Glossary · Feed-forward and experts

SwiGLU

Also: GLUGeGLUgated linear unitgate_projup_projdown_projSiLU

Read it at the depth you need: one sentence · a paragraph · the math · in the models here

1In one sentence

The gated feed-forward layer most LLMs use: one projection, passed through SiLU, multiplies another elementwise before the down projection.

2In a paragraph

A SwiGLU FFN computes two projections of the input instead of one. One goes through the SiLU (swish) activation and acts as a gate; the other is the value; they are multiplied elementwise, then projected back down. The gate lets the layer switch features on and off smoothly, and in practice it trains to better quality than a plain ReLU or GELU MLP of the same size. GeGLU is the same with GELU as the gate (Gemma).

3The math, shapes and parameters

FFN(x) = Wdown · ( SiLU(Wgate x) ⊙ Wup x ),    SiLU(z) = z · σ(z)

Wgate and Wup are [f, d], Wdown is [d, f]: 3 × d × f parameters, one more matrix than a plain MLP. To keep the count of a 4d MLP the hidden size is cut to f = ⅔ × 4d = 8d/3, then rounded to a multiple of 256 or so: Llama 2 7B has d = 4,096 and f = 11,008. Phi-3 stores gate and up as one fused gate_up_proj [2f, d]; the count is the same.

Term by term on Notation Decoder, the sister site: SiLU (swish) · The ⊙ (Hadamard) product · GELU

4In the 96 models on this site

Every model here uses a gated FFN: SwiGLU in 83 (Llama 2, Llama 3, Llama 4, Qwen2.5, Qwen3, Mistral, Phi, DeepSeek, DeepSeek-R1 distills, gpt-oss, SmolLM, OLMo 2, Granite, Falcon3, Inkling, Kimi, GLM-4.5, MiniMax, OLMo 3, Seed-OSS, Ling, Qwen3-Next, Qwen3.5, GLM-5); GeGLU in 10 (Gemma 2, Gemma 3, Gemma 4); squared-ReLU MLP in 3 (Nemotron 3).

Introduced in Shazeer, “GLU Variants Improve Transformer” (2020).

Related

Feed-forward network (FFN) · Mixture of experts (MoE) · every term