1. Home
  2. Explore
  3. Computer Science
  4. Transformer Attention Mechanism

Study methods

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

Transformer Attention Mechanism

  • 23Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Attention Fundamentals
The attention mechanism was introduced in the 2017 paper titled
.

23 questions

  1. 1
    The attention mechanism was introduced in the 2017 paper titled
    _____
    .
    Hint

    This paper's title summarizes the core idea that attention alone is sufficient for sequence modeling.

    Answer

    Attention is All You Need

  2. 2
    In a transformer, the input text is broken into pieces called
    _____
    .
    Hint

    These are commonly words or subwords that serve as the basic units of input.

    Answer

    tokens

  3. 3
    Each token is initially associated with a high-dimensional vector called its
    _____
    .
    Hint

    This vector encodes the token's identity and position, but initially lacks context.

    Answer

    embedding

  4. 4
    The goal of the attention mechanism is to
    _____
    embeddings so they encode contextual meaning beyond individual words.
    Hint

    Think of updating or refining the initial representations based on surrounding words.

    Answer

    adjust

  5. 5
    In the example with the word 'mole', attention allows the surrounding embeddings to pass information into the embedding of 'mole' because the initial embedding is the
    _____
    across different contexts.
    Hint

    Initially, the embedding does not depend on context; it is uniform for the same word.

    Answer

    same

  6. 6
    The query vector for a token is computed by multiplying the token's embedding by a matrix called the
    _____
    matrix.
    Hint

    This matrix is denoted WqW_qWq​ and projects embeddings into a smaller space.

    Answer

    query

  7. 7
    The key matrix produces vectors called
    _____
    that are matched against queries to determine relevance.
    Hint

    These answer queries; they are also in the same smaller space as queries.

    Answer

    keys

  8. 8
    The relevance between a key and a query is measured by their
    _____
    .
    Hint

    This operation yields a scalar that quantifies alignment between two vectors.

    Answer

    dot product

  9. 9
    The key and query vectors have a much smaller dimension than the embedding; in the example, they have dimension
    _____
    .
    Hint

    This number is much smaller than the embedding dimension (e.g., 12,288) to save parameters.

    Answer

    128

  10. 10
    After computing all key-query dot products, a
    _____
    function is applied column-wise to normalize the values between 0 and 1.
    Hint

    This converts the scores into a probability-like distribution per column.

    Answer

    softmax

  11. 11
    To prevent later tokens from influencing earlier ones,
    _____
    is applied by setting certain entries to negative infinity before softmax.
    Hint

    This ensures the attention pattern is causal (autoregressive).

    Answer

    masking

  12. 12
    The size of the attention pattern is the
    _____
    of the context size.
    Hint

    If the context has NNN tokens, there are N2N^2N2 possible pairs.

    Answer

    square

  13. 13
    In cross-attention, the keys and queries come from
    _____
    datasets.
    Hint

    For example, one language vs. another in translation, or audio vs. text.

    Answer

    different

  14. 14
    The value matrix produces vectors that are
    _____
    to the embeddings of target tokens to update their meaning.
    Hint

    These value vectors represent the information to be transferred from one token to another.

    Answer

    added

  15. 15
    For efficiency, the value map is factored into two matrices: the value down matrix and the value
    _____
    matrix.
    Hint

    The second matrix maps from the smaller space back to the large embedding space.

    Answer

    up

  16. 16
    After computing the attention pattern, for each column we take a weighted
    _____
    of the value vectors from all tokens.
    Hint

    The weights come from the attention scores; this combined vector is added to the target embedding.

    Answer

    sum

  17. 17
    A full attention block in a transformer consists of
    _____
    attention heads run in parallel.
    Hint

    This allows the model to learn multiple distinct types of contextual relationships simultaneously.

    Answer

    multi-headed

  18. 18
    GPT-3 uses
    _____
    attention heads inside each block.
    Hint

    This number is the same as the number of layers in the full model.

    Answer

    96

  19. 19
    The proposed changes from each attention head are
    _____
    together and added to the original embedding for each position.
    Hint

    Combining all head outputs into a single update vector before addition.

    Answer

    summed

  20. 20
    For a single attention head, the key and query matrices have dimensions 128 by 12,288, each containing approximately
    _____
    million parameters.
    Hint

    Multiply 128 by 12,288 and convert to millions.

    Answer

    1.5

  21. 21
    With 96 heads, each block of multi-headed attention in GPT-3 ends up with around
    _____
    million parameters.
    Hint

    Multiply 6.3 million by 96.

    Answer

    600

  22. 22
    In GPT-3, the total number of parameters devoted to all attention heads across 96 layers is just under
    _____
    billion.
    Hint

    Multiply per-block parameters by 96 layers.

    Answer

    58

  23. 23
    One major advantage of the attention mechanism is that it is highly
    _____
    , enabling efficient use of GPUs for large-scale training.
    Hint

    This property allows many computations to happen simultaneously on modern hardware.

    Answer

    parallelizable

1 of 23
Question 1 of 23

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent