Score Based Models
Score-based models learn the score function of the data distribution, which is the gradient of the log-density with respect to the data:
The score points in the direction of increasing data density. Knowing it is sufficient for sampling (via Langevin dynamics) without ever computing the intractable partition function $Z$.
Why the Score?
For an EBM $p_\theta(x) = e^{-E_\theta(x)} / Z(\theta)$:
The partition function $Z(\theta)$ drops out! The score can be learned and used without normalization.
Score Matching
Hyvärinen (2005): minimize the expected squared distance between the model score and the data score:
The data score $\nabla_x \log p_\text{data}(x)$ is unknown, but integration by parts yields an equivalent objective that only requires $p_\text{data}$ samples:
The trace of the Jacobian $\text{tr}(\nabla_x s_\theta(x))$ is expensive to compute exactly; approximated via Hutchinson’s estimator.
Denoising Score Matching
Add Gaussian noise $\tilde{x} = x + \sigma \epsilon$ to perturbed samples and learn the score of the noisy distribution:
The conditional score is available in closed form:
So the network learns to predict $(\tilde{x} - x)/\sigma^2$, equivalent to predicting the noise:
Connection to diffusion: denoising score matching is exactly the training objective of DDPM (noise prediction loss). See Diffusion Models.
Noise Conditional Score Network (NCSN)
Song & Ermon (2019). Train a single network $s_\theta(x, \sigma)$ conditioned on the noise level $\sigma$ to estimate scores at multiple noise scales $\sigma_1 > \sigma_2 > \cdots > \sigma_L$:
Sampling via annealed Langevin dynamics: start at high noise, run Langevin, reduce noise level, repeat.
Stochastic Differential Equations (SDEs)
Song et al. (2021) unifies diffusion models and score-based models under a continuous SDE framework.
Forward SDE (noising process):
- $f$: drift coefficient (deterministic).
- $g$: diffusion coefficient (noise scale).
- $W$: standard Wiener process (Brownian motion).
Reverse SDE (denoising process, Anderson 1982):
This requires the score $\nabla_x \log p_t(x)$ at each time $t$, which is learned by the score network $s_\theta(x, t)$.
DDPM as SDE: corresponds to the Variance Preserving (VP) SDE with specific $f$ and $g$.
SMLD (NCSN) as SDE: corresponds to the Variance Exploding (VE) SDE.
Probability Flow ODE
Every SDE has a corresponding deterministic ODE with the same marginal densities:
Benefits of ODE sampling:
- Deterministic; exact inversion via reverse-time ODE (enables image editing).
- Can use fast ODE solvers (fewer function evaluations than SDE).
- Enables exact likelihood computation via the instantaneous change of variables formula.
DDIM is a special case of the probability flow ODE sampler.
Score Distillation Sampling (SDS)
Uses a pretrained diffusion model’s score as a loss to optimize a separate model (e.g., NeRF, mesh, image):
The diffusion model provides a gradient signal without differentiating through the entire diffusion process. Used in DreamFusion (text-to-3D), Magic3D, and text-guided image editing.
Tweedie’s Formula
The posterior mean estimate of $x_0$ given noisy $x_t$:
Reveals that the score function at noise level $t$ is equivalent to the optimal denoiser. Connects denoising, score matching, and diffusion in a single formula.
Connections Between Model Families
| Framework | Score Perspective |
|---|---|
| DDPM | Predicts noise $\epsilon = -\sigma \cdot s(x_t, t)$ (equivalent to score) |
| NCSN | Directly predicts $\nabla_x \log p_\sigma(x)$ |
| SDE framework | Unifies both via VP/VE SDE |
| Flow matching | Learns the vector field $v_t$ instead of the score; equivalent in limit |
| EBM | Score = negative energy gradient $-\nabla_x E_\theta(x)$ |
The score function is the central quantity connecting diffusion models, EBMs, and normalizing flows.