← All questions
LLM FoundationsHard· Transformer Architecture

Why did SwiGLU replace plain ReLU/GELU in modern LLM fe...

A gated linear unit variant like SwiGLU splits the feed-forward projection into two paths — one passed through a smooth activation (Swish/SiLU), the other left linear — and multiplies them together elementwise. That multiplicative gate lets the network learn, per unit, how much signal to let through, rather than every unit getting the same fixed nonlinearity shape.

The empirical case for it is simple: at a matched parameter count, SwiGLU feed-forward blocks consistently outperform plain ReLU or GELU blocks on downstream tasks. The cost is that the gating mechanism needs extra weight matrices — roughly 50% more parameters in that block for the same hidden width — which most architectures compensate for by shrinking the feed-forward hidden dimension slightly, netting out close to parameter-neutral for a real quality gain.

Code playground (Python)