A single attention layer computes one set of weights over the sequence.
That forces every kind of relationship to share one blend.
Grammatical agreement, coreference and topical relevance would all have to average together.
Multi-head attention runs several attention operations side by side instead.
Each head has its own query, key and value projections, so each looks for something different.
The model dimension is split across the heads rather than multiplied.
With 512 dimensions and eight heads, each head works in 64.
So the total cost is about the same as one full-width head.
Their outputs are concatenated and passed through a final linear layer that mixes them.
Studies of trained models find heads with recognisable specialities.
Some track the previous token, some link verbs to subjects, some resolve pronouns.
Many heads appear to do very little and can be pruned with small loss.
The specialisation is not designed, since nothing tells a head what to become.
Eight to sixteen heads is typical in a mid-sized model, and large models use more.
Grouped-query attention lets heads share keys and values to shrink the cache during inference.