Demystifying Classifier-Free Guidance for Auto-Regressive Image Generation
Organizations: Yale University · National University of Singapore · Cisco Foundation AI
Abstract
Classifier-free guidance (CFG) has been widely adopted in autoregressive (AR) models for high-quality image generation. Despite its strong empirical performance, its mechanism in AR models remains unclear. This paper demystifies the mechanism of CFG through both empirical and theoretical studies. By examining the top-ranked semantics of different components in CFG, we show that texture information is primarily encoded in the difference between the conditional and unconditional logits, whereas both logits share previous-token repetition as their leading semantics. This strong repetition semantics obscures the desired texture information, causing greedy decoding from the conditional logits alone to produce nearly pure-color images. Through a training-dynamics analysis of shallow transformers, we prove that this shared repetition semantics does not arise from limitations or failures of pretraining, but instead originates from the texture sparsity of images. We further show that CFG improves generation quality by rectifying this repetition bias during inference. Motivated by the shared semantics between conditional and unconditional logits, we propose Attention Weight Reuse (AttnReuse), which reuses intermediate attention computations from the conditional-logit forward pass to accelerate the unconditional-logit computation. AttnReuse reduces about of attention computation with little performance degradation across different models.
Figures & tables
| Model | ||
|---|---|---|
| Emu3 | 0.5168 | 0.5479 |
| LlamaGen | 0.7457 | 0.7517 |
| Lumina-mGPT | 0.6804 | 0.7333 |
| Type | Model | Global | Entity | Attribute | Relation | Other | Overall | Attn. FLOPs |
|---|---|---|---|---|---|---|---|---|
| Diffusion | SD3-Medium | 87.9 | 91.0 | 88.8 | 80.7 | 88.7 | 84.1 | 100% |
| + AttnReuse | 90.1 | 86.5 | 88.8 | 86.4 | 85.7 | 82.5 | 87% | |
| AR ( ) | Emu3 | 87.5 | 83.5 | 84.9 | 85.0 | 85.3 | 76.7 | 100% |
| + AttnReuse | 84.3 | 83.5 | 83.4 | 83.5 | 82.9 | 74.7 | 75% | |
| Janus-Pro 7B | 79.3 | 90.2 | 89.0 | 89.7 | 84.5 | 83.3 | 100% | |
| + AttnReuse | 79.2 | 87.5 | 87.6 | 89.3 | 88.6 | 82.3 | 75% |
Appendix figures & tables8 assets
Supplementary material from the paper’s appendix.
Appendix
| Model | Type | CFG | AttnReuse Layers | Timesteps | |
|---|---|---|---|---|---|
| Emu3 | AR | 8–23 | – | ||
| Janus-Pro 7B | AR | 5.0 | 8–23 | – | |
| Lumina-GPT 2.0 | AR | 8–23 | – | ||
| Stable Diffusion 3 | Diffusion | – | 7.0 | 9–17 | Last |
Classifier-Free Guidance
Classifier-free guidance (CFG) steers conditional generation by extrapolating between conditional and unconditional model predictions during sampling.
See all 73 papers