Rectified Diffusion Guidance for Conditional Generation

Mengfei Xia, Nan Xue, Yujun Shen, Ran Yi, Tieliang Gong, Yong-Jin Liu

Abstract

Classifier-Free Guidance (CFG) is the standard technique for steering diffusion models toward specific prompts, yet it suffers from a fundamental theoretical flaw known as "expectation shift." This shift causes the mean of the generated distribution to drift away from the ground truth as guidance strength increases, leading to artifacts and over-saturation. We introduce ReCFG (Rectified Classifier-Free Guidance), a post-hoc method that relaxes traditional coefficient constraints to align denoising with diffusion theory. ReCFG requires no retraining and consistently improves image-text alignment and visual quality across state-of-the-art models like Stable Diffusion 3 (SD3) and EDM2.

The Problem: Expectation Shift in CFG

Diffusion models typically use CFG to interpolate between a conditional score (prompt-specific) and an unconditional score using a guidance weight $\gamma$. However, the standard formulation—where coefficients are forced to sum to one—violates the underlying mathematical requirements of diffusion processes.

As guidance strength increases to improve prompt faithfulness, the "peak" of the generated distribution physically shifts away from the true conditional distribution. This results in a trade-off where higher guidance improves alignment but introduces significant distributional bias and visual degradation.

Expectation shift in standard CFG (red) compared to the ground truth (blue) and the rectified ReCFG (green) across various guidance strengths.

Methodology: Rectifying the Score Function

ReCFG addresses this by decoupling the guidance coefficients. Instead of the rigid $\gamma$ and $(1-\gamma)$ pairing, ReCFG uses independent coefficients $\gamma_1$ and $\gamma_0$ designed to "annihilate" the expectation shift.

Key Components of ReCFG:

  1. Closed-Form Rectification: The authors derived a mathematical condition to ensure the score function expectation remains zero, providing a closed-form solution for the optimal $\gamma_0$ relative to a chosen $\gamma_1$.
  2. Post-hoc Lookup Tables: Since the ideal correction depends on the specific prompt and timestep, the method utilizes pre-computed lookup tables of expectation ratios derived from observed data.
  3. Pixel-wise Guidance: A critical insight of this work is that the necessary correction is not uniform across an image. ReCFG applies rectified coefficients at a pixel-specific level during sampling, allowing for more granular control over the denoising process.
Visualization of pixel-wise expectation ratios across different diffusion architectures (LDM, EDM2, SD3) and sampling timesteps.

Experimental Results

The authors evaluated ReCFG across prominent benchmarks including ImageNet (for class-conditioned models like EDM2 and DiT) and CC12M (for text-conditioned models like SD3).

  • Stable Diffusion 3 (SD3): On the CC12M dataset, ReCFG improved the CLIP Score (alignment) and significantly reduced the FID (image quality) from 1105.51 to 1010.14 at a guidance scale of 7.5.
  • EDM2: On ImageNet 512x512, ReCFG reduced FID from 2.29 to 2.23 while maintaining precision and recall.
  • Visual Fidelity: Qualitative analysis shows that ReCFG effectively eliminates artifacts common in high-guidance EDM2 samples and produces more detailed, faithful textures in SD3 compared to vanilla CFG.

Conclusion and Future Work

ReCFG demonstrates that fixing a fundamental theoretical flaw in guidance can yield immediate empirical gains without the need for expensive retraining. While the current implementation relies on pre-computed lookup tables, future work may involve training small "predictor networks" to estimate rectified coefficients on the fly for open-vocabulary text-to-image tasks. Additionally, exploring variance control alongside mean rectification remains a promising avenue for further improving diffusion sampling.

Summary updated

BibTeX
@inproceedings{xia2025rectified,
  author = {Mengfei Xia and Nan Xue and Yujun Shen and Ran Yi and Tieliang Gong and Yong-Jin Liu},
  title = {{Rectified Diffusion Guidance for Conditional Generation}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.01248},
}
Figure