Skip to content

CFG Scale

You might say

“What does the CFG Scale slider actually do? When I crank it up to 12 my picture turns crispy and burnt with weird color artifacts, but at 3 it ignores my prompt.”

Describe it to an agent this way — far better than saying “make it nicer”.
Also called
Guidance scaleClassifier-free guidance scalePrompt weight scaleGuidance weight

PROMPT ENGINEERING

cfg-scale · Guidance strength

Hold the conditional difference fixed and compare the guidance term at three CFG settings. Longer arrows mean more amplification of that difference, not higher image quality.

Guided prediction = unconditional prediction + CFG × (conditional prediction − unconditional prediction)

Calculation sketch: hold the difference in parentheses fixed and compare the added guidance term. Arrows represent neither the full prediction nor generated images.

Relative guidance length / shared scale

CFG 3.5

The guidance term is 3.5 times the fixed conditional difference.

CFG 5.0

The guidance term is 5.0 times the fixed conditional difference.

CFG 10.0

The guidance term is 10.0 times the fixed conditional difference.

Demo sequence / not generation time

  1. Inspect 3.5
  2. Add 5.0
  3. Keep all comparisons
All arrows share an origin and a scale. Each endpoint matches its CFG value in the table; this diagram verifies only how the coefficient scales the guidance term.
Parameters and visual checks
QuantityValueUnitExplanation / visual evidence
CFG coefficient3.5DimensionlessThe guidance term is 3.5 times the fixed conditional difference.
CFG coefficient5.0DimensionlessThe guidance term is 5.0 times the fixed conditional difference.
CFG coefficient10.0DimensionlessThe guidance term is 10.0 times the fixed conditional difference.

Not Sampling Steps: CFG changes guidance strength within each prediction; sampling steps change the number of denoising iterations.

The CFG Scale (Classifier-Free Guidance Scale) is the primary numerical hyperparameter controlling how strictly a diffusion model adheres to your text prompt versus exploring unconditional creative entropy.

Every generative image and video creator encounters this slider. Dialing it too low produces hazy, unresponsive generations that ignore crucial keywords; cranking it too high results in the notorious “deep-fried” artifact — extreme contrast, garish oversaturation, and harsh geometric halos.

Why it works

The mechanism of CFG scale is governed by the foundational Classifier-Free Guidance formulation established by Jonathan Ho and Tim Salimans:

ϵ~θ(xt,c)=ϵθ(xt,∅)+s⋅(ϵθ(xt,c)−ϵθ(xt,∅))\tilde{\epsilon}_\theta(x_t, c) = \epsilon_\theta(x_t, \varnothing) + s \cdot (\epsilon_\theta(x_t, c) - \epsilon_\theta(x_t, \varnothing))

Where ϵθ(xt,∅)\epsilon_\theta(x_t, \varnothing) is the unconditional noise prediction (using an empty null token), ϵθ(xt,c)\epsilon_\theta(x_t, c) is the text-conditioned prediction, and ss is the CFG scale scalar multiplier:

  1. At s=1.0s = 1.0 (Zero Guidance Boost): The model samples directly from standard conditional probability. Prompt following is loose, and the model relies heavily on the stochastic biases of its training weights.
  2. At s∈[4.5,7.5]s \in [4.5, 7.5] (The Production Sweet Spot): The difference vector (ϵθ(xt,c)−ϵθ(xt,∅))(\epsilon_\theta(x_t, c) - \epsilon_\theta(x_t, \varnothing)) is amplified cleanly. The latent trajectory steers decisively toward the intended semantic mode without exceeding the standard deviation boundaries of the VAE latent distribution. Skin tones remain organic and lighting stays balanced.
  3. At s>9.0s > 9.0 (Latent Overdrive & Saturation): The difference vector is magnified so aggressively that latent tensor values exceed the valid dynamic range expected by the VAE decoder. When converted back into RGB pixel space, high values are brutally clamped at maximum luminance, manifesting as blown highlights, neon color casts, and fried textures.

