True or false: switching from 1-head to 12-head attention at the same d_model increases total parameter count.
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
False. Multi-head is reshape, not parameter add. The Q/K/V matrices stay d_model × d_model: just sliced into num_heads × d_head blocks.
Think of a shelf with a fixed total width holding books. One head is one giant book covering the whole shelf. Twelve heads is the same shelf width split into twelve narrower book slots side by side. The wood you used to build the shelf, the total parameters, is exactly the same. You only changed how the shelf is divided. Same lumber, different compartments, twelve mini-readers instead of one big one.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Walk through the reshape mechanics, confirm parameter and FLOP equivalence, contrast with GQA/MQA which DO save K/V parameters, and explain why the structural difference (parallel attention patterns) is the real reason multi-head exists.
| Configuration | d_model | num_heads | d_head | Total params (Q+K+V+O) |
|---|---|---|---|---|
| single head | 768 | 1 | 768 | 4 × 768² |
| multi-head (12) | 768 | 12 | 64 | 4 × 768² |
| multi-head (8) | 768 | 8 | 96 | 4 × 768² |
| bigger model | 1024 | 12 | 85.3 (invalid) | 4 × 1024² |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Assuming each head 'has its own' projection matrices that get added on top, they're slices of the same matrix, not additions.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.