On Calibrating Diffusion Probabilistic Models

Tianyu Pang, Cheng Lu, Chao Du, Min Lin, Shuicheng Yan, Zhijie Deng

TL;DR

Diffusion Probabilistic Models (DPMs) often suffer from a systematic bias where their predicted scores do not average to zero, contrary to what theoretical "true" scores should do. This paper introduces a simple, one-time calibration trick—subtracting the model's expected prediction from its output—that consistently improves sample quality and model likelihood for any pretrained diffusion model without requiring full retraining.

The Problem: Mis-calibrated Scores

In the theoretical framework of diffusion models, the "data score" (the gradient of the log-density of the data at any given noise level) should have an expected value of exactly zero. However, the authors observe that in practice, pretrained models—whether they predict scores, noise, or data—exhibit a non-zero expectation.

This "mis-calibration" stems from two primary sources:

  1. Dataset Bias: Training on a finite dataset means the model learns the score of the empirical distribution, which doesn't perfectly match the true underlying continuous distribution.
  2. Sub-optimal Learning: Architectural limitations, finite capacity, or incomplete training can leave the model with a systematic "mean" error.

This bias leads to lower model likelihoods and can cause qualitative issues, such as "ambiguous" generated images that seem to blend multiple semantic categories (e.g., a hybrid horse-dog).

The Solution: Martingales and Calibration

At the heart of this paper is a novel theoretical observation: the stochastic process of the scaled data score acts as a martingale with respect to the reverse-time diffusion process. This mathematical property rigorously implies that the expected value of the score at any timestep must be zero.

Based on this foundation, the authors propose a straightforward calibration trick:

$$\hat{s}_\theta^t(x_t) = s_\theta^t(x_t) - \mathbb{E}_{q_t(x_t)}[s_\theta^t(x_t)]$$

Where $s_\theta^t(x_t)$ is the original model's output and $\hat{s}_\theta^t(x_t)$ is the calibrated version. To implement this expectation subtraction in practice, they suggest three approaches:

  • Post-training Estimation: Calculate the expectation using a small batch of training data via Monte Carlo estimation.
  • Generated Data Estimation: If training data is unavailable, use samples generated by the model itself to estimate the bias.
  • Amortized Computation: Train a tiny auxiliary network (e.g., a 3-layer MLP) during the original training phase to "record" and predict these expectations dynamically.
Time-dependent values of the bias across different datasets. The second row shows how calibration reduces the score-matching objective.

Key Insights and Results

The researchers validated their method across several standard benchmarks, including CIFAR-10, CelebA ($64 \times 64$), AFHQv2 ($64 \times 64$), FFHQ ($64 \times 64$), and ImageNet ($64 \times 64$).

  • The "Ghost" in the Machine: By visualizing the expected bias (the term being subtracted), the authors found it isn't just random noise. On facial datasets like CelebA and FFHQ, the bias term actually resembles a faint, blurry "mean face". This suggests the model has a baseline bias it applies to every generation, which calibration successfully removes.
  • Likelihood vs. Quality: Calibration provably reduces the score-matching loss and increases the lower bound of model likelihood. While the authors note that higher likelihood doesn't always guarantee a better FID score, empirical results show it usually helps significantly.
  • Sample Quality (FID): The calibration method yielded consistent quantitative improvements. On CIFAR-10, using a 3-order DPM-Solver with 20 evaluations, the FID improved from 3.89 to 3.32. On CelebA, it improved from 2.84 to 2.33.
  • Visual Clarity: Calibration helps eliminate ambiguous artifacts. By centering the score field, it prevents the model from generating confusing semantic blends.
Comparison of generated images on CIFAR-10. The calibrated versions (bottom) show fewer ambiguous semantic blends compared to the baseline (top).

Limitations and Future Work

While highly effective for unconditional models, the authors note a few limitations:

  • Conditional Models: For text-to-image models (like Stable Diffusion), post-training calibration is difficult because the bias likely depends on the specific text prompt. The authors suggest that "dynamic recording" during training is the most viable path forward for these large-scale conditional models.
  • Data Requirements: To get a robust estimate of the bias post-training, you still need access to a significant portion of the training data (e.g., at least 20,000 images for CIFAR-10) or you must generate a large number of samples.
  • Theoretical Bounds: The paper proves that calibration improves the upper bound of the KL divergence, but it doesn't strictly guarantee the KL divergence itself will always decrease, even though empirical evidence strongly supports the improvement.

Summary updated

BibTeX
@inproceedings{pang2023calibrating,
  author = {Tianyu Pang and Cheng Lu and Chao Du and Min Lin and Shuicheng YAN and Zhijie Deng},
  title = {{On Calibrating Diffusion Probabilistic Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=XcQzXeF7fX},
}
Figure