The Classifier-Free Guidance (CFG) Scale is a hyperparameter that amplifies the influence of a conditioning signal, such as a text prompt, during the iterative denoising process of a diffusion model. By adjusting a scalar value, typically between 1 and 20, it controls the strength of the guidance signal, steering the model away from unconditional generation and toward outputs that more closely adhere to the provided description. Higher values increase fidelity to the prompt but can reduce image diversity and quality.
Glossary
Classifier-Free Guidance (CFG) Scale

What is Classifier-Free Guidance (CFG) Scale?
The Classifier-Free Guidance Scale is a critical hyperparameter in conditional diffusion models that controls the trade-off between sample diversity and prompt fidelity.
Technically, the scale modifies the predicted noise at each denoising step by interpolating between a conditional prediction (guided by the prompt) and an unconditional prediction. This mechanism, introduced as an alternative to classifier guidance, eliminates the need for a separate trained classifier. Optimal CFG scale values are model-specific and must be tuned empirically, as excessively high values can lead to over-saturated colors, artifacts, or compromised compositional integrity in the generated image.
Key Characteristics of the CFG Scale
The Classifier-Free Guidance (CFG) Scale is a critical hyperparameter in conditional diffusion models that controls the trade-off between sample quality and prompt adherence. Understanding its mechanics is essential for generating coherent, high-fidelity images.
Definition and Core Function
The Classifier-Free Guidance (CFG) Scale is a hyperparameter, typically denoted as a numerical value (e.g., 7.5), that amplifies the influence of a conditional input (like a text prompt) during the image denoising process. It works by extrapolating between a conditional and an unconditional noise prediction, steering the generation toward the prompt. A higher scale value increases adherence to the text description but can reduce image diversity and naturalness.
The Guidance Trade-Off
Adjusting the CFG scale involves a fundamental trade-off:
- Low Scale (e.g., 1.0-4.0): Produces diverse, creative, and often more aesthetically "natural" images, but with weaker prompt adherence. The model has more freedom, which can lead to hallucination of unrelated elements.
- High Scale (e.g., 10.0-20.0): Strongly enforces the prompt, improving fidelity and detail accuracy. However, it can cause oversaturated colors, unnatural contrast, and a reduction in sample variety, making outputs look "overcooked" or artificial.
Mathematical Mechanism
The CFG algorithm modifies the predicted noise at each denoising step. The final noise prediction is calculated as:
ε_guided = ε_uncond + guidance_scale * (ε_cond - ε_uncond)
Where:
ε_condis the noise predicted using the text prompt.ε_uncondis the noise predicted for an empty or null prompt.guidance_scaleis the CFG scale parameter. This extrapolation pushes the generation away from the unconditional prediction and toward the conditional one, effectively amplifying the signal from the text.
Typical Operating Range and Defaults
While model-dependent, common effective ranges are:
- Stable Diffusion 1.x/2.x: A scale of 7.5 is a standard default, balancing detail and coherence. Values from 5.0 to 15.0 are commonly explored.
- Very High Scales (>15.0): Often used for architectural or technical concepts requiring extreme precision, but risk artifacts.
- Very Low Scales (<2.0): Used for more abstract, artistic, or dream-like generations where prompt is a loose inspiration. Optimal scale is found empirically per model checkpoint and desired output style.
Interaction with Negative Prompting
The CFG scale also amplifies the effect of negative prompts. A negative prompt provides ε_neg_cond, a noise prediction for what to avoid. The guided prediction becomes:
ε_guided = ε_uncond + guidance_scale * (ε_cond - ε_neg_cond)
A high CFG scale therefore strongly steers the generation away from the negative concepts (e.g., "blurry, deformed hands") as well as toward the positive prompt. This makes prompt engineering more precise but also more sensitive.
Impact on Inference and Samplers
The CFG scale directly affects computational cost and sampler behavior:
- Increased Compute: Calculating both conditional and unconditional predictions doubles the forward passes per denoising step.
- Sampler Sensitivity: Different samplers (e.g., DDIM, DPM++ 2M) have varying stability across CFG scales. Some samplers may become numerically unstable at very high scales.
- Denoising Steps Relationship: The effect of the scale is cumulative over denoising steps. A high scale over many steps exerts maximal guidance but can also compound errors if the prompt is ambiguous.
Effects of Different CFG Scale Values
This table compares the qualitative and quantitative effects of adjusting the Classifier-Free Guidance (CFG) scale, a critical hyperparameter for controlling text adherence in diffusion models like Stable Diffusion.
| Characteristic | Low Scale (1.0 - 4.0) | Moderate Scale (5.0 - 9.0) | High Scale (10.0 - 20.0) | Very High Scale (>20.0) |
|---|---|---|---|---|
Primary Effect | Weak conditioning | Balanced fidelity & creativity | Strong prompt adherence | Over-conditioning |
Image Fidelity to Prompt | Low. Images are creative but often ignore specific prompt details. | High. Good balance of following the prompt while maintaining natural image quality. | Very High. Strict adherence to the textual description. | Extreme. May over-interpret or distort elements to fit the prompt. |
Visual Artifacts & Quality | Minimal artifacts, natural-looking outputs. | Few artifacts, high overall quality. | Increased risk of oversaturation, contrast issues, and minor distortions. | High probability of severe artifacts, color bleaching, and distorted anatomy. |
Sample Diversity | High. Model explores latent space more freely. | Moderate. Guided exploration within prompt constraints. | Low. Converges to similar outputs for a given prompt. | Very Low. Outputs become deterministic and repetitive. |
Recommended Use Case | Abstract art, mood-based generation, maximizing creativity. | General-purpose generation, photorealistic outputs, balanced control. | Technical illustrations, precise concept rendering, strict briefs. | Seldom recommended; can be used experimentally for extreme stylization. |
Inference Time Impact | No impact. CFG scale is a weighting, not a step count. | No impact. CFG scale is a weighting, not a step count. | No impact. CFG scale is a weighting, not a step count. | No impact. CFG scale is a weighting, not a step count. |
Typical Default Value | 7.5 (Common in Stable Diffusion interfaces) |
Frequently Asked Questions
The Classifier-Free Guidance (CFG) scale is a critical hyperparameter in text-to-image diffusion models like Stable Diffusion. It controls the trade-off between image quality and adherence to the text prompt. This FAQ addresses common technical questions about its function, tuning, and impact on generation.
The Classifier-Free Guidance (CFG) scale is a hyperparameter that controls the strength of conditioning in a conditional diffusion model, amplifying the influence of a text prompt on the generated image to improve fidelity and adherence to the description.
It operates by computing a weighted combination of a conditional prediction (guided by the prompt) and an unconditional prediction (ignoring the prompt). The formula is: guided_prediction = unconditional_prediction + cfg_scale * (conditional_prediction - unconditional_prediction). A higher CFG scale pushes the generation further away from the unconditional 'average' image and closer to the specific concept described in the prompt.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The Classifier-Free Guidance (CFG) Scale operates within a broader ecosystem of concepts and components essential for modern text-to-image synthesis. These related terms define the models, mechanisms, and evaluation metrics that interact with CFG to control and assess the generation process.
Conditional Generation
Conditional generation is the core paradigm where a model produces data explicitly guided by an external input. In text-to-image models, this condition is the text prompt.
- The CFG Scale is a hyperparameter that specifically controls the strength of this conditioning.
- Without conditioning, the model generates an image from the unconditional distribution of its training data.
- High CFG values strongly amplify the signal from the conditional (text) pathway, forcing the output to adhere more closely to the prompt.
Negative Prompt
A negative prompt is a textual description of elements to avoid during image generation. It provides negative conditioning to steer the model away from unwanted content.
- It functions by leveraging the same dual-path mechanism as CFG. The model estimates noise for both the main prompt and the negative prompt.
- The final generation direction is adjusted away from the concepts described in the negative prompt.
- Using a negative prompt (e.g., "blurry, deformed hands") alongside a high CFG Scale can be a powerful technique for refining output quality and avoiding common artifacts.
Cross-Attention
Cross-attention is the neural mechanism that enables conditional generation by fusing text guidance into the image generation process.
- In models like Stable Diffusion, the U-Net uses cross-attention layers where image features (keys/values) "attend to" the text embeddings (queries) from the prompt.
- The CFG Scale directly modulates the output of these cross-attention layers. A higher scale amplifies the influence of the text-derived attention maps on the denoising process.
- This makes cross-attention the architectural site where the CFG hyperparameter exerts its effect.
Scheduler (Noise Schedule)
A scheduler in a diffusion model defines the noise schedule—the plan for how much noise is added or removed at each step of the forward and reverse processes.
- While the CFG Scale controls what the model generates (prompt adherence), the scheduler controls how it generates (the iterative denoising trajectory).
- Different schedulers (e.g., DDIM, DPM-Solver, LMS) have different stability and speed characteristics.
- The interaction between the CFG scale and the scheduler is important; some schedulers are more robust to very high guidance scales than others.
CLIP Score
The CLIP Score is an automatic evaluation metric that quantifies the semantic alignment between a generated image and its text prompt.
- It uses OpenAI's CLIP model to encode both the image and the text into a shared embedding space, then calculates their cosine similarity.
- This metric is directly correlated with the CFG Scale. As the CFG scale increases, the CLIP score typically increases, indicating better prompt-image alignment.
- It is a key quantitative tool for validating the intended effect of adjusting the CFG hyperparameter.
Latent Diffusion Model
A Latent Diffusion Model performs the iterative denoising process in a compressed, lower-dimensional latent space (via a VAE), not on pixel data. This is the architecture used by Stable Diffusion.
- Classifier-Free Guidance is applied within this latent space. The U-Net predicts noise in the latent representation, guided by the text condition.
- The efficiency of operating in latent space makes the iterative CFG process computationally feasible for high-resolution image generation.
- The CFG scale's effect on image diversity and quality is fundamentally tied to the statistics and structure of this learned latent space.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us