← Back to Multimodal Mind Map
中文·English
👁️ MultimodalID: cfg-guidance

Classifier-Free Guidance

Classifier-Free Guidance (CFG)
🎯Core Definition
Classifier-Free Guidance linearly extrapolates between a conditional and an unconditional prediction so that sampling amplifies the condition cc. During training the condition is dropped with probability pp (CFG dropout, usually 10–15%) and replaced by the empty token ∅\emptyset, so one network learns both ϵθ(xt,c)\epsilon_\theta(x_t, c) and ϵθ(xt,∅)\epsilon_\theta(x_t, \emptyset). At sampling the two noise predictions are combined with strength ww:
📌Overview
ϵ^θ(xt,c)=ϵθ(xt,∅)+w(ϵθ(xt,c)−ϵθ(xt,∅)),w≥1\hat\epsilon_\theta(x_t, c) = \epsilon_\theta(x_t, \emptyset) + w\left(\epsilon_\theta(x_t, c) - \epsilon_\theta(x_t, \emptyset)\right),\qquad w \ge 1
📌Overview
w=1w=1 reduces to plain conditional sampling; larger ww pushes the trajectory toward the conditional distribution (stronger prompt adherence) at the cost of diversity and oversaturated colors; typical values are w=7–8w = 7\text{–}8 for Stable Diffusion and w=3–5w = 3\text{–}5 for video/cascaded models. It is a score reweighting: it matches the behavior of classifier guidance ∇xtlog⁡p(xt)+γ∇xtlog⁡p(c∣xt)\nabla_{x_t}\log p(x_t) + \gamma\nabla_{x_t}\log p(c \mid x_t), pushing the score toward conditional likelihood, but needs no extra classifier.
💡Use Cases
prompt adherence in text-to-image/text-to-video (enabled by default in SD/Flux); a classic interview question — “how is CFG implemented, what w is typical, and why does large w oversaturate and reduce diversity?”.
⚡Key Problems Solved
plain conditional diffusion gives weak text control and off-prompt samples; classifier guidance needs a separately trained discriminator that is sensitive to adversarial noise; CFG needs one training run (dropout) and two forward passes (conditional + unconditional) at inference — no extra model — while substantially improving condition fidelity.
🎯Core Interview Exam Points
Fundamentals · Production Scenarios · Deep Dive
Core Def
Explain the core definition, underlying mechanism/math, and key principles of Classifier-Free Guidance.
Use Cases
In production engineering, what are the primary use cases for Classifier-Free Guidance and what core pain points does it solve?
🔥 High-Frequency Deep-Dive Questions
1
Write the CFG sampling formula and explain every symbol.
2
What is the typical CFG dropout probability, and how does one network learn both branches?
3
How does increasing w affect adherence, diversity and oversaturation, and why?
4
How does classifier-free guidance relate to classifier guidance; pros and cons of each?
5
What do w=1 and w=0 correspond to, and what is CFG's extra inference cost?
📖 In-depth Guide:📄 diffusion-models →
Updated 2026-08-12
🎯
Test Your Knowledge: Practice Questions for "Classifier-Free Guidance"
Single choice pitfall questions with instant feedback and mistake tracking.
🚀 Start Card Practice ➔
← Previous CardDDPM Forward/Reverse ProcessNext Card →Latent Diffusion (LDM)

🔗 More Multimodal Knowledge Cards

ASR (Whisper)Audio RepresentationCLIP ApplicationsCLIP Two-Tower Architecture