MODEL TECHNIQUE
What Is Classifier-Free Guidance (CFG)?
Classifier-free guidance (CFG) is the technique that makes a diffusion model's output actually match its prompt, instead of producing a generically plausible image or video that only loosely reflects it. It works by generating two predictions at every denoising step, one with the prompt and one without, and pushing the result further in the direction the prompt adds. The same mechanism, run against an unwanted description instead of an empty one, is what a negative prompt does.
Why conditioning alone falls short
Feeding a prompt's embedding into a diffusion model (see how AI image generation works) tells the model what to aim for, but that pull competes against everything else the model learned: the overall statistics of what a realistic image or video looks like. Tested directly, plain conditioning underperforms. A prompt like "a lone tree standing in the middle of a desert" can produce a correct desert, sand, light, shadows, with no tree in it at all, because the model's pull toward generically plausible desert imagery is stronger than its pull toward the one specific, less common detail the prompt asked for.
The model isn't failing to understand the prompt. The conditioning signal is real but comparatively weak next to the model's general sense of what a plausible output looks like, so the prompt's influence needs to be deliberately strengthened rather than just supplied.
How CFG strengthens the signal
CFG, introduced by Jonathan Ho and Tim Salimans, starts with a training trick: during training, the prompt is randomly replaced with an empty condition some fraction of the time, commonly 10 to 20 percent. This teaches one model to act as both an unconditional predictor and a conditional one, instead of training two separate models.
At generation time, each denoising step runs the model twice on the same noisy input: once with the real prompt, once with the empty condition. The difference between those two predictions is the guidance direction, the part of the conditional prediction that the prompt specifically adds. The model then moves further along that direction than the conditional prediction alone would, controlled by a guidance scale: at a scale of 1, you get the plain conditional result (the tree-less desert); turning the scale up amplifies the prompt's pull until the described subject reliably appears and gets more detailed, at the cost of some variety between generations if pushed too far.
Negative prompts: the same trick, aimed at what to avoid
A negative prompt replaces the empty, unconditional prediction with a prediction conditioned on a description of what you don't want. The guidance direction then points away from those unwanted qualities specifically, instead of away from a generic average of all outputs.
This is standard in text-to-video systems: a negative prompt might list "static, blurry, extra fingers, deformed limbs, walking backwards" so that every denoising step is actively steered away from those specific failure modes, not just generically toward the positive prompt. Generations run without a negative prompt are more prone to exactly the defects it would have suppressed: anatomical errors, texture artifacts, and inconsistencies the model would otherwise wander into by default.
FAQ
- Why does turning CFG scale up too high make images look worse?
- Pushed far enough, the guidance direction gets amplified past the point of subtle correction, and outputs start to look oversaturated, overly contrasted, or artificial, since the model is being extrapolated well outside the range it was directly trained to predict.
- Do I need to write a negative prompt every time?
- No. Without one, the model falls back to guiding against its default unconditional prediction, which still improves prompt-following over no guidance at all. A negative prompt is an added layer of control for steering away from specific, known failure modes.
Sources
Related
Last updated 2026-09-13