AI Glossary / Probabilistic machine learning / Intermediate
Classifier-free guidance
Definition
Classifier-free guidance is a diffusion-generation technique that combines conditional and unconditional model predictions to strengthen the influence of a requested condition. It obtains the guidance signal without a separate classifier. A guidance scale controls how far the combined prediction moves from unconditional behavior toward, or beyond, the conditional prediction.
What it means
A conditional diffusion model receives information such as a class label or another supported condition. An unconditional model predicts without that condition. Their difference provides a direction associated with the conditioning information.
Classifier-free guidance uses that difference during sampling. In the original formulation, one network learns both behaviors by sometimes receiving the condition and sometimes receiving a designated null condition during training.
Classifier-free does not mean training-free, condition-free, or free of computational cost. It refers specifically to avoiding the separate classifier used by classifier guidance. The generative model still needs a useful learned relationship between the condition and the data.
How it works
Train a denoising model with conditioning information, randomly omitting that information for some training examples. This lets the shared network learn both conditional and unconditional predictions.
At a sampling step, evaluate the current noisy state with the desired condition and with the null condition. For a noise-prediction parameterization, write these outputs as epsilon_cond and epsilon_uncond.
One common convention is epsilon_guided = epsilon_uncond + s × (epsilon_cond − epsilon_uncond). Under this convention, s = 0 gives the unconditional prediction, s = 1 gives the ordinary conditional prediction, and s greater than one extrapolates beyond it.
The original paper writes (1 + w) × epsilon_cond − w × epsilon_uncond, so its w equals s − 1. Feed the combined prediction into the chosen diffusion sampler. The equation specifies a model prediction, not a complete sampling update by itself.
Three practical examples
- A class-conditioned image-generation experiment increases guidance to emphasize the requested class while examining changes in variety.
- A conditional generative system combines its null-condition and requested-condition predictions at each denoising step.
- A researcher compares guidance strengths using the same model and sampler, recording the convention so results can be interpreted correctly.
Think of it this way
Think of comparing a sketch made without a brief with one made for a particular brief. The difference highlights changes associated with the request, and the artist can emphasize those changes further.
The analogy has limits: the model combines numerical denoising predictions, not finished pictures or deliberate artistic judgments. Exaggerating the difference may amplify undesirable features as well as the intended condition.
Worked example
Use an original two-coordinate noise-prediction example. Let epsilon_uncond = (0.2, −0.1) and epsilon_cond = (0.5, 0.3). Their difference is (0.3, 0.4).
With the s convention and s = 3, the guided prediction is (0.2, −0.1) + 3 × (0.3, 0.4) = (1.1, 1.1). This lies beyond the conditional prediction rather than between the two predictions.
The original paper's equivalent setting is w = 2. Its formula gives 3 × (0.5, 0.3) − 2 × (0.2, −0.1) = (1.5, 0.9) − (0.4, −0.2) = (1.1, 1.1), the same result.
At s = 1, or equivalently w = 0, the result is simply (0.5, 0.3). The coordinates are predicted noise values, not probabilities or image-quality scores. A sampler must still use them with its timestep-dependent update to obtain the next state.
Illustrative case study
In a fictional project, Birch Studio compares generated illustrations from two implementations. Both interfaces show a guidance value of two, but one uses the s convention and the other uses the original w convention.
The team checks the underlying formulas and aligns the effective strengths before comparing results. It then evaluates adherence to the condition, visible artifacts, and variation across multiple samples.
This invented case illustrates a reproducibility issue. It reports no actual product behavior or measured quality advantage.
Common misconceptions and mistakes
Do not assume that guidance zero always means unconditional generation. It depends on the convention: the original paper's w = 0 is ordinary conditional generation.
Do not call the combination a simple average when the scale extrapolates beyond the conditional prediction.
Do not assume classifier-free guidance requires two independently trained networks. The original method uses one network for both modes.
Do not equate stronger guidance with uniformly better results. Excessive emphasis can reduce variety or produce artifacts.
Finally, do not claim that the difference of approximate neural predictions is exactly the gradient of a real classifier. The original paper distinguishes the ideal score identity from what unconstrained learned networks actually provide.
Business use
For teams using conditional generation, guidance is an operating choice that can affect adherence, variety, and appearance. It should be evaluated against the actual purpose of the generated material rather than chosen solely because a larger number sounds stronger.
Record the model, sampler, guidance convention, condition, and evaluation setup. Compare collections rather than relying on a single appealing sample. In the standard implementation, obtaining both predictions also adds computation; removing a separate classifier does not mean every sampling step becomes costless or requires only one prediction.
People also ask
Is this the same as classifier guidance?
No. Classifier guidance uses an auxiliary classifier gradient; classifier-free guidance uses conditional and unconditional generative predictions.
Is the unconditional branch required to be a separate model?
No. A shared network can use a null condition to provide that prediction.
Does guidance guarantee that every requested detail appears?
No. It amplifies a learned conditioning signal, which may be incomplete or inaccurate. Results still need evaluation.
Check your understanding
Using epsilon_uncond + s × (epsilon_cond − epsilon_uncond), what does s = 1 produce, and what is the equivalent original-paper w?
Answer: It produces epsilon_cond, the ordinary conditional prediction. The equivalent w is zero because s = 1 + w.
Related terms
- Classifier guidance
- Score matching
- Sampling
- conditional diffusion
- denoising prediction
- null conditioning
- guidance scale
Learn next
reproduce the worked calculation at several scales and distinguish interpolation from extrapolation. Then compare the guidance equation with a full sampler update so the model prediction is not confused with the generated state.
More in Probabilistic machine learning
- Chain graphical model - A chain graphical model represents a probability distribution using a graph that can contain both directed and undirected edges, subject to restrictions...
- Class incremental learning - Class incremental learning is a continual-learning setting in which a model learns additional classes over time while remaining able to distinguish the...
- Classification with rejection - Classification with rejection allows a classifier to abstain from assigning a class to selected inputs.
- Cluster assumption - The cluster assumption is a semi-supervised learning assumption that examples within the same meaningful high-density cluster tend to share a class.
- Collapsed Gibbs sampling - Collapsed Gibbs sampling is a Markov chain Monte Carlo method that integrates some unknown variables out of a probability model, then repeatedly samples the...
- Common random numbers - Common random numbers is a simulation technique that deliberately shares random inputs between alternatives being compared.
Sources
Primary source: Ho and Salimans, Classifier-Free Diffusion Guidance, algorithms 1–2 and section 3.2: https://arxiv.org/pdf/2207.12598 Classifier-guidance comparison: Dhariwal and Nichol, Diffusion Models Beat GANs on Image Synthesis: https://papers.neurips.cc/paper/2021/file/49ad23d1ec9fa4bd8d77d02681df5cfa-Paper.pdf The numerical vectors and fictional case are original illustrations.
Previous: Classifier chains Next: Classifier guidance