How does a SwiGLU feed-forward layer differ from a standard two-layer MLP?
Last updated
A standard MLP is two linear layers with a pointwise nonlinearity (d → 4d → d with ReLU). SwiGLU uses three matrices (gate, up, down):
W2 · (SiLU(W1 x) ⊙ W3 x).The
SiLUgate branch scales the up branch elementwise. This adds multiplicative feature interactions and smoother gradients than ReLU's hard cutoff.The hidden size shrinks to about 8/3·d to keep parameters and FLOPs equal. At matched compute it gives lower perplexity (an empirical gain, not a theoretical one).