When paired with a structured negative-prompt, the unconditional baseline ϵθ(xt,∅)\epsilon_\theta(x_t, \varnothing) is replaced by the negative conditioning vector ϵθ(xt,cneg)\epsilon_\theta(x_t, c_{neg}), allowing the scale parameter ss to simultaneously push away from defects while pulling toward positive prompt attributes.

When to use it

  • Dialing into the sweet spot (5.0–7.0): Standard baseline for photorealistic cinematic generation across Stable Diffusion, Flux, and Kling AI.
  • Complex multi-clause prompt enforcement (7.5–9.0): Forcing adherence when specifying intricate blocking, specific wardrobe, and lighting angles from prompt-structure.
  • Loosening constraints for abstract concepts (3.0–4.0): Encouraging organic randomness in fantasy landscapes, cloud formations, or surreal dreamscapes.
  • Taming stylized LoRAs (3.5–5.0): Lowering CFG scale prevents external LoRAs from burning into the base model weights.

Pitfalls

  • The “crank it to 12” trap: Believing that higher numbers yield “better quality.” High CFG values do not increase fidelity; they merely amplify contrast and destroy subtle gradients. Keep generations within 4.5–7.5.
  • Compounding high CFG with negative prompt dumps: Stacking a 10.0 CFG scale with a 50-word negative prompt dump triggers extreme vector repulsion, causing distorted anatomy and plastic faces. Use minimal, targeted negative tokens as taught in negative-prompt.
  • Overlooking model architectural differences: Flux.1 and SD3 use flow-matching architectures with Guidance Distillation, often preferring a much lower CFG scale (2.5–3.5), whereas SD 1.5/SDXL thrives around 7.0. Check model specifications.
  • Color banding post-processing: High CFG values collapse subtle color transitions into ugly 8-bit stepped bands. If grading footage downstream in a color-grading-pass, shoot with moderate CFG to preserve maximal 10-bit dynamic range.
Engine / Architecture Recommended CFG Range Default Value Notes
Stable Diffusion XL 5.0 – 7.5 7.0 Pristine photorealism; above 8.5 risks skin over-sharpening
Flux.1 (Dev / Schnell) 2.5 – 3.5 3.5 Distilled guidance; higher values quickly burn pixels
Kling AI / Runway Gen-3 4.0 – 6.5 5.0 Smooth temporal vectors; high CFG causes severe video jitter

Model-specific prompts

Stable Diffusion XL (CFG 6.5)

Cinematic portrait of an architect in a concrete studio, natural diffuse morning light, 85mm lens f/2.8, realistic skin pores, photorealistic, 4k --cfg 6.5 --steps 30.

Kling AI (Relevance / CFG 0.5 – equivalent to 5.0)

A lone detective walks through a foggy alley, high temporal consistency, naturalistic color saturation, 35mm film grain, prompt weight balanced at 0.5, no blown highlights.

Flux.1 Dev (Guidance 3.0)

Masterpiece photograph, elegant woman in a tailored wool coat standing in a European courtyard, soft overcast sky, hyper-realistic, muted natural palette --guidance 3.0.

CFG scale directly governs the intensity of repulsion in your negative-prompt and controls the syntactic parsing of your prompt-structure. When generating assets intended for a multi-shot color-grading-pass, moderate CFG scales preserve the dynamic range necessary for high-end color grading.

Sources

  1. Jonathan Ho & Tim Salimans, Classifier-Free Diffusion Guidance, NeurIPS 2021 Workshop — https://arxiv.org/abs/2207.12598
  2. Robin Rombach et al., High-Resolution Image Synthesis with Latent Diffusion Models, CVPR 2022 — https://arxiv.org/abs/2112.10752
  3. Stability AI, Stable Diffusion Parameter Reference Guidance Scale Dynamics

Quick check

Pick the answer you think fits best and see the explanation instantly. Your answers stay in this browser.

Pick one — it grades instantly

What mathematical artifact occurs in latent diffusion models when CFG scale is pushed beyond 10.0?

Selecting grades it — no submit