home/ atoms/ classifier-free-guidance

Classifier-free guidance combines conditional and unconditional model outputs at inference to steer generation without a separate classifier

Classifier-free guidance (CFG) trains a single diffusion model to produce both conditional (given label/text y) and unconditional (y=empty) outputs by randomly dropping the conditioning during training. At inference, the final noise prediction is epsilon_guided = (w+1)epsilon_cond - wepsilon_uncond = epsilon_uncond + (w+1)*(epsilon_cond - epsilon_uncond). Increasing the guidance weight w strengthens adherence to the conditioning at the cost of sample diversity and sometimes image quality. CFG is now the standard in text-to-image systems (Stable Diffusion, DALL-E, Imagen) because it avoids a second classifier model and, as GLIDE found, gives better quality-diversity tradeoffs than classifier guidance (which can exploit the classifier with adversarial examples).

Examples

Stable Diffusion uses CFG with a guidance scale around 7.5 by default. Lower scale gives more diverse outputs; very high scale often causes oversaturated, artifact-prone images.

Assessment

Write out the CFG noise-prediction formula. What happens as w increases? Why is CFG preferred over classifier guidance in modern image-generation systems?

“These two models can be learned via a single neural network.”
corpus · what-are-diffusion-models-lil-log-lilian-weng · chunk 9