4.5.14 · D5Generative Models

Question bank — Classifier-free guidance

2,035 words9 min readBack to topic

This bank hunts the conceptual misconceptions around classifier-free guidance (CFG). Every reveal below forces you to justify — a bare "true" or "false" earns nothing. Cover the sign traps, the -limits, the training-time null token, and the difference from Classifier guidance. Read the question, commit to an answer out loud, then reveal.

Figure — Classifier-free guidance

Figure 1 plots the guidance line through the two anchor predictions (point ①, at ) and (point ②, at ). The cyan segment ③ is the interpolation region where the guided point sits between the anchors; the amber ray ④ is the extrapolation region where it shoots past (the amber star marks ). Every "sign trap" below is really asking: where on this line does your land — cyan segment ③ or amber ray ④?


True or false — justify

CFG requires training a separate noise-robust classifier alongside the diffusion model.
False. That is Classifier guidance. CFG's whole point is to avoid the extra classifier by training one model to do both conditional and unconditional denoising, then differencing the two at sampling time.
Setting recovers ordinary conditional sampling with no amplification.
True. At the formula collapses to , exactly the plain conditional prediction — no guidance, no extrapolation.
At the model still weakly follows the prompt.
False. At the coefficient on is zero and on is one, so you get the purely unconditional prediction — the prompt is completely ignored.
Increasing always improves image quality.
False. Higher improves prompt adherence but eventually over-saturates colors, flattens texture, and reduces diversity (mode-collapse-like behaviour). Quality peaks at a moderate then degrades.
For , the unconditional term carries a negative weight.
True. The weight is , which is negative once (e.g. at it is ). This actively pushes the sample away from the generic unconditional distribution, sharpening it toward .
CFG changes what the network's weights are; it is a training-time modification.
False. The trained network is untouched. CFG is an inference-time recombination of two forward passes. The only training-side change is randomly dropping so the same weights can denoise unconditionally.
The vector is the same length regardless of the prompt.
False. is the "direction the prompt adds," and its magnitude depends on how much the prompt changes the prediction at that . A vague or off-distribution prompt yields a small ; a strong, in-distribution prompt yields a large one.
Because CFG runs the model twice per step, it roughly doubles sampling compute versus plain conditional sampling.
True. Each denoising step needs both and , so wall-clock cost per step is about (often batched into one forward pass of doubled batch size).
CFG and Classifier guidance produce the score modification via the same term.
True (in effect). Both add . CFG just estimates that gradient implicitly as instead of reading it off an explicit classifier.
The null token must be a special learned symbol distinct from any real prompt.
Mostly true in practice. For text it is typically the empty string / a fixed padding embedding; for class labels a dedicated null class. What matters is that it is a consistent, reserved input the model was trained to see when conditioning is dropped.

Spot the error

"CFG works by adding the classifier gradient to the score."
Error: it should be . The term has no dependence, so its gradient is zero — it can't steer anything.
"The guided formula is ."
Error: the weights are swapped. It is . As written, at you'd amplify the unconditional term — the opposite of guidance.
"Since , choosing gives the conditional prediction."
Error: kills , leaving — the unconditional prediction. You need for the plain conditional.
"To train CFG we drop the conditioning on 100% of examples so the model becomes fully unconditional."
Error: the drop rate, call it , is a small fraction (commonly ; the original CFG paper found worked well, and large values like waste capacity the conditional path needs). Setting would make the model never learn conditional denoising, so would be meaningless.
" points from the conditional toward the unconditional prediction."
Error: points from the unconditional toward the conditional. We then add copies of it to the unconditional baseline to overshoot toward the prompt.
"Because guidance sharpens toward the prompt, CFG increases the diversity of generated samples."
Error: it reduces diversity. Concentrating probability mass around prompt-matching modes is exactly why high causes reduced variety and mode-collapse-like output.
"CFG requires the unconditional and conditional models to be two separately trained networks."
Error: it is one network with shared weights; the "two models" are two forward passes of the same weights, differing only in whether or is fed in.

Why questions

Why does the term disappear when we take ?
Because is a constant with respect to (the prior over conditions doesn't depend on the noisy image), and the gradient of a constant is zero. This is what cleanly splits the conditional score into unconditional score plus the classifier term.
Why does subtracting from isolate the effect of the prompt?
Both predictions share everything the model knows about generic images at ; only the conditional one also encodes . Subtracting cancels the common part and leaves just the prompt-specific direction .
Why does scaling by correspond to sampling from the sharpened posterior ?
Take the log of that target: . Its gradient is . Since the classifier gradient equals , which in -land is exactly , scaling it by is raising to the power — a peakier, more confident posterior.
Why must we train with conditioning dropout rather than just feeding at inference?
If the model never saw during training, its "unconditional" pass would be an untrained, arbitrary output. Dropout teaches the same weights to give a valid unconditional prediction, which is what must be for the difference to be meaningful.
Why does negative prompting fit naturally into the CFG formula?
Negative prompting swaps the baseline for a prediction conditioned on the unwanted concept ; guidance then pushes away from and toward the positive prompt — the same subtract-and-extrapolate structure with a non-empty baseline.
Why is CFG described as extrapolation rather than interpolation when ?
For the guided prediction is a convex blend between and (interpolation, cyan segment ③ in Figure 1). For the point lies beyond on the line through both (amber ray ④) — you leave the segment, hence extrapolation.
Why is CFG describable in the language of Score-based diffusion models at all?
Because the predicted noise is a fixed rescaling of the negative score, . So manipulating scores by Bayes' rule translates one-to-one into manipulating noise predictions — that exact relation is what makes the whole derivation legal.

Edge cases

What does equal in the limit (direction only)?
It aligns with the ray , dominated entirely by . In practice this produces extreme, over-saturated, low-diversity samples long before the theoretical limit.
What happens if a prompt is so out-of-distribution that ?
Guidance has almost nothing to amplify, so regardless of — the output stays generic. The prompt effectively fails to steer generation.
If is set negative, what would CFG do?
The weight on becomes negative, so sampling is pushed away from the prompt — you'd get an image avoiding the described concept, the inverse of guidance (and the mechanism behind treating an unwanted concept as a target to flee).
At the final denoising step (, image nearly clean), does the guidance term matter?
It still applies, but is typically small there because the image is already mostly determined; most of guidance's shaping happens at higher where structure is still forming.
Is CFG applicable to unconditional-only models (no ever)?
No. Without any conditioning signal there is no to compare against , so is undefined. CFG fundamentally needs a Conditional generation setup.
Does the DDPM/DDIM update change under CFG?
No — the sampler equations are identical. You simply feed in place of wherever the DDPM sampling step uses the predicted noise.
Recall Quick self-check

"Load-bearing sign fact" means the one sign that, if flipped, breaks everything. Here it is ::: For , the unconditional term's weight is negative, pushing away from generic samples toward the prompt. Flip that sign and you'd steer away from the prompt instead. The single load-bearing training fact ::: Randomly drop with probability (a small value, commonly ) and replace with so one set of weights learns both conditional and unconditional denoising.