Feed-forward block and gated FFN
What it is
The per-token MLP that holds most parameters, usually widened 4x and gated in modern models.
When to use it
Capacity vs compute decisions, and the layer MoE replaces with an expert bank.
Caveats
The feed-forward layers hold roughly two thirds of a transformer's parameters, so they dominate model size. Gated variants such as SwiGLU add a third weight matrix, so the hidden width is reduced to keep the parameter count equal.
Key ideas
- A two-layer MLP applied to each token position independently
- Expands to a wider hidden size (typically about 4x) and projects back
- Gated versions (SwiGLU, GeGLU) multiply two projections together
Related architectures
Original paper
GLU Variants Improve Transformer (2020, arXiv)