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:

Modeldff / dFFN share of a block
SmolLM3 3B2,04811,0085.3886.6%
Llama 2 7B4,09611,0082.6966.8%
Granite 3.3 8B4,09612,8003.1378.9%
Falcon3 10B3,07223,0407.5089.4%
Phi-45,12017,9203.5080.8%
Qwen3.5 27B5,12017,4083.4069.8%
Gemma 3 27B5,37621,5044.0084.0%
Gemma 2 27B4,60836,8648.0090.0%
Gemma 4 31B5,37621,5044.0072.4%
OLMo 3 32B5,12027,6485.4087.1%
OLMo 2 32B5,12027,6485.4087.1%
Qwen3 32B5,12025,6005.0080.6%
Seed-OSS 36B5,12027,6485.4078.6%
DeepSeek-R1-Distill-Llama-70B8,19228,6723.5082.4%
Qwen2.5 72B8,19229,5683.6182.8%
Devstral 2 (123B)12,28828,6722.3376.4%
Llama 3.1 405B16,38453,2483.2582.1%

Related

SwiGLU · Mixture of experts (MoE) · Transformer block · every term