Attention / Core
verifiedMulti-Head Attention
One attention pass has to settle on a single set of weights, so it averages away anything it cannot decide between. Multi-head attention runs several passes side by side, each with its own projections, so one head can follow grammatical agreement while another tracks the subject of the sentence. The results are concatenated and mixed.
Split d sub model into h heads of dimension d sub k = d sub model /h, run attention in each, concatenate, and project back with W sub O . Total parameter count is unchanged from a single head of full width, so heads buy diversity rather than capacity. Empirically many heads are prunable after training, which suggests the gain is in optimisation as much as expressiveness.
MultiHead(X) = Concat(head sub 1 ,…,head sub h )W sub O where head sub i = Attention(XW sub Q super i , XW sub K super i , XW sub V super i ) and W sub O ∈ ℝ super h·d sub v ×d sub model . With d sub k = d sub v = d sub model /h the total cost matches single-head attention at full width, since the h smaller matmuls sum to the same work.
8 queries against 8 keys; a brighter cell means more of that query's attention went to that key. Nothing is masked: every position can read every other, itself included.
One head's attention pattern at a time. Drag the head count to see the same budget split into more, narrower views — each sharper than the single head that had the whole width to itself.
Reviewed by opendroid · 2026-08-04
- arXiv:1706.03762 — Attention Is All You Need
- arXiv:1905.10650 — Are Sixteen Heads Really Better than One?