TL;DR
Diffusion models can be steered toward a class label or a text prompt to trade sample variety for sample fidelity. Earlier methods needed a separate classifier trained on noisy images to do this. Ho and Salimans show that the same effect comes from one network trained with random conditioning dropout, so it learns both the conditional and unconditional cases, then extrapolating its conditional prediction away from its unconditional one at sampling time.
Where you'll see it: almost every text-to-image system, where the "guidance scale" slider is this paper's weight .
The problem
Diffusion models generate good samples but, left alone, they spread across the whole data distribution. The Inception score rewards samples that a classifier labels confidently, so a model that covers all modes will score poorly on it even when its images look reasonable.
Practitioners wanted the sampling knob that GANs had: truncation, which trades diversity for fidelity. Shrinking the noise in a diffusion sampler does not work, because it produces blurry, low-quality images. The working solution before this paper was classifier guidance, which pushes samples uphill on the log-likelihood of an image classifier. That classifier had to be trained separately, on noisy images, which made the training pipeline heavier and tied sampling to gradients of a model that was not the generator.
Key idea
Classifier guidance adds a classifier gradient to the score. The paper observes that a classifier can be implied by the generative model itself. By Bayes' rule, the ratio of the conditional score to the unconditional score is the gradient of an implicit classifier. So if a single network can predict both scores, the guidance direction is available without any extra model.
The method is concrete. Train one network with the condition replaced by a null token a fraction of the time. At sampling time, form the extrapolated prediction
and sample with it in place of the ordinary prediction. Larger pushes the sample further from the unconditional prediction and closer to the condition. That is the whole method. The rest of the paper is about showing that the trade-off it produces is as good as classifier guidance.
The method
Background
A diffusion model corrupts data with Gaussian noise at a log signal-to-noise ratio :
Here and are the signal and noise scales implied by , and is a network that predicts the added noise. Training minimises the denoising loss from DDPM, which is a weighted form of denoising score matching. The network's noise prediction is proportional to the score scaled by , so the noise prediction and the score carry the same information. Sampling follows the score, which is why modifying the noise prediction modifies the sampling distribution.
Classifier guidance, in one equation
Dhariwal and Nichol replaced the score by the score plus the gradient of an image classifier's log-probability of the condition , scaled by . The sampled distribution then becomes approximately
The factor up-weights samples that the classifier recognises. That raises the Inception score and lowers diversity, which is the truncation-like behaviour the authors wanted. The drawback is the separately trained classifier, which has to work on noisy inputs.
Classifier-free guidance
Apply Bayes' rule to the conditional and unconditional densities. The implicit classifier is
Its log-gradient is a difference of two scores. Substituting exact scores into the classifier-guidance formula and rearranging gives the combination shown above. The authors are careful about the status of this step. Because the networks are unconstrained, the combined field is not guaranteed to be the gradient of any scalar potential, so it is not exactly a classifier-guided score. It is inspired by one, and the paper's evidence is empirical.
Training is Algorithm 1 in the paper. For each example, draw , replace by the null token with probability , draw and , form , and take a gradient step on . Sampling is Algorithm 2. At each step compute the two predictions, combine them with , and pass the result to any diffusion sampler, such as ancestral sampling or DDIM. The cost is two network evaluations per step, one conditional and one unconditional.
Results
The experiments use class-conditional ImageNet at 64 by 64 and 128 by 128, with the same architecture and hyperparameters as the guided diffusion models of Dhariwal and Nichol. The paper states plainly that these experiments are a proof of concept, not a push for state of the art, though its 128 by 128 results are reported as state of the art at the time.
Guidance strength. Sweeping from 0 to 4 traces a clear frontier between FID and Inception score: Inception score rises steadily with , while FID is best at small and then worsens. At 64 by 64 with , the best FID is 1.55 at , compared with 2.07 for ADM and 1.48 for the cascaded model CDM (the latter is best). At the Inception score reaches 260.2 with FID 26.22, which is the high-fidelity end of the curve.
Sampling steps. At 128 by 128 with 256 sampling steps and , the paper reports FID 2.43 and Inception score 158.47. The FID is better than the classifier-guided ADM-G at 2.97. The paper notes that 256 steps match ADM-G's step count, but each classifier-free step costs two network evaluations, so the fair speed comparison is its 128-step setting, which underperforms in FID.
Unconditional probability. Training with is consistently worse across the frontier than 0.1 or 0.2, which perform about the same. The authors read this as a sign that only a small fraction of model capacity needs to go to unconditional generation.
Figures show the qualitative effect. Stronger guidance produces more saturated colours and less variety, which is the expected truncation-like behaviour.
Why it mattered
The paper turned guidance from a classifier-dependent trick into a property of the generative model. Once the conditioning can be dropped during training, any conditional diffusion model gets a sampling-time quality knob for free. Later text-to-image systems use this exact combination, with the condition being a text embedding and exposed to users as a guidance scale.
The method also made the sampling trade-off explicit. Because the update is a linear extrapolation, a larger can push samples outside the region of likely conditional data. Practitioners later found saturated colours and reduced diversity at high guidance, which the paper already observes. The paper itself flags the loss of diversity as a concern for deployed models.
Reading guide
Read the paper in this order, and use these prerequisites for each part.
- Introduction and Section 2 (Background). Needs Gaussian (Normal) Distribution for the noising process and DDPM for the training loss and the noise-prediction parameterisation.
- Section 3.1 (Classifier guidance). Needs Score Function for why the noise prediction is a scaled score, and Score Matching for the link between denoising and score estimation. The tilted distribution is a product of densities, so it helps to be comfortable with Bayes' Rule.
- Section 3.2 (Classifier-free guidance). Needs Classifier-Free Guidance for the combined prediction, and the derivation step uses the implicit-classifier identity from Bayes' rule. Algorithms 1 and 2 are the practical core.
- Section 4 (Experiments). Needs Diffusion Model for the sampling loop and the notion of sampling steps, and Variational Lower Bound (ELBO) if you want the likelihood background behind the training objective. The FID and Inception score definitions are standard and need no separate lesson here.
- Section 5 (Discussion). Revisits the non-conservative-field point from Section 3.2 and the cost of two forward passes per step. Langevin Dynamics (also mentioned at the end of Section 2) gives the intuition that sampling follows a score field, and Denoising Diffusion Implicit Models (DDIM) covers the deterministic sampler that Algorithm 2 says can replace the ancestral step.
Check yourself
QuestionRecall: what is the combined prediction used at sampling time, and what does each term stand for?Show answer
The combined prediction is . The first term is the noise prediction given the condition . The second is the noise prediction with the condition replaced by the null token, which is the unconditional prediction. The guidance weight controls how far the result moves away from the unconditional prediction, toward the conditional one.
QuestionComputation: suppose at some step the conditional prediction is 0.5 and the unconditional prediction is 0.2 for one coordinate, and . What is the guided value, and check it another way?Show answer
Direct: . Rewriting the formula as gives , which agrees. The guided value lies beyond the conditional prediction, because the extrapolation keeps going past it in the same direction.
QuestionWhy: the paper says classifier-free guidance is only inspired by a classifier and is not exactly a classifier-guided score. Why can't the combined field be an exact classifier gradient?Show answer
A classifier-guided score is the score of a tilted density, which requires the guidance direction to be the gradient of a scalar function, the classifier log-probability. The combined field is built from two unconstrained neural network outputs, and such outputs need not be conservative. A vector field has a scalar potential only when its curl vanishes, and nothing in the training forces that. So there may be no classifier whose gradient equals the combined field, even though the field has the same role in sampling.
QuestionApplied: you want to add guidance to an existing conditional diffusion model without retraining it from scratch. What is the minimal change, and what does it cost at sampling time?Show answer
Fine-tune the model so that it also learns the unconditional case, by dropping the condition with some probability during continued training. This needs no separate classifier. At sampling time, run the network twice per step, once with the condition and once with the null token, and combine them with . The sampling cost roughly doubles per step, which is the main drawback the paper names. You would also need to tune , because too large a value reduces diversity and produces saturated samples.
Sources
- Ho, Salimans, Classifier-Free Diffusion Guidance, 2022: https://arxiv.org/abs/2207.12598
- Dhariwal, Nichol, Diffusion Models Beat GANs on Image Synthesis, 2021: https://arxiv.org/abs/2105.05233
- Ho, Jain, Abbeel, Denoising Diffusion Probabilistic Models, 2020: https://arxiv.org/abs/2006.11239