Attention, with the maths
"The trophy didn't fit in the suitcase because it was too big." You know "it" is the trophy. Lesson 1.3 said attention lets a token look back at the others. Here is exactly how: three small matrix multiplies, a softmax, and one weighted average.
In this lesson you'll learn to
- Explain queries, keys and values, and how each token's three vectors are made.
- Work through scaled dot-product attention, softmax(QKᵀ/√d)V, including the causal mask and why it costs n².
- Explain multi-head attention, and how grouped-query and latent attention shrink the KV cache.
- Explain why attention needs positional information, and how RoPE provides it.
Create a free account to open this lesson
It's free. You'll get every free lesson, quizzes that save your progress, daily flashcards and streaks.