W_O is the (d_model, d_model) output projection after head concat. Its job is to mix signals across heads before the residual add.
Picture eight reporters who each cover a different beat at a city paper, sports, weather, politics, food. Each writes one column independently. Without an editor, the front page would just be eight separate columns sitting side by side, with no story that crosses beats. W_O is the editor who reads all eight columns and weaves them into one front page, where the sports story can pull in a quote from the politics column and the food story can reference the weather. The shape of the front page is the same with or without the editor, but the story is much richer when the editor gets to mix the contributions.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
The output projection W_O sits at the end of every multi-head attention sub-layer in every modern transformer. Its shape (d_model, d_model) does not change the dimensionality of the data flowing through, which makes it tempting to dismiss as 'plumbing'. The dismissal is wrong: W_O is the only place where the per-head outputs of multi-head attention can mix with each other, and it is the substrate that makes multi-head behave as more than h independent attention computations stacked side by side.
This deep dive walks the slice structure that motivates W_O, explains the per-head decomposition view that makes the mixing concrete, surveys the empirical evidence from interpretability research, and closes with how W_O fits into the broader residual-stream picture.
Mental model: W_O is the editor that turns h independent reporters into one coherent front page.
Where W_O sits in the attention sub-layer
The full multi-head attention sub-layer is a sequence of operations:
- Project the input
xinto Q, K, V viaW_Q,W_K,W_V. - Split Q, K, V into
hheads, each of widthd_head = d_model / h. - Compute scaled dot-product attention per head:
head_i = softmax(Q_i K_i^T / sqrt(d_head)) V_i. - Concatenate the h head outputs along the last axis to recover a
d_model-wide vector. - Apply W_O:
out = W_O @ concat(head_0, ..., head_{h-1}). - Add to the residual stream.
W_O sits at step 5, between the concat and the residual add. Its shape (d_model, d_model) matches the concatenated output's d_model width on both sides.
What the concat does
The concat is a memory rearrangement, not an arithmetic operation. It takes h separate d_head-wide context vectors and arranges them contiguously into one d_model-wide vector. Head 0's output occupies indices [0, d_head), head 1 occupies [d_head, 2*d_head), and so on.
No information flows across heads during the concat. Each head's output sits in its own slot, untouched.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- Every production decoder-only transformer (Llama 4 Maverick, GPT-5.5, Claude Opus 4.7, Gemini 3.1 Pro, Qwen 3.5) keeps W_O at full d_model x d_model rank.
- Anthropic's transformer-circuits framework decomposes W_O into per-head write matrices for mechanistic-interpretability analysis.
What an interviewer would ask next. Try answering before peeking at the approach.
QIf W_O is so important, why does removing the bias term on W_O usually not matter?
The bias on W_O adds a constant shift to the residual stream, which downstream layer normalization can absorb. The matrix W itself is what does the mixing; the bias term is a free parameter the model can mostly replicate via the LayerNorm gain and bias.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Calling W_O a 'shape-preservation' bookkeeping step and missing that it is the only place where heads can mix with each other before the residual add.
60 second bullets to scan on the way to the call.
Shape and position of W_O in the multi-head attention sub-layer
Why W_O is needed despite the input and output dimensions matching
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.