Classifier-Free Guidance

Also known as: CFG, Guidance Scale

Category: Generative AI / LLM

A technique used in diffusion models that controls how closely the generated image follows the text prompt by blending conditional and unconditional predictions.

Full Explanation

Classifier-free guidance (CFG) is a fundamental technique in text-to-image diffusion models that controls the trade-off between image quality/diversity and adherence to the text prompt. During generation, the model makes two predictions at each denoising step: one conditioned on the text prompt and one without conditioning (unconditional). The final prediction is computed by moving away from the unconditional prediction and toward the conditional one, scaled by the guidance scale parameter. Higher guidance values produce images that more closely match the prompt but may reduce diversity and introduce artifacts; lower values produce more varied but less prompt-aligned results. Typical guidance scales range from 5 to 15. CFG replaced the earlier approach of using a separate classifier model to guide generation, making it simpler and more flexible. It is a key parameter users adjust when generating images with models like Stable Diffusion and DALL-E.

Related Terms

More in Generative AI / LLM

Explore More