Three tokens have embeddings , and . Take (no projection matrices) and . What are the attention weights and output for token 1 using scaled dot-product attention?
Sequence models and transformers, Attention
Level L2 Elementary. Length Medium. Nature Mat Mathematical.
What's being asked
Whether you can run the three steps of self-attention (scores, softmax, weighted sum) with actual numbers.
Key idea
with .
Steps
- Dot products with : , , .
- Scale by : scores .
- Exponentiate: , , . The sum is .
- Weights , which add to .
- Output .
- Token 1 attends most to itself and to the similar token 3, and least to the orthogonal token 2.
Common mistakes
- Forgetting to divide by .
- Taking the softmax over the wrong axis (over queries instead of keys).
- Using the scores as weights without the softmax, so the weights do not sum to .
How long your answer should be
Half a page with the numbers shown.
Last checked on 4 December 2026.
Read this
Previous in Sequence models and transformers: Reference: "the cat is on the mat" (6 words). Candidate 1: "the the the the the the the". Candidate 2: "the cat mat". (a) What is the clipped unigram precision of Candidate 1? (b) For Candidate 2, what are the unigram precision and the brevity penalty, so what is its unigram-only BLEU?
Next in Sequence models and transformers: A language model gives logits for four tokens. What are the sampling probabilities at temperature , and ? What happens as and as ?