FoundationsChecking saved investigationReading browser-local route memory before showing a continuation.

Foundation Lab

SwiGLU & Gated Activations

Used in LLaMA, PaLM, and most modern LLMs—replaced ReLU in transformer FFN

Concept 67 of 100Core TrainingPhase 2
#67SwiGLUCore Training
key equation\text{SwiGLU}(x) = (xW_1 \cdot \text{SiLU}(xW_2)) W_3

Selected Foundation Object

Keep the equation fixed; move through the evidence.

Concept 67 of 100SwiGLUCore Training / Phase 2: Architecture fundamentals
Current question

Gates let the network learn which features to pass through, not just which to zero out

\text{SwiGLU}(x) = (xW_1 \cdot \text{SiLU}(xW_2)) W_3
PredictionCommit before the demo.

Ask what should change when the equation is manipulated, then let the visualization test that expectation.

EvidenceCompare local witness and source.

Use the runnable panel, the key equation, and canonical papers as separate forms of evidence for the same object.

InvariantName what survives notation changes.

The useful learning product is the reusable mechanism you can carry into another model, paper, or engineering tradeoff.

Next moveContinue through the atlas.

Use prerequisites, dependents, and semantic links to repair the next gap without leaving the object behind.

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
SwiGLU(x)=(xW1SiLU(xW2))W3\text{SwiGLU}(x) = (xW_1 \cdot \text{SiLU}(xW_2)) W_3

Gated Linear Unit (GLU):

GLU(x)=(xW1)σ(xW2)\text{GLU}(x) = (xW_1) \odot \sigma(xW_2)

SwiGLU uses SiLU (Swish) activation:

SwiGLU(x)=(xW1SiLU(xW2))W3\text{SwiGLU}(x) = (xW_1 \cdot \text{SiLU}(xW_2)) W_3

where SiLU(x)=xσ(x)\text{SiLU}(x) = x \cdot \sigma(x).

The gating mechanism: one path produces values, another produces gates.
More expressive than ReLU at same parameter count (but uses 50% more compute).

Canonical Papers

GLU Variants Improve Transformer

Shazeer2020arXiv
Read paper →

LLaMA: Open and Efficient Foundation Language Models

Touvron et al.2023arXiv
Read paper →

Connections

Prerequisites

Next Moves

Choose the next question to carry this object forward.