Legacy Concept Lab
SwiGLU & Gated Activations
Used in LLaMA, PaLM, and most modern LLMs—replaced ReLU in transformer FFN
#67SwiGLUCore Training
key equation
Phase 2: Architecture fundamentalsConcept 67 of 100
Why It Matters for Modern Models
- Used in LLaMA, PaLM, and most modern LLMs—replaced ReLU in transformer FFN
- Empirically better than ReLU/GELU at same compute budget
- The gating mechanism adds multiplicative interactions, increasing expressiveness
What Tutorials Skip
What is still poorly explained in textbooks and papers:
- Gates let the network learn which features to pass through, not just which to zero out
- SwiGLU needs 50% more parameters for same hidden dim—but quality gains are worth it
- Smooth activations (SiLU vs ReLU) may help optimization by avoiding gradient discontinuities
Interactive Visualization
Core Math (Optional Deep Dive)
If you want intuition first, start with the key equation and the visualization. Come back here for the full walkthrough.
Key Equation
Gated Linear Unit (GLU):
SwiGLU uses SiLU (Swish) activation:
where .
The gating mechanism: one path produces values, another produces gates.
More expressive than ReLU at same parameter count (but uses 50% more compute).