Glossary
What is CFG scale?
In short
CFG scale is an image generation setting that sets how strictly a neural network follows the text description: the higher the value, the more literal the picture.
Images, video, audio · classifier-free guidance
MMOOZZGG.com editorsChecked: 1 min read
For a child
Imagine you ask a friend to draw a kitten in a hat. If you say “draw what you like”, the friend may forget the hat and add a butterfly. If you keep repeating “only a kitten in a hat!”, you get exactly that, but the friend may try too hard and the drawing comes out rough. A drawing neural network has a switch like this: how closely to follow the request.
In plain words
When a neural network draws, it makes two predictions at each step: how the picture would look with your description and how it would look without it. The difference between them can be made stronger, and this multiplier is called the guidance scale. At a low value the model is freer and the pictures vary more, but it follows the description only roughly. At a high value it tries to match every word, but colors become overexposed and details harsh. People usually look for the middle: they make a few test pictures with different values and pick the one that fits.
For business
The setting affects the share of rejects and how fast you get a usable layout. If the value is too low, the designer gets beautiful pictures far from the task; if too high, someone has to clean up artifacts. It also costs compute: with guidance, the model makes two predictions at each step, so generation is heavier than without it. Cloud services often hide the setting or give it another name. On your own server you tune it for each task and record it in the work rules together with the model and the seed. You find the value with a test series: a dozen descriptions, several values and a designer’s rating.
For a specialist
CFG scale (guidance scale, w) is the weight of classifier-free guidance, proposed by Ho and Salimans (2022). One model is trained as both conditional and unconditional, and at sampling time the two noise estimates are mixed. In diffusers notation: ε̂ = ε(x, ∅) + w·(ε(x, c) − ε(x, ∅)), where c is the text condition. With w = 1 you get a plain conditional model; with w > 1 sampling shifts toward where the condition is stronger, at the cost of diversity. The method needs no external classifier, which classifier guidance requires and which has to be trained on noisy data. In the diffusers library the default is 7.5, guidance turns on at values above 1, and a negative prompt is ignored without guidance. To fight overexposure at large w, especially in models with zero terminal SNR, people use guidance rescale, and distilled models build guidance into their weights.
Example
A designer generates a background for a greeting card: “winter forest with lights”. At 2.5 there are almost no lights; at 12.5 the snow looks like plastic. The designer settles on 7.5 and keeps that value for the whole series.
Related terms
Questions and answers
Sources
Not sure whether your company needs this?
AI solutions map