Back to LLMs Mind Map
中文·English
LLMsID: feedforward-swiglu

FFN & SwiGLU

前馈层与激活
🎯Core Definition
the Transformer feed-forward layer FFN(x)=W2GELU(W1x)FFN(x) = W_2 \cdot GELU(W_1 x) holds roughly 2/3 of model parameters (excluding embeddings); SwiGLU is a gated activation: SwiGLU(x)=(SiLU(xWg))(xWu)WdSwiGLU(x) = (SiLU(x W_g)) \cdot (x W_u) W_d with SiLU(x)=xsigmoid(x)SiLU(x) = x \cdot sigmoid(x) (Swish), shrinking the intermediate width from 4d4d to 83d\frac{8}{3}d (LLaMA-2 7B: hidden 4096 → intermediate 11008).
💡Use Cases
every mainstream model after 2023 (LLaMA-2/3, Qwen, Mistral, Gemma) replaced GELU MLPs with SwiGLU; interviews often probe "why gating", "why 8/3 d" and activation memory during training.
Key Problems Solved
plain ReLU/GELU MLPs have no input-conditional selection — information flows the same way for every token; the 4d4d intermediate width inflates parameters and activations; SwiGLU lets different tokens traverse different "sub-networks" via input-dependent gating, improving quality at equal parameter count while actually shrinking parameters and training activation memory (4d83d4d \rightarrow \frac{8}{3}d).
🎯5 High-Frequency Exam Points
1
Why does FFN hold ~2/3 of parameters? Design of intermediate width 4d4d vs 83d\frac{8}{3}d?
2
Essential difference between SwiGLU and a plain GELU MLP (input-dependent gating)?
3
Properties of SiLU/Swish: why smoother and saturation-free vs ReLU?
4
GLU family: activations used by ReGLU, GEGLU and SwiGLU?
5
Why is FFN activation memory large in training, and how to mitigate (caching, recomputation)?
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "FFN & SwiGLU"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice
Previous CardRoPE Extrapolation PI/NTK/YaRNNext CardPre-LN & RMSNorm

🔗 More LLMs Knowledge Cards

Agent & Tool CallingAlignment Tax & Preference DataScaled Dot-Product AttentionAttention Variants MHA/MQA/GQA