Which sublayer of a dense transformer block carries more parameters, attention or FFN?
In a standard dense transformer block, the FFN holds roughly two-thirds of the parameters and attention holds one-third.
Picture a transformer block as a workshop with two big machines. One machine, attention, takes every word's data and lets it talk to every other word. The other machine, the FFN, takes each word one at a time and reshapes it in a much wider workspace before squeezing it back to size. Now count the wires (the parameters). Attention has four boxes, each the same size as the input. The FFN has two boxes, but each one is four times wider than the input. So the FFN's two big boxes have more wires than attention's four small boxes. About two-thirds of the workshop's wiring lives in the FFN. The diagrams in papers always show attention as the headline feature, but the parameters live mostly in the FFN.
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.
3 min: do the arithmetic, name the 2/3 rule, explain why it surprises people, mention how GQA and MoE shift the ratio further toward FFN dominance.
| Sublayer | Matrices | Parameter count (d_model = 4096, 4x FFN) | Share of block |
|---|---|---|---|
| Attention Q, K, V, O | 4 matrices, each d_model x d_model | 67.1M | ~1/3 |
| FFN up, down (ReLU) | 2 matrices, d_model -> 4d_model and back | 134.2M | ~2/3 |
| FFN gate, up, down (SwiGLU at 8/3 ratio) | 3 matrices, d_model x 2.67*d_model | ~134.2M | ~2/3 |
| Block total | (all of the above) | ~201M | 100% |
Real products, models, and research that use this idea.
- Llama 3 8B (d_model = 4096, d_ff = 14336): one block has ~67M attention params (GQA reduces this) and ~176M FFN params (SwiGLU, three matrices). FFN dominates.
- GPT-2 small (d_model = 768, d_ff = 3072): one block has 2.36M attention params and 4.72M FFN params. Exact 2:1 ratio.
- Mistral 7B (d_model = 4096, d_ff = 14336, GQA with 8 KV heads): FFN holds ~80% of block parameters once GQA is factored in.
- Mixtral 8x7B: dense attention plus 8 SwiGLU experts. Each block's FFN experts hold roughly 1.4B parameters together, dwarfing attention's ~30M.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy does the FFN's parameter dominance not translate into FFN dominance of inference latency at long context?
QHow does GQA change the parameter ratio between attention and FFN?
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.
Believing attention dominates the parameter count because it dominates the diagrams. Attention dominates the *FLOPs* at long context, but the *parameters* live mostly in the FFN.
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.