Answers · How models work
What do multiple attention heads actually give you that one big head doesn't?
In shortSeveral heads let a model track several relationships at once, each in its own lower-dimensional subspace, instead of squeezing every relationship into one weighted average that destroys information.
Multiple heads let the model keep several different weighted averages at once, each in its own low-dimensional subspace, instead of forcing one average to carry every relationship. A single head produces one mixture per token, and a mixture destroys information: once two value vectors are blended, nothing downstream can separate them again.
One average cannot hold two answers
Take a sentence where one token needs two different things at once: 'The researcher who wrote the paper said it was wrong.' For the token 'said', a useful representation depends on its subject 'researcher' (four tokens back, across a relative clause) and on its complement clause beginning at 'it'. These are different questions with different answers. One head must answer both with one set of weights summing to one. If it puts 0.45 on 'researcher', 0.40 on the complement, and 0.15 elsewhere, the output is 0.45 v_researcher + 0.40 v_complement + 0.15 v_other, a blend of two unrelated vectors. Nothing downstream can undo that blend. Two heads do not split weight: head A puts 0.95 on 'researcher', head B puts 0.90 on the complement, and both vectors survive into the output because they occupy different coordinates.
The construction
Run heads in parallel. Each head has its own projections , , and , so each computes its own scores and its own weighted average. The outputs, each of width , are concatenated and multiplied by one output matrix .
Why this costs nothing
The obvious objection is that eight heads should cost eight times as much. They do not, because head width shrinks as head count grows: . The attention cost per head has two parts. The score matrix is and each entry is a dot product over terms, giving . The weighted sum of values is the same order. Multiply by heads: . The head count cancels. Eight heads of width 64 cost , exactly what one head of width 512 costs.
| Configuration | Heads | Width each | Total cost |
|---|---|---|---|
| Single wide head | 1 | 512 | |
| Original transformer | 8 | 64 | |
| Many narrow heads | 32 | 16 |
What the output projection is for
Concatenation alone would put head one in coordinates 1 through 64, head two in 65 through 128, and so on. Each head would write into a fixed, private slice, and nothing downstream could receive contributions from two heads in the same coordinate. is a full matrix mapping the concatenated vector back to model width. Each head's output can be written into any direction. Two heads can add into the same direction; one head's output can be spread across many. This is the mechanism by which a head in one layer can write something that a head in a later layer reads.
The natural guess is that heads are just the same attention run several times for redundancy. That fails because each head has its own projections , , . Each head computes a different similarity matrix and a different weighted average in a subspace of dimension . They are not copies; they are different questions asked of the same sequence. The redundancy that does exist is a by-product of training, not the design.
It stops being true that every head does something useful. Probing trained models finds that a minority of heads have clean, describable jobs, such as attending to the previous token or tracking a syntactic dependency, and a substantial fraction can be removed with little effect on the output. Head count is chosen with slack, not tuned to a minimum. Also, narrower heads mean simpler individual similarity functions: the learned matrix has rank at most , so splitting into more heads trades expressiveness per head for coverage across heads.
Worth keeping
- A single attention head produces one weighted average per token, and averaging is irreversible, so any relationship not weighted highly is lost.
- Splitting the model width into h heads of width d_model/h costs the same as one wide head, because the per-head cost falls in proportion to the head count.
- The output projection lets head outputs mix into any direction, so heads are not locked into fixed, disjoint slices of the representation.
Where this goes next
This question is one step of The Mathematics of Attention, a course that works through its subject from the beginning. The page that teaches this part of it is Multiple Heads, and it reads the whole way through whether or not you have an account.
What an account changes is the practice: problems standing under every idea, marked with a reason rather than a tick, in a copy of the course that is yours.
Read that pageThe whole courseOther questions people ask about this
- Why do we divide the attention scores by the square root of the key dimension?The square root of the key dimension is the typical size of an unscaled attention score, so dividing by it stops softmax from becoming a hard pick-one.
- Why does attention use softmax instead of just dividing each score by the sum of all the scores?Dividing by the sum can give negative weights and fails when scores cancel; exponentiating first makes weights positive and turns score gaps into ratios.
- How does masking actually make attention causal?The mask is applied to the scores before they become weights, so forbidden positions end up with exactly zero weight and the rest are renormalised automatically.
- Why does attention need positional encoding if it already looks at the whole sequence at once?Attention treats tokens as an unordered set, so position has to be added to the vectors; otherwise a sentence and its anagram get the same representations.
- Why does the model get stuck repeating the same sentence over and over?The model is not stuck in a memory loop: once it has written a phrase, that phrase is in its context and makes writing it again more likely, so a decoder that always picks the top word cannot leave.
- Why does diffusion add Gaussian noise instead of any random corruption?Diffusion adds Gaussian noise because Gaussian errors combine exactly: each step keeps the spread fixed and gives a closed-form noisy picture at any later step, which makes the reverse step learnable.