Rehearsing the Explanation
You already know the mechanics. This lesson is about compression and delivery: turning what you know into five minutes of speech and one static whiteboard, then holding up under questions.
Two rules for the whole exercise:
- One example sentence, carried all the way through. Never introduce a second one. Every abstraction you mention must point back to the same nine words.
- The board is a destination, not a slideshow. By minute five the board should contain one finished picture your colleague can photograph. Don't erase.
The board layout
Draw this skeleton first, in about 20 seconds, before you say anything mathematical. Fill in the numbers as you talk.
The animal crossed the street because IT was tired
| | ^
| | |
┌─────────────┴─────────────────┴──────────────────┘
│
│ token → x → ┌ q = x W_Q ┐
│ │ k = x W_K │ (3 learned projections)
│ └ v = x W_V ┘
│
│ score = q · k weight = softmax(score / √d)
│
│ out(IT) = Σ weight_j · v_j
│
└─ [ scores table ] [ softmax weights ]
Leave the right third of the board empty. That is where multi-head and the stack of layers go at minute four.
The script
Sentence: The animal crossed the street because it was tired.
0:00 – 0:40 — The problem
"To process the word it, the model has to know it refers to animal, not street. Nothing about the token
ititself tells you that — the information is somewhere else in the sentence. So we need a mechanism that lets a token pull in information from other positions. That's all attention is: a learned, differentiable way for one position to look at other positions and copy in a blend of what it finds."
Circle IT and animal on the board. Draw the arrow.
0:40 – 1:30 — Three vectors per token
"Every token starts as a vector — say 4 numbers here, 768 or 4096 in a real model. From that one vector we make three, by multiplying by three learned matrices:
- query — what am I looking for?
- key — what do I advertise about myself?
- value — what do I actually hand over if you pick me?
Same input vector, three different learned projections. Think of a room of people: your query is the question you're shouting, your key is the name tag on your chest, your value is the thing you say if someone walks over."
Write , , . Say the word learned out loud — it is the thing people forget.
1:30 – 3:00 — The worked numbers
Now pretend the four dimensions mean something. Say explicitly: "I'm making these numbers up so the arithmetic fits on a board; the real ones aren't interpretable like this."
Label the axes [animate, subject-ish, place, action].
Dot products (do this arithmetic out loud, slowly — it is the single most convincing moment of the talk):
"The dot product is just an alignment score — big when two vectors point the same way. Now divide by , because with big these sums grow and shove the softmax into a corner where gradients vanish."
Softmax:
"Softmax turns scores into a probability distribution over positions — everything positive, summing to one. It's soft: not 'fetch record #2' but 'fetch 84% of that one and a bit of the others.' That softness is why the whole thing is differentiable and why we can train it."
Finally the values. Let , , on axes [animate-thing, place]:
"The vector sitting at position it after this layer is now 84% 'animal-like'. The pronoun has absorbed its referent. That's one attention head, one layer."
3:00 – 3:40 — All at once
"Every token does this simultaneously — each one is a query against every key. Stack the queries into a matrix , keys into , values into , and the whole layer is one line:"
" is the table of every-token-against-every-token. Softmax runs along each row. In a language model that generates text we mask the upper triangle to before the softmax, so position can't see the future — otherwise predicting the next word is cheating."
3:40 – 5:00 — Heads, blocks, stack
Use the empty right third now.
"One problem: that whole layer is one weighted average, so it can only chase one kind of relationship at a time. Fix: run copies in parallel with different — heads — each at a smaller dimension, then concatenate and project back. One head can track coreference, another can just look at the previous word.
Wrap that with a residual connection and a per-token MLP, and you have a transformer block. GPT-style models are that block stacked 12 to 100+ times, with position information added at the bottom since attention itself is order-blind — a permuted sentence gives permuted outputs. Final vector at the last position → linear layer → softmax over the vocabulary → next token."
Stop. Five minutes.
Deliberately cut
Say these only if asked: layer norm placement, the exact positional scheme (RoPE/ALiBi/learned), why exists, cross-attention in encoder–decoder models, dropout, the 4× MLP width. If pressed on something you've cut: "That's an implementation detail that doesn't change the picture — happy to go into it after."
The three follow-ups
"Why did this replace RNNs?"
Ten-second answer: Parallel training and a constant-length path between any two tokens.
The real answer: An RNN's hidden state at step requires step , so a length- sequence is sequential steps — you can't saturate a GPU no matter how much data you have. Attention computes all positions at once during training; it's a couple of big matmuls. Second, in an RNN, information from token 1 reaching token 100 passes through 99 multiplications, which is where the classic vanishing/exploding gradient trouble comes from. In attention, every pair is one dot product apart — path length instead of .
If they push: "Wasn't the win just scale?" — Largely yes, and that's the point: the architecture is the one that lets you spend the compute. And note RNNs aren't dead: state-space models (Mamba, etc.) are a modern recurrent family designed to be trainable in parallel, motivated exactly by attention's quadratic cost. Also be honest that generation is still sequential in a transformer — one token at a time, which is why KV caching exists.
"What do the individual heads learn?"
Ten-second answer: Nobody assigns them; specialization emerges. Some are cleanly interpretable, many aren't.
The real answer: Interpretability work has found reliably recurring types — previous-token heads that attend one position back, positional/local heads, syntactic heads that link verbs to their subjects, and induction heads: a two-head circuit implementing "last time I saw A, it was followed by B, so predict B." That circuit is a big part of in-context learning. In the well-studied indirect-object task, specific "name mover" heads move the name from earlier in the sentence to the final position — which is essentially my it → animal cartoon, but discovered rather than designed.
The caveat to volunteer yourself (it makes you credible): most heads are messy and polysemantic, many are redundant and can be pruned, and a high attention weight is not proof of causal importance — "attention is not explanation" is a real literature. Attention weights are a hypothesis to test with ablations, not an explanation.
"Why is it quadratic in sequence length?"
Ten-second answer: queries times keys.
The real answer: has entries and each costs multiply-adds, so attention is FLOPs and — naively — memory per head for the score matrix. At that's a million scores per head per layer; at it's ten billion. Doubling context quadruples the attention work.
The nuance that gets you respect: attention is not always the bottleneck. Per layer, attention is roughly while the MLP is roughly , so attention only dominates once approaches — for a 4096-dim model at 512 tokens, the MLPs cost more. It's long contexts that hurt. Also, the memory is avoidable: FlashAttention tiles the computation so the full matrix is never materialized (same FLOPs, far less HBM traffic). The FLOPs are attacked separately by sliding-window/local attention, sparse patterns, linear-attention approximations, and non-attention sequence models. And at inference, the KV cache grows linearly with context — each new token attends to all previous ones, so generating tokens is again total.
Phrases that will get you in trouble
| Don't say | Say instead | |---|---| | "Q, K, V are three different embeddings" | "Three learned projections of the same vector" | | "Softmax picks the most relevant token" | "Softmax produces a weighted blend, usually peaked" | | "We divide by to normalize" | "To keep the scores' variance stable so softmax doesn't saturate" | | "Attention shows you what the model is thinking" | "Attention shows where information could flow; proving it matters takes ablation" | | "Transformers have no recurrence, so they're order-invariant" (and stopping there) | "...which is why positional information is injected explicitly" |
Try it yourself
Set a phone timer for five minutes and record audio while you talk at a real wall or a sheet of paper. Then check three things:
- Did you finish? If you ran past 5:00, you almost certainly over-explained . Cut minute two to 40 seconds.
- Did you say the numbers out loud? Play back the 8 / 4 / 2 → 4 / 2 / 1 → 0.84 / 0.11 / 0.04 segment. If you mumbled it or wrote it silently, redo it — this is the part that converts.
- Cold-open a follow-up. Without re-reading this page, speak a 30-second answer to "why does it scale quadratically?" Then compare against the section above and note exactly which fact you dropped.
Then do the hardest version: give it to someone who will actually interrupt, and write down the one question you couldn't answer. That question is your next lesson.