1. Home
  2. Explore
  3. Computer Science
  4. Attention and Transformers

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Attention and Transformers

  • 71Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Sequence Applications

What major capability do recurrent neural networks add compared with networks designed primarily for one-to-one image tasks?

71 questions

  1. 1

    What major capability do recurrent neural networks add compared with networks designed primarily for one-to-one image tasks?

    1. A

      They replace all learned parameters with manually specified rules

    2. B

      They restrict neural networks to image classification problems

    3. C

      They guarantee that every input sequence has the same fixed length

    4. D

      They process sequences and support mappings involving multiple inputs or outputs

    Correct answer
    D

    They process sequences and support mappings involving multiple inputs or outputs

    Explanation

    Recurrent neural networks process sequential data, enabling one-to-many, many-to-one, and sequence-to-sequence problems in addition to one-to-one tasks.

  2. 2

    Which example best represents a one-to-many problem?

    1. A

      Inputting a sequence of frames and producing one classification

    2. B

      Inputting one image and producing one class label

    3. C

      Inputting an English sentence and producing one sentiment score

    4. D

      Inputting an image and generating a sequence of words describing it

    Correct answer
    D

    Inputting an image and generating a sequence of words describing it

    Explanation

    Image captioning takes one image as input and generates a sequence of words, making it a one-to-many problem.

  3. 3

    Which example best represents a many-to-one problem?

    1. A

      Inputting one word and generating a sequence of translated words

    2. B

      Inputting one image and producing one classification label

    3. C

      Inputting one image and generating a sequence of caption words

    4. D

      Inputting a sequence of video frames and producing one classification

    Correct answer
    D

    Inputting a sequence of video frames and producing one classification

    Explanation

    A many-to-one task maps a sequence of inputs, such as video frames, to a single output classification.

  4. 4

    Why is translation a sequence-to-sequence problem?

    1. A

      It maps one word to a fixed-dimensional numerical feature

    2. B

      It maps one image to one class label in the same representation

    3. C

      It maps many frames to one label without generating a sequence

    4. D

      It maps a sequence of words in one language to a sequence of words in another

    Correct answer
    D

    It maps a sequence of words in one language to a sequence of words in another

    Explanation

    Machine translation receives an input word sequence, such as English, and produces an output word sequence, such as Italian or French.

  5. 5

    Why can translation not generally rely on a position-by-position correspondence between source and target words?

    1. A

      Every translated word must correspond to exactly one source character

    2. B

      The source and target languages always contain the same number of words

    3. C

      The target sentence is generated without using any source information

    4. D

      The two languages may differ in both sentence length and word order

    Correct answer
    D

    The two languages may differ in both sentence length and word order

    Explanation

    The number and order of words can differ between languages, so translation requires a flexible sequence-processing architecture.

  6. 6

    What distinguishes a recurrent neural network unit from a standard feed-forward unit in sequence processing?

    1. A

      It uses the current input together with the previous hidden state

    2. B

      It requires the entire sequence to be presented simultaneously

    3. C

      It uses fixed, non-learnable weights at every time step

    4. D

      It uses only the current input and discards all previous information

    Correct answer
    A

    It uses the current input together with the previous hidden state

    Explanation

    An RNN unit receives the current input xtx_txt​ and the previous hidden state ht−1h_{t-1}ht−1​, then produces a new hidden state.

  7. 7

    What does applying the same recurrent unit repeatedly across time allow an RNN to process?

    1. A

      Only sequences containing exactly one token

    2. B

      Sequences whose lengths can vary across examples

    3. C

      Sequences whose length must equal the hidden-state dimension

    4. D

      Only images with a fixed spatial resolution

    Correct answer
    B

    Sequences whose lengths can vary across examples

    Explanation

    The recurrent unit is reused at successive time steps, allowing it to process sequences of potentially variable length.

  8. 8

    Why are transformers considered broadly useful across modern deep-learning applications?

    1. A

      They eliminate the need for training data in all large-scale applications

    2. B

      They are restricted to translating short sentences between closely related languages

    3. C

      They can serve as large, data-trained architectures for text, images, audio, and other tasks

    4. D

      They are designed only for classifying two-dimensional images

    Correct answer
    C

    They can serve as large, data-trained architectures for text, images, audio, and other tasks

    Explanation

    The lecture identifies transformers as the dominant architecture for many large, state-of-the-art applications involving text, images, audio, and more.

  9. 9

    What is the role of the encoder in a recurrent sequence-to-sequence model?

    1. A

      It generates the output tokens without receiving any hidden state

    2. B

      It processes the input sequence and summarizes it for the decoder

    3. C

      It compares only the first and last tokens of the input sequence

    4. D

      It converts every output token directly into an image

    Correct answer
    B

    It processes the input sequence and summarizes it for the decoder

    Explanation

    The encoder RNN processes the input sequence and creates a representation that the decoder can use to generate the target sequence.

  10. 10

    In the basic encoder-decoder RNN described, what does the context vector usually represent?

    1. A

      A fixed-dimensional summary based on the encoder's final hidden state

    2. B

      A probability distribution over the output vocabulary at every step

    3. C

      A variable-length list containing every raw input token

    4. D

      The decoder's previous output token without any source information

    Correct answer
    A

    A fixed-dimensional summary based on the encoder's final hidden state

    Explanation

    The context vector is commonly formed from the encoder's last hidden state, which is intended to summarize the entire input sequence.

  11. 11

    Which inputs does the decoder RNN unit receive at each output time step in the basic model?

    1. A

      The entire target sequence and the decoder's final state

    2. B

      Only the previous output token and a fixed classification label

    3. C

      The previous output token, previous decoder state, and context vector

    4. D

      Only the current source token and the encoder's initial state

    Correct answer
    C

    The previous output token, previous decoder state, and context vector

    Explanation

    The decoder receives yt−1y_{t-1}yt−1​, the previous decoder hidden state st−1s_{t-1}st−1​, and the context vector CCC.

  12. 12

    Why does the basic encoder-decoder architecture create a communication bottleneck?

    1. A

      The encoder is unable to process more than one input token

    2. B

      The decoder receives every encoder hidden state independently at every output step

    3. C

      The output sequence must always have the same length as the input sequence

    4. D

      All information from the input sequence must pass through one fixed-length context vector

    Correct answer
    D

    All information from the input sequence must pass through one fixed-length context vector

    Explanation

    The input and output sequences communicate only through the single fixed-length vector CCC, creating a bottleneck as sequences become longer.

  13. 13

    Why does the fixed context vector become problematic for very long sequences?

    1. A

      A fixed-size representation may be unable to preserve all relevant information from a long input

    2. B

      The encoder loses the ability to apply the same recurrent unit repeatedly

    3. C

      The context vector automatically grows so large that it cannot be stored

    4. D

      Long sequences prevent the decoder from producing any output token

    Correct answer
    A

    A fixed-size representation may be unable to preserve all relevant information from a long input

    Explanation

    The vector's dimensionality remains fixed even as the input grows, making it increasingly unreasonable to expect it to summarize an entire paragraph, book, or corpus.

  14. 14

    What architectural change addresses the fixed-vector bottleneck in an encoder-decoder RNN?

    1. A

      Force the encoder to compress the input into an even smaller vector

    2. B

      Allow the decoder to look back at the full input sequence at every output step

    3. C

      Require the decoder to generate all output tokens simultaneously

    4. D

      Remove the input sequence after computing the first decoder state

    Correct answer
    B

    Allow the decoder to look back at the full input sequence at every output step

    Explanation

    Attention gives the decoder access to the input sequence repeatedly, allowing it to compute a new summary for each output step.

  15. 15

    What is the purpose of an alignment score in an attention-based decoder?

    1. A

      It measures how well a decoder state matches each encoder hidden state

    2. B

      It determines the fixed dimensionality of the decoder's weight matrices

    3. C

      It measures the number of recurrent steps remaining in the sequence

    4. D

      It directly specifies the correct output token without learning

    Correct answer
    A

    It measures how well a decoder state matches each encoder hidden state

    Explanation

    An alignment score is computed for each input position to estimate how relevant that encoder state is to the current decoder state.

  16. 16

    How can a simple learned alignment function produce one score for a decoder state and an encoder state?

    1. A

      It averages all output tokens and compares the result with the input length

    2. B

      It multiplies the two states element by element and keeps the entire resulting vector

    3. C

      It applies a hard threshold to the decoder state without using the encoder state

    4. D

      It concatenates the two states and applies a learned linear transformation to a scalar

    Correct answer
    D

    It concatenates the two states and applies a learned linear transformation to a scalar

    Explanation

    The described function concatenates the decoder hidden state and an encoder hidden state, then applies a learned linear layer that outputs a scalar.

  17. 17

    Why is softmax applied to the alignment scores?

    1. A

      It converts arbitrary scores into nonnegative weights that sum to one

    2. B

      It forces all input positions to receive exactly equal weight

    3. C

      It converts every score into an unrestricted negative or positive value

    4. D

      It removes the need for any learned alignment function

    Correct answer
    A

    It converts arbitrary scores into nonnegative weights that sum to one

    Explanation

    Softmax transforms the alignment scores into a probability-like distribution whose entries lie between 000 and 111 and sum to 111.

  18. 18

    How is an attention context vector computed from encoder hidden states?

    1. A

      It is formed by selecting the longest encoder state without weighting

    2. B

      It is always equal to the encoder's first hidden state

    3. C

      It is produced by concatenating all encoder states without any learned weights

    4. D

      It is a weighted linear combination of encoder states using attention weights

    Correct answer
    D

    It is a weighted linear combination of encoder states using attention weights

    Explanation

    The context vector is computed as a linear combination of the encoder hidden states, weighted by the attention distribution.

  19. 19

    Why might a decoder assign higher attention weights to the source words corresponding to a word it is currently generating?

    1. A

      The decoder is explicitly given a human-provided word alignment

    2. B

      Every output word must attend equally to every source word

    3. C

      Attention weights are required to be largest for the first source word

    4. D

      Those source words may contain the information most relevant to predicting the current output

    Correct answer
    D

    Those source words may contain the information most relevant to predicting the current output

    Explanation

    Attention allows the decoder to emphasize source words that are useful for producing the current target word, such as focusing on relevant words during translation.

  20. 20

    How is attention learning performed in the translation model described?

    1. A

      The decoder learns attention only after the output sequence is manually reordered

    2. B

      The attention mechanism is learned end to end through gradient descent on the output prediction task

    3. C

      Human annotators must label the source words used for every target word

    4. D

      The alignment weights are fixed randomly and never updated

    Correct answer
    B

    The attention mechanism is learned end to end through gradient descent on the output prediction task

    Explanation

    The entire computation graph is differentiable, so the model learns attention weights indirectly through the output-token loss and gradient descent.

  21. 21

    What loss provides the training signal for learning attention in the sequence-to-sequence example?

    1. A

      A loss that directly compares human-labeled alignment matrices

    2. B

      A classification loss for identifying the source language only

    3. C

      A reconstruction loss for reproducing the encoder's initial state

    4. D

      A cross-entropy loss for predicting the target sequence tokens

    Correct answer
    D

    A cross-entropy loss for predicting the target sequence tokens

    Explanation

    The network is trained to predict the correct output tokens using a cross-entropy and softmax objective, and attention is learned as part of that process.

  22. 22

    Which statement correctly distinguishes decoder weight initialization from decoder-state initialization?

    1. A

      Weights are learned parameters, whereas the initial hidden state is set when processing each sequence

    2. B

      Weights are recomputed at every time step, whereas the initial state is fixed during all training

    3. C

      Weights are output tokens, whereas the initial state is an alignment score

    4. D

      Weights and the initial state are identical objects with the same role

    Correct answer
    A

    Weights are learned parameters, whereas the initial hidden state is set when processing each sequence

    Explanation

    Decoder weights are typically initialized randomly and learned by gradient descent. Separately, an initial decoder state must be chosen for each processed sequence.

  23. 23

    Which is one possible method for setting the decoder's initial hidden state?

    1. A

      Use the attention distribution from a decoder state that does not yet exist

    2. B

      Always use the first target token before the target sequence has been generated

    3. C

      Use zeros, the encoder's final state, or a learned projection of the encoder's final state

    4. D

      Set the state equal to the number of words in the source sentence

    Correct answer
    C

    Use zeros, the encoder's final state, or a learned projection of the encoder's final state

    Explanation

    Possible strategies include initializing the state to zeros, using the encoder's final state, or applying a learned projection from the encoder's final state.

  24. 24

    What changes when the decoder advances from one output step to the next in an attention-based RNN?

    1. A

      It reuses one context vector permanently for the entire output sequence

    2. B

      It discards the encoder states after generating the first output token

    3. C

      It computes attention only over previously generated output tokens

    4. D

      It computes a new alignment distribution and a new context vector using the new decoder state

    Correct answer
    D

    It computes a new alignment distribution and a new context vector using the new decoder state

    Explanation

    At every decoder step, the current decoder state is compared with all encoder states to produce a new attention distribution and context vector.

  25. 25

    What information does an attention visualization matrix show in a translation task?

    1. A

      The raw pixel values associated with each translated word

    2. B

      The number of recurrent layers used to encode each target word

    3. C

      The attention distribution over source words for each generated target word

    4. D

      The learned vocabulary size for each source word in the sentence

    Correct answer
    C

    The attention distribution over source words for each generated target word

    Explanation

    Each row can represent the distribution over the input sentence predicted while generating one output word.

  26. 26

    What does a diagonal pattern in an attention matrix usually indicate?

    1. A

      An equal attention weight assigned to every source word

    2. B

      A requirement that every target word attend to the final source word

    3. C

      A complete lack of correspondence between the two languages

    4. D

      A mostly order-preserving correspondence between source and target words

    Correct answer
    D

    A mostly order-preserving correspondence between source and target words

    Explanation

    Diagonal structures suggest that source and target words align in roughly the same order.

  27. 27

    What can a backward-diagonal pattern in an attention matrix suggest?

    1. A

      The model is applying a convolutional kernel to the source sentence

    2. B

      The model has learned a reversed or differently ordered correspondence between languages

    3. C

      The model has learned that all source words are irrelevant

    4. D

      The model is assigning equal probability to all possible translations

    Correct answer
    B

    The model has learned a reversed or differently ordered correspondence between languages

    Explanation

    A backward diagonal can reflect a different word order between the source and target languages.

  28. 28

    What might a small two-by-two attention block indicate in a translation visualization?

    1. A

      Several source and target words have a less perfectly one-to-one alignment

    2. B

      The model has stopped computing attention for the remainder of the sentence

    3. C

      The decoder has been initialized with an all-zero hidden state

    4. D

      Every source word is aligned with exactly one target word in order

    Correct answer
    A

    Several source and target words have a less perfectly one-to-one alignment

    Explanation

    A block-like pattern can indicate that multiple words in one language correspond to multiple words in the other without perfect one-to-one disentanglement.

  29. 29

    In the generalized attention operator, what are the data vectors?

    1. A

      Vectors that determine the order in which queries are generated

    2. B

      Vectors representing only the model's learned scalar loss values

    3. C

      Vectors containing information that can be summarized for the task

    4. D

      Vectors that specify only the output vocabulary probabilities

    Correct answer
    C

    Vectors containing information that can be summarized for the task

    Explanation

    In the original RNN setting, the encoder hidden states serve as data vectors that the attention mechanism summarizes.

  30. 30

    In the generalized attention operator, what is a query vector?

    1. A

      A vector containing every data vector concatenated without comparison

    2. B

      A vector used only to initialize the encoder's recurrent state

    3. C

      A vector used to determine how the data vectors should be summarized for one output

    4. D

      A vector that permanently stores the model's output vocabulary

    Correct answer
    C

    A vector used to determine how the data vectors should be summarized for one output

    Explanation

    A query represents the information needed to produce a particular output and is compared with the data vectors to determine relevance.

  31. 31

    What does the attention operator produce for each query vector?

    1. A

      A new sequence whose length must exceed the number of data vectors

    2. B

      A copy of the query vector with no contribution from the data

    3. C

      An output vector formed by summarizing the data vectors according to query-dependent weights

    4. D

      A fixed scalar that is independent of all data vectors

    Correct answer
    C

    An output vector formed by summarizing the data vectors according to query-dependent weights

    Explanation

    Attention compares a query with the data, creates weights, and uses those weights to form an output summary vector.

  32. 32

    What is the simplest commonly used similarity function between a query and a key?

    1. A

      The number of tokens in the source sequence

    2. B

      Their dot product

    3. C

      The maximum coordinate of the two vectors

    4. D

      Their concatenation without any further operation

    Correct answer
    B

    Their dot product

    Explanation

    Although many functions are possible in principle, the lecture introduces the dot product as a simple similarity measure.

  33. 33

    Why is the dot product scaled by the square root of the vector dimension in scaled dot-product attention?

    1. A

      To ensure that every attention weight becomes exactly equal

    2. B

      To allow dot products between vectors with unrelated dimensions

    3. C

      To remove the need for query, key, and value projections

    4. D

      To reduce overly sharp softmax behavior and help prevent vanishing gradients

    Correct answer
    D

    To reduce overly sharp softmax behavior and help prevent vanishing gradients

    Explanation

    Scaling by the square root of the dimension helps maintain better gradient flow through the softmax as vector dimensions grow.

  34. 34

    Why are matrix multiplications useful when attention processes many queries and data vectors?

    1. A

      They eliminate the need to calculate any similarity between queries and data

    2. B

      They force the attention layer to process only one query at a time

    3. C

      They efficiently compute all pairwise dot products and weighted combinations in parallel

    4. D

      They guarantee that the input vectors have identical semantic meanings

    Correct answer
    C

    They efficiently compute all pairwise dot products and weighted combinations in parallel

    Explanation

    A matrix multiplication computes many inner products at once, and another matrix multiplication forms the weighted combinations of value vectors.

  35. 35

    When attention handles multiple query vectors, what distribution is computed for each query?

    1. A

      A distribution over the dimensions of the query vector only

    2. B

      A distribution over the model's training examples

    3. C

      A distribution over the data vectors or keys

    4. D

      A distribution over the decoder layers rather than the input vectors

    Correct answer
    C

    A distribution over the data vectors or keys

    Explanation

    Each query receives its own softmax distribution over the available data vectors or keys.

  36. 36

    Why are keys and values introduced as separate projections of the data vectors?

    1. A

      They make the query vectors unnecessary during attention computation

    2. B

      They let the model learn separate representations for matching queries and producing retrieved outputs

    3. C

      They eliminate all learned parameters from the attention layer

    4. D

      They force the model to use the same representation for matching and retrieval

    Correct answer
    B

    They let the model learn separate representations for matching queries and producing retrieved outputs

    Explanation

    Keys are compared with queries to compute alignment, while values are combined to produce the output, allowing these two roles to be learned separately.

  37. 37

    What does the key projection do in a cross-attention layer?

    1. A

      It transforms each query into the final output without using the data

    2. B

      It transforms each data vector into a representation compared with the queries

    3. C

      It determines the number of output time steps in the decoder

    4. D

      It converts attention weights into target-language tokens directly

    Correct answer
    B

    It transforms each data vector into a representation compared with the queries

    Explanation

    The key matrix projects data vectors into keys, which are compared with query vectors to obtain similarity scores.

  38. 38

    What does the value projection do in a cross-attention layer?

    1. A

      It computes the similarity scores while ignoring the query vectors

    2. B

      It transforms each data vector into a representation that is weighted to form outputs

    3. C

      It converts each output token into a source-language word

    4. D

      It determines the initial hidden state of the encoder

    Correct answer
    B

    It transforms each data vector into a representation that is weighted to form outputs

    Explanation

    The value vectors are combined using the attention weights to produce the attention layer's output vectors.

  39. 39

    Which situation most naturally calls for cross-attention?

    1. A

      Normalizing each feature independently without comparing any vectors

    2. B

      Applying a linear classifier to one already-computed feature vector

    3. C

      Generating text from an image by relating image representations to text-generation queries

    4. D

      Processing only one collection of image patches with no second input source

    Correct answer
    C

    Generating text from an image by relating image representations to text-generation queries

    Explanation

    Cross-attention is useful when two distinct sets of vectors interact, such as image features and text-generation states.

  40. 40

    What is the defining input structure of a self-attention layer?

    1. A

      Only scalar inputs are accepted, so vector comparisons are impossible

    2. B

      A recurrent hidden state must be supplied before any attention computation

    3. C

      Two unrelated sets of vectors are required to generate queries and values

    4. D

      One set of input vectors is used to generate queries, keys, and values

    Correct answer
    D

    One set of input vectors is used to generate queries, keys, and values

    Explanation

    Self-attention derives queries, keys, and values from the same input sequence or set of vectors.

  41. 41

    How does self-attention differ from cross-attention in its use of input representations?

    1. A

      Self-attention requires recurrence, whereas cross-attention cannot use learned weights

    2. B

      Self-attention computes one scalar, whereas cross-attention always computes a classification label

    3. C

      Self-attention derives queries, keys, and values from one input set, whereas cross-attention uses distinct sets

    4. D

      Self-attention uses no values, whereas cross-attention uses no keys

    Correct answer
    C

    Self-attention derives queries, keys, and values from one input set, whereas cross-attention uses distinct sets

    Explanation

    Cross-attention relates two sets, while self-attention projects one set into queries, keys, and values and relates the elements within that set.

  42. 42

    Why might image classification use self-attention rather than cross-attention?

    1. A

      Self-attention is used only when the input contains words in two languages

    2. B

      Cross-attention cannot compute weighted combinations of image representations

    3. C

      The relevant inputs are image regions that need to interact with one another within one set

    4. D

      Image classification always requires an independent target sentence as a second input

    Correct answer
    C

    The relevant inputs are image regions that need to interact with one another within one set

    Explanation

    When there is one set of inputs, such as image patches, self-attention allows the elements of that set to exchange information.

  43. 43

    What happens to self-attention outputs if the input vectors are permuted while the weights remain fixed?

    1. A

      The output vectors become independent random vectors with new values

    2. B

      All output vectors collapse into one identical vector

    3. C

      The attention layer becomes unable to compute any output

    4. D

      The same output vectors are produced in the corresponding permuted order

    Correct answer
    D

    The same output vectors are produced in the corresponding permuted order

    Explanation

    Because the operations are permutation-equivariant, permuting the inputs permutes the outputs in the same way.

  44. 44

    Why is self-attention described as operating on sets rather than inherently ordered sequences?

    1. A

      It always sorts the inputs alphabetically before processing them

    2. B

      It uses recurrence to remember the order of previously processed vectors

    3. C

      It requires every sequence to contain exactly one vector

    4. D

      Its computation does not depend on the order in which the input vectors are presented

    Correct answer
    D

    Its computation does not depend on the order in which the input vectors are presented

    Explanation

    Without an added positional signal, self-attention produces corresponding outputs regardless of how the input vectors are ordered.

  45. 45

    What problem results from self-attention's lack of inherent order information when processing language?

    1. A

      The model cannot represent more than one word at a time

    2. B

      The model is forced to use a recurrent unit after every attention operation

    3. C

      The model may not know the positions of words in the sequence

    4. D

      The model cannot compute dot products between any two words

    Correct answer
    C

    The model may not know the positions of words in the sequence

    Explanation

    Self-attention alone is insensitive to ordering, so language models need an additional signal indicating each token's position.

  46. 46

    What is the purpose of a positional embedding?

    1. A

      It replaces the value projection with a fixed classification vector

    2. B

      It forces all vectors at different positions to have different dimensions

    3. C

      It supplies information about where each input vector occurs in the sequence

    4. D

      It prevents attention weights from being normalized by softmax

    Correct answer
    C

    It supplies information about where each input vector occurs in the sequence

    Explanation

    A positional embedding is concatenated or added to an input representation to communicate its sequence index or position.

  47. 47

    What does masked self-attention accomplish?

    1. A

      It restricts which input positions are allowed to influence each output position

    2. B

      It allows the model to inspect future tokens specifically to improve training accuracy

    3. C

      It removes all attention weights before the output projection

    4. D

      It guarantees that every input position attends equally to every other position

    Correct answer
    A

    It restricts which input positions are allowed to influence each output position

    Explanation

    Masked self-attention modifies selected alignment scores so that particular interactions are blocked.

  48. 48

    Why are negative infinities inserted into selected attention scores during masking?

    1. A

      Their softmax probabilities become zero, preventing those positions from contributing

    2. B

      They make the corresponding queries and keys identical

    3. C

      Their softmax probabilities become one, forcing attention to those positions

    4. D

      They increase the magnitude of the corresponding value vectors

    Correct answer
    A

    Their softmax probabilities become zero, preventing those positions from contributing

    Explanation

    A score of negative infinity receives probability zero after softmax, so the associated value cannot affect the output.

  49. 49

    Why is masking useful for autoregressive language modeling?

    1. A

      It prevents an output at position ttt from using future input tokens

    2. B

      It ensures that the model attends only to the final token

    3. C

      It allows each output to use every future token before it is generated

    4. D

      It replaces the language-modeling loss with an image-classification loss

    Correct answer
    A

    It prevents an output at position ttt from using future input tokens

    Explanation

    For autoregressive prediction, the output at position ttt should depend only on the current and earlier tokens, not on future tokens.

  50. 50

    What is multi-headed self-attention?

    1. A

      Several independent self-attention copies run in parallel and their outputs are fused

    2. B

      Several recurrent networks process the same sequence one after another

    3. C

      One attention head assigns a separate scalar to every model parameter

    4. D

      One self-attention layer runs repeatedly with exactly the same weights

    Correct answer
    A

    Several independent self-attention copies run in parallel and their outputs are fused

    Explanation

    Multi-headed self-attention routes the inputs through multiple independently parameterized attention heads and combines their outputs with a projection.

  51. 51

    What distinguishes different attention heads in a multi-headed layer?

    1. A

      They receive different examples but cannot process the same input

    2. B

      They use different input sequence lengths but no learned parameters

    3. C

      They perform unrelated operations such as convolution and pooling

    4. D

      They have different learned weights while sharing the same general computation

    Correct answer
    D

    They have different learned weights while sharing the same general computation

    Explanation

    The heads use the same attention architecture but have separately initialized and learned weight matrices, allowing them to learn different transformations.

  52. 52

    Which feature makes self-attention highly parallelizable?

    1. A

      Its main computations can be expressed as large batched matrix multiplications

    2. B

      It processes only one vector during the entire forward pass

    3. C

      It uses manually ordered symbolic rules instead of numerical operations

    4. D

      Each output must wait for the previous output's hidden state

    Correct answer
    A

    Its main computations can be expressed as large batched matrix multiplications

    Explanation

    The projections, similarity calculations, value combinations, and output mixing can be implemented with batched matrix multiplications.

  53. 53

    Why are recurrent neural networks difficult to parallelize across a sequence?

    1. A

      They discard all previous hidden states before computing the next one

    2. B

      They use only matrix multiplications, which cannot run on parallel hardware

    3. C

      They require every input to be independently compared with every other input

    4. D

      Each hidden state depends on the hidden state computed at the previous time step

    Correct answer
    D

    Each hidden state depends on the hidden state computed at the previous time step

    Explanation

    The recurrence creates a sequential dependency from one time step to the next, preventing straightforward parallel computation across positions.

  54. 54

    What type of structure does convolution primarily operate on?

    1. A

      Single scalar outputs without any input geometry

    2. B

      Only variable-length word sequences with no spatial arrangement

    3. C

      Unordered sets with no local neighborhood structure

    4. D

      Multi-dimensional grids such as image grids

    Correct answer
    D

    Multi-dimensional grids such as image grids

    Explanation

    Convolution operates on grids, including one-dimensional, two-dimensional, and higher-dimensional grids.

  55. 55

    What is a key limitation of convolution for modeling very long-range relationships?

    1. A

      It cannot be computed at multiple spatial positions in parallel

    2. B

      It automatically gives every input position access to every other position in one small kernel

    3. C

      It mixes information locally and may require large kernels or many layers for a large receptive field

    4. D

      It can process only one-dimensional inputs

    Correct answer
    C

    It mixes information locally and may require large kernels or many layers for a large receptive field

    Explanation

    Convolution has local receptive fields, so broad information exchange requires large kernels or stacking many layers.

  56. 56

    What is a major computational advantage of self-attention over recurrence?

    1. A

      All positions can interact in one layer using operations that are highly parallelizable

    2. B

      It requires more sequential steps than an RNN for every sequence

    3. C

      It reduces every input sequence to one fixed vector before processing

    4. D

      It eliminates all computation involving pairwise interactions

    Correct answer
    A

    All positions can interact in one layer using operations that are highly parallelizable

    Explanation

    A self-attention layer allows every vector to attend to every other vector in a single operation, implemented efficiently with matrix multiplications.

  57. 57

    What is the main computational cost of standard self-attention for a sequence of length nnn?

    1. A

      Its cost grows only linearly because each vector sees one neighbor

    2. B

      Its cost decreases as the sequence length increases

    3. C

      Its pairwise interactions require approximately quadratic compute and memory in nnn

    4. D

      Its cost is always constant regardless of the sequence length

    Correct answer
    C

    Its pairwise interactions require approximately quadratic compute and memory in nnn

    Explanation

    Standard self-attention compares each query with every key, leading to approximately n2n^2n2 computation and memory for sequence length nnn.

  58. 58

    Why can a large amount of computation be beneficial in a neural network despite higher computational cost?

    1. A

      More computation automatically makes every prediction mathematically correct

    2. B

      More computation guarantees that the model will need no training data

    3. C

      Higher computational cost removes the need for learned parameters

    4. D

      More computation can give the model greater capacity to process and reason about its inputs

    Correct answer
    D

    More computation can give the model greater capacity to process and reason about its inputs

    Explanation

    The lecture notes that increased computation can provide more capacity and allow a network to perform more processing, even though it is more expensive.

  59. 59

    What is the central computational primitive of a transformer?

    1. A

      A single convolutional kernel

    2. B

      A fixed-size recurrent bottleneck

    3. C

      Self-attention

    4. D

      A manually programmed alignment table

    Correct answer
    C

    Self-attention

    Explanation

    Transformers are neural-network architectures that place self-attention at the core of their computation.

  60. 60

    What is the role of self-attention inside a transformer block?

    1. A

      It converts the entire input into one scalar before normalization

    2. B

      It allows the vectors in the representation to communicate and compare with one another

    3. C

      It processes every vector independently without any interaction

    4. D

      It replaces all subsequent feed-forward computation

    Correct answer
    B

    It allows the vectors in the representation to communicate and compare with one another

    Explanation

    Self-attention allows all vectors to exchange information, providing global interactions within the representation.

  61. 61

    What is the role of the MLP or FFN inside a transformer block?

    1. A

      It applies learned computation independently to each vector

    2. B

      It determines the positional order without using learned parameters

    3. C

      It computes pairwise similarities between every pair of vectors

    4. D

      It replaces the attention weights with a recurrent hidden state

    Correct answer
    A

    It applies learned computation independently to each vector

    Explanation

    The feed-forward network or MLP operates separately on each vector, complementing self-attention's cross-vector communication.

  62. 62

    How do residual connections and layer normalization contribute to transformer blocks?

    1. A

      Residual connections remove all input information, while normalization creates sequence order

    2. B

      Residual connections enforce causal masking, while normalization computes attention scores

    3. C

      Residual connections support information flow, while normalization helps stabilize training

    4. D

      Residual connections generate vocabulary tokens, while normalization replaces the MLP

    Correct answer
    C

    Residual connections support information flow, while normalization helps stabilize training

    Explanation

    Transformer blocks wrap attention and MLP components with residual connections and layer normalization, helping preserve information and make training more stable.

  63. 63

    What is a transformer in terms of its overall structure?

    1. A

      A convolutional network with no normalization or residual connections

    2. B

      A single recurrent unit applied once to the first input token

    3. C

      A lookup table that maps each input token directly to an output token

    4. D

      A sequence of transformer blocks containing self-attention and feed-forward components

    Correct answer
    D

    A sequence of transformer blocks containing self-attention and feed-forward components

    Explanation

    A transformer is built by stacking transformer blocks, each containing self-attention, an MLP or FFN, residual connections, and normalization.

  64. 64

    How can a transformer process an image?

    1. A

      It can process only the image's first patch because attention is sequential

    2. B

      It requires a separate recurrent unit for every pixel before any transformer operation

    3. C

      It can divide the image into patches and project each patch into an input vector

    4. D

      It must first convert the image into a single scalar before using attention

    Correct answer
    C

    It can divide the image into patches and project each patch into an input vector

    Explanation

    For image applications, image patches can be separately projected into vectors that serve as transformer inputs.

  65. 65

    How can a transformer produce an image-classification prediction from patch representations?

    1. A

      Convert every patch directly into a separate unrelated class label

    2. B

      Pool the output vectors and pass the pooled representation through a linear classifier

    3. C

      Use the input image dimensions as the only classification features

    4. D

      Select the last patch and discard all other transformer outputs

    Correct answer
    B

    Pool the output vectors and pass the pooled representation through a linear classifier

    Explanation

    The transformer produces an output for each patch; pooling these outputs and applying a linear layer yields class scores.

  66. 66

    Why can the same transformer-style architecture be applied to both language and images?

    1. A

      Transformers require all inputs to be words before attention can operate

    2. B

      Both can be represented as sets or sequences of vectors processed by the same attention machinery

    3. C

      Images and language always have identical input dimensions and ordering

    4. D

      The architecture uses different fundamental operations for every application

    Correct answer
    B

    Both can be represented as sets or sequences of vectors processed by the same attention machinery

    Explanation

    Language tokens and image patches can both be embedded as vectors, allowing the same transformer primitives to process them.

  67. 67

    Why might the three projections for queries, keys, and values be fused into one matrix multiplication?

    1. A

      Hardware often handles fewer large matrix multiplications more efficiently than many smaller ones

    2. B

      Fusion removes the need for three distinct learned projections

    3. C

      Fusion guarantees that queries, keys, and values have identical learned meanings

    4. D

      Hardware cannot execute separate matrix multiplications for neural networks

    Correct answer
    A

    Hardware often handles fewer large matrix multiplications more efficiently than many smaller ones

    Explanation

    Concatenating projection matrices permits one larger matrix multiplication, which is often more efficient on modern hardware.

  68. 68

    Why is parallelizability especially valuable when scaling neural networks?

    1. A

      Parallel algorithms eliminate the need to distribute data across processors

    2. B

      Parallel algorithms can use many processors when making individual processors faster is difficult

    3. C

      Parallel algorithms require fewer operations than every possible sequential algorithm

    4. D

      Parallelizability guarantees that all model parameters have the same value

    Correct answer
    B

    Parallel algorithms can use many processors when making individual processors faster is difficult

    Explanation

    The lecture emphasizes that large computations can scale by using many processors or GPUs in parallel rather than relying on one increasingly fast processor.

  69. 69

    Which description best summarizes the historical motivation for attention?

    1. A

      Attention originated as a method for replacing softmax with a hard threshold

    2. B

      Attention developed as a way to overcome the fixed-context bottleneck in recurrent sequence-to-sequence models

    3. C

      Attention was introduced to make convolutional kernels operate on image pixels

    4. D

      Attention was designed primarily to eliminate all training data from translation

    Correct answer
    B

    Attention developed as a way to overcome the fixed-context bottleneck in recurrent sequence-to-sequence models

    Explanation

    The lecture presents attention as emerging from efforts to let an RNN decoder access relevant parts of the input sequence instead of relying on one fixed context vector.

  70. 70

    What does attention make possible that the basic encoder-decoder bottleneck does not?

    1. A

      It prevents the decoder from using any information from the input sequence

    2. B

      It forces every output step to use exactly the same source representation

    3. C

      It requires the source and target sequences to have identical lengths

    4. D

      It lets each output step dynamically summarize the full input sequence in a different way

    Correct answer
    D

    It lets each output step dynamically summarize the full input sequence in a different way

    Explanation

    Attention computes a new, query-dependent context vector at each output step, avoiding reliance on one fixed summary.

  71. 71

    What makes the attention mechanism interpretable to some extent?

    1. A

      It exposes the exact causal reason for every parameter update

    2. B

      It provides a guaranteed verbal explanation generated by the model designer

    3. C

      It uses hard-coded linguistic grammar to label every alignment

    4. D

      Its learned attention weights reveal which input positions receive emphasis for each output

    Correct answer
    D

    Its learned attention weights reveal which input positions receive emphasis for each output

    Explanation

    Visualizing attention weights can show which source positions the model emphasized while producing particular outputs, although this is not a complete explanation of the model.

Question 1 of 71
Question 1 of 71

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent