Replacing the ReLU or GELU activation inside a Transformer’s feed-forward block with a multiplicative gate (SwiGLU or GEGLU) consistently improves language model quality without adding parameters or FLOPs. In a concise 2020 paper, Noam Shazeer extends Dauphin et al.’s Gated Linear Unit (GLU) to modern activations on T5-Base, cutting held-out C4 denoising log-perplexity from 1.677 (ReLU) and 1.679 (GELU) down to 1.633 (GEGLU) and 1.636 (SwiGLU), while lifting SuperGLUE dev average from 72.76 to 74.56 (SwiGLU).

Crucially, plain ungated Swish scores 1.683 log-perplexity, the worst of all eight architectures tested. The gain comes from multiplicative interaction between two learned projections, not from swapping ReLU for a smoother curve.

  • Matched parameter and FLOP budget: gated blocks add a third matrix, so Shazeer scales hidden width d_ff by 2/3 (3072 down to 2048 at d_model = 768), keeping per-layer parameters fixed at 4.72M.
  • Every gated variant beats every ungated baseline: across 524,288 pretraining steps, all five gated blocks (GEGLU 1.633, SwiGLU 1.636, ReGLU 1.645, Bilinear 1.648, GLU 1.663) outperform ReLU (1.677), GELU (1.679), and Swish (1.683).
  • Downstream transfer: on a joint multi-task fine-tune, SwiGLU tops SuperGLUE (74.56 vs 72.76 ReLU, 72.98 GELU), ReGLU tops GLUE (84.67 vs 83.80 ReLU), and Bilinear / GEGLU / ReGLU lead SQuAD v1.1 (91.06 to 91.18 F1 vs 90.87 ReLU).
  • Pretraining dropout matters too: removing dropout during pretraining alone lifted the FFN_ReLU baseline from 71.36 (original T5) to 72.76 on SuperGLUE and 83.28 to 83.80 on GLUE.
Held-out C4 log-perplexity at 524,288 steps (lower is better)
FFN_GEGLU
1.633 (73.96)
FFN_SwiGLU
1.636 (74.56)
FFN_ReGLU
1.645 (73.66)
FFN_Bilinear
1.648 (73.81)
FFN_GLU
1.663 (73.95)
FFN_ReLU
1.677 (72.76)
FFN_GELU
1.679 (72.98)
FFN_Swish
1.683 (72.40)

Values show C4 log-perplexity (SuperGLUE dev average in parentheses). All runs match parameter and FLOP counts. Source: Shazeer (2020), Tables 1 and 3.

How the gated feed-forward block works

In the original Transformer, each position-wise feed-forward network expands a hidden vector x with one matrix W1, applies an elementwise nonlinearity, and projects back with W2 (T5 omits bias terms: max(0, xW1) W2). A gated block splits that first step into two parallel projections W and V, passes only the W branch through an activation f, multiplies the two branches coordinate by coordinate, and projects down through W2: (f(xW) * xV) W2.

Setting f to sigmoid reproduces Dauphin et al.’s GLU; omitting f gives a Bilinear layer; setting f to ReLU, GELU, or Swish_1(z) = z * sigmoid(z) gives ReGLU, GEGLU, and SwiGLU. Because three d_model x d_ff matrices replace two, matching parameter count and multiply-add FLOPs requires shrinking d_ff from 4 * d_model (3072) to (2/3) * 4 * d_model (2048). Even the Bilinear variant with zero nonlinearity (1.648 perplexity) beats ReLU, GELU, and Swish, highlighting how input-dependent coordinate multiplication adds expressive power.

Standard FFN vs. SwiGLU at matched T5-Base compute
Standard FFN (2 matrices)

act(xW1) W2 with hidden width d_ff = 3072 (4 * d_model).

Parameters/layer: 2 * 768 * 3072 = 4.72M
FFN_SwiGLU (3 matrices)

(Swish_1(xW) * xV) W2 with d_ff = 2048 (2/3 width).

Parameters/layer: 3 * 768 * 2048 = 4.72M

Source: Shazeer (2020), Sections 2 and 3.1.

Experimental setup and key findings

Shazeer evaluates all eight FFN designs on T5-Base (12 encoder and 12 decoder layers, d_model = 768, 12 attention heads) pretrained with Adafactor on C4 span-filling (128 sequences of 512 tokens per step, ~0.15s/step on a 32-core TPUv2). Four shorter 65,536-step seeds establish tight run-to-run variance (0.003 to 0.010 standard deviation in log-perplexity), where GEGLU (1.942) and SwiGLU (1.944) already separate cleanly from ReLU (1.997) and GELU (1.983).

At 524,288 steps, GEGLU (1.633) and SwiGLU (1.636) maintain a roughly 0.04 log-perplexity lead over ReLU and GELU. After a single 131,072-step multi-task fine-tuning run across SQuAD v1.1, GLUE, and SuperGLUE, SwiGLU achieves the strongest SuperGLUE score (74.56 vs 72.76 ReLU) and ReGLU leads GLUE (84.67 vs 83.80 ReLU). Combined later with RMSNorm and pre-norm residuals, SwiGLU became the default MLP block in PaLM, LLaMA, Mistral, and Qwen.

Caveats and builder takeaway

Shazeer explicitly declines to offer a mechanistic theory (“we attribute their success, as all else, to divine benevolence”), and the experiments have clear limits. Only a single ~220M-parameter encoder-decoder model on C4 was tested at full length, each full checkpoint was fine-tuned once without multi-seed downstream error bars (Raffel et al. measured 0.235 GLUE and 0.416 SuperGLUE standard deviations across seeds), and SwiGLU vs. GEGLU margins on SQuAD and GLUE lie inside that noise band.

In production kernels, FLOP parity does not guarantee identical wall-clock speed: three smaller projections add memory-bandwidth and launch overhead unless xW and xV are fused into a single [d_model, 2 * d_ff] GEMM, and engineers should round (2/3) * 4d to hardware-friendly tensor-core multiples (128 or 256) and benchmark tokens per second alongside perplexity.