# Classifier-free guidance (CFG)

> Canonical: https://skillalmanac.com/glossary/classifier-free-guidance | Last verified: 2026-11-25 | Index status: index-eligible

Classifier-free guidance is a diffusion-model technique that combines a conditional and an unconditional prediction, so one setting can trade how closely an image follows its prompt against sample diversity, without a separate classifier.

Also called: CFG, CFG scale, guidance scale, CFG Stable Diffusion, classifier-free diffusion guidance.

## In plain language

Image generators turn a text prompt into a picture, and most expose a dial often called guidance scale or CFG scale. Turn it down and the model wanders more loosely from your wording. Turn it up and it sticks closer to the prompt, though the Hugging Face guide warns that a value that is too high can show artifacts in the image. The idea comes from a 2022 paper that showed this steering works without a separate classifier. The limit is that no single value is right for every prompt or model, so you have to try settings, and each try generates a new image.

## Technical definition

The paper (arXiv 2207.12598) starts from classifier guidance, which combines a diffusion model's score estimate with the gradient of a separately trained image classifier to trade off mode coverage against sample fidelity after training. Classifier-free guidance removes that classifier: a conditional and an unconditional diffusion model are trained jointly, and their score estimates are combined at sampling time to trade sample quality against diversity. Image-generation libraries expose a setting for this kind of control. The Hugging Face Diffusers documentation describes its guidance_scale parameter as affecting how much the prompt influences generation: lower values give more creative, looser images, and higher values follow the prompt more closely.

## How it shows up when you use agents

Classifier-free guidance is a setting you meet when you generate images, not when you code. In a hosted image tool it may appear as a slider labelled guidance or CFG. In code, a coding agent writing a script with the Hugging Face Diffusers library would pass a `guidance_scale` value to the pipeline, which the documentation says affects how much the prompt influences the image. The model behind it is a [diffusion model](/glossary/diffusion-model), used for [text-to-image](/glossary/text-to-image) generation.

What goes wrong when it is misunderstood: people turn the value up expecting "better" images and get artifacts, which the Hugging Face page warns about for high values. Others change the prompt and the setting at the same time, then cannot tell which one made the difference. A [negative prompt](/glossary/negative-prompt) is a separate control: the Diffusers page describes it as steering the model away from things you do not want.

Next action: if you ask an agent to generate images, ask it to keep the seed and prompt fixed, vary only the guidance value across a few runs, and save each output next to its settings. That gives you a comparison you can judge by eye. Check that an image service exposes the setting before you plan around it.

## Common confusions

- **Guidance scale versus the method.** Search queries use "guidance scale" and "CFG scale" for the setting. The paper is the source of the method's name, and the Hugging Face page documents the guidance_scale parameter. This entry does not claim every tool implements the setting the same way.
- **Classifier guidance versus classifier-free guidance.** The paper says classifier guidance needs a separately trained image classifier. The classifier-free version trains a conditional and an unconditional diffusion model jointly instead.
- **Guidance scale versus negative prompt.** One sets how strongly the prompt influences the image. The other names things to steer away from. They are two parameters in the Diffusers documentation.
- **Prompt adherence versus quality.** The paper describes a trade-off between quality and diversity. Following the prompt more closely is not the same as a better picture, and this entry makes no quality claim.
- **Myth.** Higher is better. The Hugging Face page says too high a value can show artifacts.

## Worked examples in this catalogue

### [image-prompt-direction](https://skillalmanac.com/skills/skill-almanac/image-prompt-direction)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The skill writes image prompts like an art director and lints them for gaps, contradictions and rights problems.

Why it exercises the concept: Guidance scale decides how strongly a generator follows the prompt, so a prompt with gaps or contradictions gives the setting less to work with. The skill improves the prompt. It does not set or measure guidance.

### [imagegen](https://skillalmanac.com/skills/openai/imagegen)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The skill generates or edits raster images such as mockups, textures and illustrations.

Why it exercises the concept: An adjacent example. Whether a given image service exposes a guidance setting depends on that service, and the skill description does not say it does. Check the service's own documentation for the parameter names.

### [room-redesign-brief](https://skillalmanac.com/skills/skill-almanac/room-redesign-brief)

Status: illustrative example from the item's own documentation, not executed for this page.

What you see: The skill writes a room redesign brief, three image-tool prompts and a measure-before-you-buy checklist from measured dimensions and fixed items.

Why it exercises the concept: It produces prompts you would feed to an image tool. Running the same prompt at different guidance settings is a way to see the effect described above. The skill does not run a generator.

## Related terms

- [Diffusion model](https://skillalmanac.com/glossary/diffusion-model.md)
- [Text-to-image](https://skillalmanac.com/glossary/text-to-image.md)
- [Negative prompt](https://skillalmanac.com/glossary/negative-prompt.md)
- [Stable Diffusion](https://skillalmanac.com/glossary/stable-diffusion.md)
- [Temperature (LLM sampling)](https://skillalmanac.com/glossary/temperature-sampling.md)
- [Inpainting](https://skillalmanac.com/glossary/inpainting.md)

## Sources

- [Classifier-Free Diffusion Guidance](https://arxiv.org/abs/2207.12598), arXiv (accessed 2026-11-24)
- [Text-to-image](https://huggingface.co/docs/diffusers/using-diffusers/conditional_image_generation), Hugging Face (Diffusers documentation) (accessed 2026-11-24)

Definitions are written by Skill Almanac from the sources above and checked against them on 2026-11-25. [Glossary index](https://skillalmanac.com/glossary.md).
