classifier-free guidance
Classifier-free guidance controls generation strength by mixing conditional and unconditional predictions. **Problem**: Sampling from conditional diffusion models can produce outputs that don't strongly match the condition (text prompt). **Solution**: Amplify difference between conditional and unconditional predictions. Steer more strongly toward condition. **Formula**: ε̃ = ε_unconditional + w × (ε_conditional - ε_unconditional), where w is guidance scale (typically 7-15). Higher w = stronger conditioning but less diversity. **Training**: Drop conditioning randomly during training (10-20% of time), model learns both conditional and unconditional generation. **Inference**: Run model twice per step (with and without condition), combine predictions using guidance formula. **Effect of guidance scale**: w=1 is pure conditional, w>1 amplifies conditioning, high w can cause artifacts/saturation. **Trade-offs**: Higher guidance = better prompt following but reduced diversity, may cause over-saturation. **Alternative**: Classifier guidance uses separate classifier gradients (requires training classifier). CFG is simpler; no classifier needed. **Standard practice**: Default in DALL-E, Stable Diffusion, Midjourney. Essential for controllable high-quality generation.