Pick a concrete input and say what the equation should give before you read the math.
Foundation reference
Classifier-Free Guidance in Diffusion
Classifier-free guidance combines a diffusion model's predictions with and without a condition, such as a text prompt. It is used in published text-to-image systems such as GLIDE and latent diffusion, the basis of Stable Diffusion, where it greatly improves how closely images follow the prompt (Nichol et al., 2022; Rombach et al., 2022).
Study guide
Where to start
Why does guidance with w > 1 extrapolate beyond the conditional distribution, and why can that give images that follow the prompt more closely but look less natural?
How to study this pagePredict · Check · Generalize · Continue
Work through the math, then read the cited papers for the original argument.
Identify the part of the idea that survives a change of notation or model, so you can recognize it in another paper or system.
Use the prerequisites and related concepts at the end of the page to fill the next gap.
Why It Matters for Modern Models
- Classifier-free guidance combines a diffusion model's predictions with and without a condition, such as a text prompt. It is used in published text-to-image systems such as GLIDE and latent diffusion, the basis of Stable Diffusion, where it greatly improves how closely images follow the prompt (Nichol et al., 2022; Rombach et al., 2022).
- The guidance scale is the main user-facing setting for trading prompt fidelity against diversity in text-to-image models.
- One network serves as both the conditional and the unconditional model, because the conditioning is dropped at random during training.
Questions to Think About
- What happens at the two extremes of the guidance scale: why does too little guidance ignore the prompt, and too much produce oversaturated images with artifacts?
- How is raising the guidance scale like lowering the temperature of a language model, and where does the comparison break down?
Core Math
Classifier-free guidance combines the predictions of one diffusion model run with and without its conditioning , for example a text prompt:
where is the guidance scale. With this is the ordinary conditional prediction; with it extrapolates past it, away from the unconditional prediction. Text-to-image systems typically use values well above 1. (Ho & Salimans write the same rule with shifted by one.)
One network learns both predictions: during training the conditioning is replaced by a null token for a random fraction of examples.
In terms of scores. Because is a rescaled score, , the rule is equivalent to
using Bayes' rule, . Classifier guidance computes the second term with a separately trained classifier on noisy images (Dhariwal & Nichol, 2021); classifier-free guidance obtains it from the difference between the conditional and unconditional predictions. Raising trades sample diversity for fidelity to the condition.