Multi-Head Attention › Summary

Michael BrenndoerferUpdated May 30, 20252 min read
Language AI HandbookAll chapters
Part 13 of 67Self-Attention
Chapter 94Multi-Head Attention › Summary
Reading section 13 of 14 · Summary · 2 minSection 13 of 14 · 2 min

Book contents

Section 13 of 14 · 2 min read

Multi-Head Attention › SummaryOne section · Sections in this chapter13 / 14 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Multi-head attention extends single-head attention by running multiple attention operations in parallel, each with its own learned projections. This architectural choice significantly impacts model capacity and performance.

Key takeaways from this chapter:

  • Parallel heads: Multi-head attention computes hh independent attention operations, each learning different relationship patterns between tokens. Each head can specialize in detecting specific linguistic phenomena.
  • Dimension splitting: The model dimension dmodeld_{\text{model}} is divided among heads, with each head operating on dimension dk=dmodel/hd_k = d_{\text{model}} / h. This keeps total computation comparable to single-head attention while enabling multiple perspectives.
  • Four-step process: (1) Project input to Q, K, V for each head using learned matrices WiQ\mathbf{W}^Q_i, WiK\mathbf{W}^K_i, WiV\mathbf{W}^V_i; (2) compute scaled dot-product attention independently per head; (3) concatenate head outputs; (4) apply final output projection WO\mathbf{W}^O.
  • Head specialization: Different heads learn to focus on different aspects: positional patterns, syntactic relationships, semantic similarity, or coreference links. This emerges from training without explicit supervision.
  • Parameter efficiency: The total parameter count is 4×dmodel24 \times d_{\text{model}}^2, similar to single-head attention with an output projection. The gain is in representational diversity, not parameter count.
  • Practical implementations: Efficient implementations batch all heads into single tensor operations, using GPU parallelism through combined QKV projections.

In the next chapter, we'll examine the computational complexity of attention in detail. Understanding the O(n2)O(n^2) scaling (where nn is sequence length) and its implications is essential for working with long sequences and motivates the efficient attention variants used in modern long-context models.