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

Study methods

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

Self-Attention and Transformers

  • 64Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Recurrent Limitations
The main bottleneck that motivated attention in machine translation was the need to encode the entire source sentence into
.

64 questions

  1. 1
    The main bottleneck that motivated attention in machine translation was the need to encode the entire source sentence into
    _____
    .
    Hint

    Attention was introduced to avoid compressing all source information into one fixed-size representation.

    Answer

    a single vector

  2. 2
    In an RNN, words that occur far apart have a large
    _____
    interaction distance because information must pass through intermediate recurrent steps.
    Hint

    The problem is named for the sequential left-to-right or right-to-left structure of recurrence.

    Answer

    linear

  3. 3
    In the sentence “The chef who went to the store ... was ...,” learning the relationship between “chef” and “was” is difficult because the dependency is
    _____
    .
    Hint

    The relevant words are separated by many intervening words.

    Answer

    long distance

  4. 4
    Although LSTMs model gradients across long distances better than simple RNNs, their handling of long-distance dependencies is
    _____
    .
    Hint

    The lecture noted that LSTMs improve the problem but do not eliminate it.

    Answer

    not perfect

  5. 5
    The hidden state at time step five in a recurrent network cannot be computed before the hidden state at time step
    _____
    .
    Hint

    A recurrent computation depends directly on the immediately preceding state.

    Answer

    four

  6. 6
    The number of sequentially dependent, unparallelizable operations in an RNN grows with the
    _____
    of the input.
    Hint

    Longer sequences require more recurrent steps before later states can be computed.

    Answer

    sequence length

  7. 7
    The dependence of RNN computation on the sequence index is also commonly described as dependence on
    _____
    .
    Hint

    Each recurrent state corresponds to a particular position in the sequence.

    Answer

    time

  8. 8
    Attention represents each word as a
    _____
    that accesses and incorporates information from a set of values.
    Hint

    In the key-value lookup analogy, this object asks which stored information is relevant.

    Answer

    query

  9. 9
    In an ordinary lookup table, a query that exactly matches a key returns the key's associated
    _____
    .
    Hint

    A dictionary maps keys to what is stored under them.

    Answer

    value

  10. 10
    Unlike an exact dictionary lookup, attention compares a query with
    _____
    keys and matches them softly.
    Hint

    Attention computes similarities rather than selecting only one exact match.

    Answer

    all

  11. 11
    The similarity scores in attention are converted into weights between zero and one using a
    _____
    .
    Hint

    This function normalizes a set of scores into a probability-like distribution.

    Answer

    softmax

  12. 12
    The output of attention is formed by taking a
    _____
    sum of the value vectors.
    Hint

    Each value contributes according to the similarity between its key and the query.

    Answer

    weighted

  13. 13
    In self-attention, the query, key, and value for each word are produced by transforming its non-contextual word embedding with three different
    _____
    .
    Hint

    These are learned linear transformations commonly denoted by Q, K, and V.

    Answer

    weight matrices

  14. 14
    If a word embedding has dimensionality DDD, multiplying it by a key matrix maps it to a key vector of dimensionality
    _____
    .
    Hint

    In the basic formulation, the query, key, and value transformations preserve dimensionality.

    Answer

    DDD

  15. 15
    The attention score between a query for one word and a key for another word is computed using their
    _____
    .
    Hint

    The score measures alignment between two vectors through multiplication and summation.

    Answer

    dot product

  16. 16
    A word's self-attention representation is computed by summing the value vectors for all words, weighted by their
    _____
    with that word's query.
    Hint

    These weights come from normalized query-key similarities.

    Answer

    attention weights

  17. 17
    Self-attention can be interpreted as a fuzzy lookup in a
    _____
    store.
    Hint

    This analogy uses queries to softly retrieve stored values through keys.

    Answer

    key-value

  18. 18
    When all word embeddings are stacked into a matrix, the sequence representation has shape
    _____
    .
    Hint

    The first dimension indexes sequence positions and the second indexes embedding dimensions.

    Answer

    nnn by DDD

  19. 19
    Multiplying the stacked sequence matrix by the query, key, or value matrix applies the same transformation to every word using one large
    _____
    .
    Hint

    This avoids explicitly looping over sequence positions.

    Answer

    matrix multiply

  20. 20
    The softmax in matrix-form self-attention is applied across the dimension representing the possible
    _____
    positions.
    Hint

    For each query, the scores must be normalized over the positions it may attend to.

    Answer

    key

  21. 21
    After the attention weights are computed, multiplying them by the stacked value matrix produces the complete self-attention
    _____
    .
    Hint

    This operation performs all weighted averages at once.

    Answer

    output

  22. 22
    Computing all pairwise interactions in self-attention requires memory and computation that grow
    _____
    with sequence length.
    Hint

    The score matrix has one entry for every pair of positions.

    Answer

    quadratically

  23. 23
    The matrix-vector formulation of self-attention is especially useful because GPUs can perform the operations
    _____
    .
    Hint

    Vectorization allows many position-wise calculations to be grouped together.

    Answer

    in parallel

  24. 24
    Multi-head attention allows different attention mechanisms to examine different parts of a sequence for different
    _____
    .
    Hint

    One head might focus on syntactic relations while another focuses on entities or context.

    Answer

    reasons

  25. 25
    In multi-head attention, each head has an independent query, key, and
    _____
    matrix.
    Hint

    The three transformations correspond to the three roles in key-query-value attention.

    Answer

    value

  26. 26
    If the model dimensionality is DDD and there are HHH heads, each head typically operates in a space of dimensionality
    _____
    .
    Hint

    The model representation is divided among the heads.

    Answer

    DDD divided by HHH

  27. 27
    After each attention head produces an output, the outputs are
    _____
    together along their feature dimension.
    Hint

    The separate head representations are joined into one larger representation.

    Answer

    concatenated

  28. 28
    A final linear transformation is applied after concatenating the attention heads to
    _____
    their information together.
    Hint

    The transformation combines the specialized representations into the model's output space.

    Answer

    mix

  29. 29
    The number of attention heads is often scaled with model dimensionality so that each head has a reasonable number of
    _____
    .
    Hint

    The lecture gave values such as 64 or 128 dimensions per head as an intuition.

    Answer

    dimensions

  30. 30
    The fact that different attention heads often learn different roles is called head
    _____
    .
    Hint

    Different heads may focus on syntactic dependencies, averaging context, or other patterns.

    Answer

    specialization

  31. 31
    Scaled dot-product attention divides attention scores by a constant based on the head's model
    _____
    .
    Hint

    The scaling compensates for the tendency of dot products to grow in high-dimensional spaces.

    Answer

    dimensionality

  32. 32
    Without scaling, large dot products can make the softmax distribution too peaked and cause the
    _____
    to become small.
    Hint

    The problem concerns learning difficulty when softmax inputs have very large magnitudes.

    Answer

    gradients

  33. 33
    Plain self-attention has no inherent notion of the
    _____
    of words in a sequence.
    Hint

    Reordering the same set of word embeddings would otherwise produce the same corresponding representations.

    Answer

    order

  34. 34
    Without position information, self-attention would give the same representations to sequences containing the same words in different
    _____
    .
    Hint

    For example, “Zuko made his uncle” and “his uncle made Zuko” would be indistinguishable.

    Answer

    orders

  35. 35
    A position vector can be added to a word embedding so the representation contains both word identity and sequence
    _____
    .
    Hint

    The added vector indicates whether the word is at position one, two, three, and so on.

    Answer

    position

  36. 36
    Sinusoidal positional representations use sine and cosine functions with different
    _____
    across dimensions.
    Hint

    Different periodic patterns allow position vectors to vary across dimensions.

    Answer

    periods

  37. 37
    A learned positional representation can be implemented as a matrix with dimensions equal to model dimensionality by maximum
    _____
    length.
    Hint

    The matrix contains one learned vector for each possible position up to a fixed limit.

    Answer

    sequence

  38. 38
    A limitation of learned absolute position embeddings is that the model cannot directly process sequences longer than the maximum
    _____
    length used to learn them.
    Hint

    Only a fixed number of position vectors are available.

    Answer

    sequence

  39. 39
    In autoregressive decoding, attention must be masked so that a word cannot attend to words in the
    _____
    .
    Hint

    The model should predict the next word without seeing the answer in advance.

    Answer

    future

  40. 40
    Future attention scores are effectively set to
    _____
    before the softmax operation.
    Hint

    This value becomes zero after softmax.

    Answer

    negative infinity

  41. 41
    Causal masking permits a position to attend to itself and positions at
    _____
    indices.
    Hint

    The decoder may use the current and preceding context, but not later tokens.

    Answer

    earlier

  42. 42
    Self-attention alone repeatedly averages value vectors, so a feed-forward network is added to provide
    _____
    and nonlinear expressivity.
    Hint

    This component supplies the traditional deep-learning transformations missing from pure weighted averaging.

    Answer

    nonlinearities

  43. 43
    The feed-forward network applied after self-attention processes each word position
    _____
    .
    Hint

    Self-attention mixes information across positions; the following network operates separately on each resulting vector.

    Answer

    independently

  44. 44
    A residual connection adds a layer's output to its
    _____
    .
    Hint

    The skip path carries the representation around the layer.

    Answer

    input

  45. 45
    Residual connections help gradients flow through a layer because the skip path implements the
    _____
    function.
    Hint

    The input is passed directly along the shortcut without a learned transformation.

    Answer

    identity

  46. 46
    Residual connections can make a network easier to optimize because the layer initially needs to learn only the
    _____
    from the previous representation.
    Hint

    The layer models the difference between the desired transformation and simply copying its input.

    Answer

    residual

  47. 47
    Layer normalization normalizes the coordinates of an individual word vector across its model
    _____
    .
    Hint

    The mean and standard deviation are computed across the features of one vector.

    Answer

    dimensions

  48. 48
    Layer normalization subtracts the vector's mean and divides by its standard deviation plus a small
    _____
    .
    Hint

    This small constant prevents numerical instability when variation is very small.

    Answer

    epsilon

  49. 49
    Unlike batch normalization, layer normalization computes its statistics independently for each
    _____
    .
    Hint

    The lecture emphasized that statistics are not shared across sequence positions or batch examples.

    Answer

    word vector

  50. 50
    A Transformer decoder block consists of masked multi-head self-attention followed by add-and-norm, then a feed-forward layer followed by another
    _____
    .
    Hint

    Each major sublayer is paired with a residual connection and layer normalization.

    Answer

    add-and-norm

  51. 51
    A Transformer encoder uses multi-head self-attention without causal
    _____
    because it can access the entire input sequence.
    Hint

    Unlike an autoregressive decoder, the encoder is allowed to use bidirectional context.

    Answer

    masking

  52. 52
    The Transformer decoder uses causal masking because it must generate a sequence
    _____
    .
    Hint

    Each next token is predicted from the tokens already generated.

    Answer

    autoregressively

  53. 53
    In an encoder-decoder Transformer, the decoder's masked self-attention is followed by an operation called
    _____
    attention.
    Hint

    This operation connects representations from the decoder to representations produced by the encoder.

    Answer

    cross

  54. 54
    In encoder-decoder cross attention, the decoder representations provide the
    _____
    .
    Hint

    The decoder asks which source information is relevant to generating the next target token.

    Answer

    queries

  55. 55
    In encoder-decoder cross attention, the encoder outputs provide the keys and
    _____
    .
    Hint

    The source sequence supplies the information that the decoder retrieves.

    Answer

    values

  56. 56
    The original Transformer architecture was presented in the paper titled “
    _____
    Is All You Need.”
    Hint

    The title emphasizes the central mechanism replacing recurrence.

    Answer

    Attention

  57. 57
    Transformers were more efficient to train than recurrent systems primarily because their computations are more
    _____
    .
    Hint

    They do not require walking through the sequence one recurrent step at a time.

    Answer

    parallelizable

  58. 58
    Transformers achieved strong early results in
    _____
    translation while training significantly more efficiently than recurrent systems.
    Hint

    This was the main application used to motivate attention in the lecture.

    Answer

    machine

  59. 59
    The parallelizability of Transformers made it possible to train on much more
    _____
    using faster GPUs.
    Hint

    The advantage concerned the amount of training material and available computation.

    Answer

    data

  60. 60
    Transformers helped enable the modern revolution in large-scale
    _____
    .
    Hint

    The lecture connected their scalability to training models before adapting them to tasks.

    Answer

    pre-training

  61. 61
    As datasets and computational resources grew, Transformers generally surpassed LSTMs across many modern NLP
    _____
    .
    Hint

    The comparison concerned progress and state-of-the-art systems in natural language processing.

    Answer

    advancements

  62. 62
    The principal computational drawback of standard self-attention is its
    _____
    dependence on sequence length.
    Hint

    Every position interacts with every other position.

    Answer

    quadratic

  63. 63
    Because of quadratic attention cost, processing an entire novel or Wikipedia page in one sequence can become
    _____
    .
    Hint

    The issue is that the required memory and computation become too large.

    Answer

    infeasible

  64. 64
    Research on replacing the quadratic attention operation with lower-cost alternatives remains an
    _____
    area of research.
    Hint

    The lecture described the question as unresolved rather than settled.

    Answer

    open

1 of 64
Question 1 of 64

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent