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

  • 30Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Transformers Overview
  • spaceFlip card
  • KI knew it
  • DI didn't know it
  • ←Previous card
  • →Next card

What is the main goal of the transformer model described in the content?

Tap to flipClick to flipspace

To take in a piece of text and predict what word comes next.

Or swipe the card

30 cards

  1. What is the main goal of the transformer model described in the content?

    To take in a piece of text and predict what word comes next.

  2. What are tokens in the context of transformers?

    Pieces of text (often words or subwords) that the input is broken into.

  3. What is an embedding in a transformer?

    A high-dimensional vector associated with each token, representing its meaning and position.

  4. How do directions in the embedding space correspond to meaning?

    Directions can correspond to semantic features like gender; adding a certain vector can transform a masculine embedding to a feminine one.

  5. Why is the initial embedding for the same word the same regardless of context?

    Because the initial token embedding is a lookup table with no reference to context.

  6. What information do the entries of the initial embedding vector encode?

    Both what the word is and its position in the context.

  7. What are the three matrices that parameterize a single head of attention?

    Query matrix (WqW_qWq​), key matrix (WkW_kWk​), and value matrix (WvW_vWv​).

  8. What is the purpose of the query vector in attention?

    To encode a question from one token (e.g., 'Are there adjectives in front of me?').

  9. What is the purpose of the key vector in attention?

    To potentially answer queries (e.g., 'I am an adjective in that position').

  10. What is the purpose of the value vector in attention?

    To specify what should be added to the embedding of another token if it is relevant.

  11. How are queries and keys typically dimensioned relative to embeddings?

    Queries and keys have a much smaller dimension than embeddings (e.g., 128 vs. 12288).

  12. How is the relevance between two tokens measured in attention?

    By the dot product between the query of one token and the key of another.

  13. Why is the dot product divided by the square root of the key-query dimension?

    For numerical stability, to prevent extremely large values that could cause softmax issues.

  14. What is the attention pattern (or attention matrix)?

    A grid of normalized weights (0 to 1, columns sum to 1) indicating how much each token attends to others.

  15. How is the attention pattern computed mathematically in the original transformer paper?

    ight)V$$
  16. What is masking in attention, and why is it used?

    Masking prevents later tokens from influencing earlier ones by setting their attention scores to −infty-infty−infty before softmax.

  17. How does the size of the attention pattern scale with context size?

    It scales as the square of the context size (L2L^2L2).

  18. What is the effect of masking on the attention weights for later tokens attending to earlier ones?

    Those weights become zero after softmax (since −infty-infty−infty becomes 0).

  19. How does a single attention head update the embedding of a token?

    It computes a weighted sum of value vectors (using attention weights), then adds that sum to the original embedding.

  20. What is multi-headed attention?

    Running many attention heads in parallel, each with its own key, query, and value matrices.

  21. How many attention heads does GPT-3 use in each block?

    96 heads.

  22. How are the outputs of multiple attention heads combined?

    The proposed changes from all heads are summed together and added to the original embedding.

  23. What is the output matrix in multi-headed attention?

    A single large matrix that combines the value up projections from all heads.

  24. What are the dimensions of the query and key matrices in GPT-3?

    12,288 columns (embedding dim) and 128 rows (key-query dim).

  25. How is the value matrix factorized in practice for efficiency?

    It is broken into a value down matrix (embedding to small space) and a value up matrix (small space back to embedding).

  26. What is the total number of parameters for one attention head in GPT-3 (including key, query, and value maps)?

    About 6.3 million parameters (4 matrices imes imesimes 1.572 million each).

  27. How many parameters are in a full multi-headed attention block with 96 heads?

    Around 600 million parameters.

  28. How many layers does GPT-3 have, and what is the total attention parameter count?

    96 layers; total attention parameters is just under 58 billion.

  29. What is cross-attention and how does it differ from self-attention?

    Cross-attention uses keys from one data set and queries from another (e.g., different languages), and typically has no masking.

  30. Why is the attention mechanism highly parallelizable?

    Because the computations for all tokens can be done simultaneously using matrix operations on GPUs.

Card 1 of 30
Card 1 of 30

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent