Guidance Scale Hyperparameter
What You'll Learn
You'll learn how the guidance scale controls the balance between how closely samples follow conditioning (like text prompts) versus how diverse and creative they are.
The Core Idea
In classifier-free guidance, you've seen how we combine conditional and unconditional predictions. The guidance scale (often denoted as w or s) is the hyperparameter that controls how much we push toward the conditional prediction:
guided_prediction = unconditional + w × (conditional - unconditional)
When w = 0, you get pure unconditional generation (maximum diversity, ignores prompts). When w > 1, you amplify the difference between conditional and unconditional predictions, making outputs follow the condition more faithfully—but at the cost of diversity.
The Trade-off
Think of guidance scale like a "creativity vs obedience" dial:
-
Low guidance scale (w ≈ 1-3): More diverse, creative outputs. The model takes liberties with your prompt. Images might be varied but less aligned with exact wording.
-
High guidance scale (w ≈ 7-15): Very faithful to prompts. Strong adherence to conditioning, but samples become less diverse and may look oversaturated or artificial.
-
Very high (w > 20): Often produces artifacts and unrealistic results from over-correction.
In practice, w = 7-8 is common for text-to-image models like Stable Diffusion, balancing prompt adherence with natural-looking results.
Why It Matters
The guidance scale lets users control generation behavior without retraining. Artists might use lower values for creative exploration, while applications needing precise outputs (like "generate a red car") use higher values.
Key Takeaway: The guidance scale hyperparameter controls the strength of conditioning—higher values mean closer adherence to prompts but reduced sample diversity, while lower values allow more creative freedom.