Glossary · Feed-forward and experts
Feed-forward network (FFN)
Also: MLPfeed-forwardintermediate_size
Read it at the depth you need: one sentence · a paragraph · the math · in the models here
1In one sentence
The per-token MLP in every block: widen the vector from d to f, apply a nonlinearity, project back to d. It holds most of a dense model's parameters.
2In a paragraph
After attention has mixed information between tokens, the feed-forward network processes each token on its own: it expands the vector to a wider hidden size (intermediate_size, usually 3 to 4 times d), applies a nonlinearity, and projects it back. Much of what a model "knows" is thought to be stored here. In current models the FFN is gated (SwiGLU), and in a mixture of experts it is replaced by many smaller FFNs.
3The math, shapes and parameters
The original transformer's FFN has two matrices:
FFN(x) = W2 · ReLU(W1x) W1: [f, d], W2: [d, f], f = 4d → 8d² parameters
A gated FFN has three: 3 × d × f. Per block it is about two thirds of the parameters (with f ≈ 2.7d and GQA attention, even more).
Term by term on Notation Decoder, the sister site: FFN · GELU
4In the 96 models on this site
The FFN's width against the model's, and its share of each block, for the largest dense model of each series:
| Model | d | f | f / d | FFN share of a block |
|---|---|---|---|---|
| SmolLM3 3B | 2,048 | 11,008 | 5.38 | 86.6% |
| Llama 2 7B | 4,096 | 11,008 | 2.69 | 66.8% |
| Granite 3.3 8B | 4,096 | 12,800 | 3.13 | 78.9% |
| Falcon3 10B | 3,072 | 23,040 | 7.50 | 89.4% |
| Phi-4 | 5,120 | 17,920 | 3.50 | 80.8% |
| Qwen3.5 27B | 5,120 | 17,408 | 3.40 | 69.8% |
| Gemma 3 27B | 5,376 | 21,504 | 4.00 | 84.0% |
| Gemma 2 27B | 4,608 | 36,864 | 8.00 | 90.0% |
| Gemma 4 31B | 5,376 | 21,504 | 4.00 | 72.4% |
| OLMo 3 32B | 5,120 | 27,648 | 5.40 | 87.1% |
| OLMo 2 32B | 5,120 | 27,648 | 5.40 | 87.1% |
| Qwen3 32B | 5,120 | 25,600 | 5.00 | 80.6% |
| Seed-OSS 36B | 5,120 | 27,648 | 5.40 | 78.6% |
| DeepSeek-R1-Distill-Llama-70B | 8,192 | 28,672 | 3.50 | 82.4% |
| Qwen2.5 72B | 8,192 | 29,568 | 3.61 | 82.8% |
| Devstral 2 (123B) | 12,288 | 28,672 | 2.33 | 76.4% |
| Llama 3.1 405B | 16,384 | 53,248 | 3.25 | 82.1% |
Related
SwiGLU · Mixture of experts (MoE) · Transformer block · every term