Decode the acronym MHA in the transformer attention context.
MHA stands for Multi-Head Attention, the Vaswani 2017 baseline where h independent (Q, K, V) heads run in parallel inside one attention layer.
Picture a panel of expert reviewers reading the same document. Each reviewer has a different angle: one tracks grammar, one tracks logic, one tracks tone, one tracks references. They all read the same text at the same time, write their notes independently, and the editor then merges the notes into a final report. MHA is that panel inside one step of a transformer. Several reviewers (called heads) work on the same sentence at the same time, each with their own private set of reading glasses, each picking up on a different kind of relationship between words. At the end, their notes are stitched together and combined into one summary the model uses to keep thinking.
Detailed answer & concept explanation~5 min readEverything 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. 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.
3m: what MHA stands for, the parallel-head mechanism, why parameters are unchanged vs single-head, parallel specialization across heads, and the relationship to MQA, GQA, MLA.
Real products, models, and research that use this idea.
- The original Transformer in Vaswani et al. 2017 used MHA with h=8 heads at d_model=512.
- BERT-base used MHA with h=12 heads at d_model=768; BERT-large used h=16 at d_model=1024.
- GPT-2 and GPT-3 used MHA throughout, before the field shifted to GQA in larger production decoders.
- Llama 4 Maverick and Mistral Large 3 use GQA, the production successor to MHA that keeps multi-head queries but shares K and V.
- DeepSeek V4 uses MLA, another MHA descendant that compresses K and V into a low rank latent while preserving multi-head queries.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does the output projection W_O matter rather than just concatenating heads?
QIf MHA has the same parameter count as single-head, why is the multi-head version empirically better?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Reading MHA as 'masked head attention' or thinking the h heads increase parameter count. Heads partition the existing d_model budget; the M stands for Multi, not Masked.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.