Score Matching and Score-Based Generative Models
Score matching is a statistical estimation technique introduced by Aapo Hyvärinen (2005) that enables learning of unnormalized probability models by matching the gradient of the log-density (the score function) rather than the density itself, entirely bypassing intractable partition function computation. Score-based generative models, culminating in the stochastic differential equation (SDE) framework of Song et al. (2020), leverage this principle to define a continuous-time diffusion process that transforms data into noise and learns its time-reversed counterpart for generation. Remarkably, these models are mathematically equivalent to denoising diffusion probabilistic models (DDPMs) yet derive from a completely different theoretical lineage — estimation theory rather than variational inference.
The key insight is that you can train a generative model without ever evaluating a normalized probability: instead of learning , learn — the direction of steepest ascent in log-probability space. This score function is defined even when the normalizing constant is intractable, and once you have it, you can generate samples by simulating Langevin dynamics, which only requires scores. The "aha moment" is that generation is not about memorizing probability mass — it is about learning a vector field that points toward high-density regions, and you can learn this field purely from data using a denoising objective that has no free parameters requiring normalization.
How It Works
Score Functions and Fisher Divergence
Let be the unknown data distribution and a model defined up to a normalizing constant: . The score function of any distribution is defined as:
Explanation: Because does not depend on , its gradient vanishes, so the score of the unnormalized model equals the score of the normalized model — the partition function drops out entirely. Here is a vector field. The natural objective is the Fisher divergence:
Explanation: This measures the average squared distance between the model's score field and the data's score field, analogous to a squared loss in function space over the data manifold.
Hyvärinen's Integration-by-Parts Trick
Since is unknown, Hyvärinen (2005) showed via integration by parts (assuming boundary terms vanish) that equals the explicit score matching objective:
Explanation: The trace term is the sum of all second-order partial derivatives , which penalizes score fields whose divergence differs from the data's, and equals the Fisher divergence up to a constant independent of . This is a complete equality, not an approximation. However, computing requires backpropagation passes through the network, making it in time but with a large constant — and memory for the full Jacobian.
Denoising Score Matching
Vincent (2011) showed a cleaner equivalence. Let be a Gaussian corruption kernel, and the corresponding smoothed distribution. The denoising score matching objective is:
Explanation: The target score is the negative scaled noise added during corruption, so the network learns to predict the noise direction — this is why DDPM's -prediction and score matching are equivalent. This objective is minimized over the same minimizer as with respect to , but requires only a single forward pass per sample.
Noise-Conditional Score Network and NCSN
Song & Ermon (2019) proposed the Noise-Conditional Score Network (NCSN) by training a single network across a geometric sequence of noise levels , minimizing the weighted sum:
Explanation: Weighting by normalizes the magnitude of each score target so that all noise levels contribute comparably to training regardless of scale, and corresponds to the optimal weighting under the Fisher information of the Gaussian kernel. Generation proceeds by annealed Langevin dynamics: starting from noise, run steps of for each from large to small.
SDE Framework (Song et al. 2020)
The SDE generalization unifies all diffusion models. The forward process is an Itô SDE:
Explanation: Here is the drift coefficient (e.g., for the VP-SDE), is the scalar diffusion coefficient, and is standard Brownian motion, so this SDE continuously transforms data into a tractable prior . By Anderson (1982), the time-reversal of this SDE is:
Explanation: The reverse SDE has an additional score-dependent drift that "undoes" the forward diffusion, and since we approximate this score with , a trained score network is all that is needed to run generation. The score network is trained via the continuous-time analog of DSM:
Explanation: Since is a Gaussian with known mean and variance given by the SDE's transition kernel, the conditional score target is computable analytically, making this loss tractable for any noise schedule . The SDE framework encompasses VP-SDE (equivalent to DDPM), VE-SDE (equivalent to NCSN), and sub-VP-SDE as special cases with different drift/diffusion choices.
Probability Flow ODE
Every SDE in the framework has a corresponding probability flow ODE with identical marginals:
Explanation: This deterministic ODE preserves the marginal distributions of the SDE at every while being invertible, enabling exact likelihood computation via the instantaneous change-of-variables formula (the continuous normalizing flow log-likelihood) and accelerated sampling via adaptive ODE solvers.
Hyvärinen is a Finnish statistician and computational neuroscientist at the Gatsby Computational Neuroscience Unit and University of Helsinki, best known for his work on Independent Component Analysis (ICA) and unsupervised learning. His 2005 Journal of Machine Learning Research paper "Estimation of Non-Normalized Statistical Models by Score Matching" introduced the integration-by-parts trick that eliminates the partition function from estimation, directly enabling the score-based generative model revolution fifteen years later. Remarkably, Hyvärinen developed score matching in the context of fitting energy-based models to neural data, with no anticipation of its eventual use in image synthesis — it was a statistical estimation paper repurposed into the foundation of state-of-the-art generative modeling.
Yang Song is a research scientist at OpenAI whose PhD work at Stanford (advised by Stefano Ermon) produced the NCSN framework (NeurIPS 2019) and the landmark SDE paper "Score-Based Generative Modeling through Stochastic Differential Equations" (ICLR 2021 Outstanding Paper), which unified all diffusion models under a single continuous-time framework. His specific contribution was recognizing that Anderson's 1982 reverse-time SDE theorem, combined with the DSM objective trained on the transition kernels of a forward SDE, provides a complete recipe for learning to reverse arbitrary noise processes. Song was the first to demonstrate likelihood computation in diffusion models via the probability flow ODE, achieving competitive bits-per-dimension on CIFAR-10 against flow models.
Pascal Vincent is a professor at Université de Montréal and a member of MILA, closely associated with Yoshua Bengio's group, where he developed denoising autoencoders and the denoising score matching equivalence. His 2011 Neural Computation paper "A Connection Between Score Matching and Denoising Autoencoders" proved that training a denoising autoencoder to remove Gaussian noise is equivalent to score matching on the noise-corrupted distribution — a result that reduced the computational cost of score matching from Jacobian evaluations to a single forward pass. This paper, originally framed in terms of representation learning, turned out to be the algorithmic engine behind DDPM's -prediction objective.
Intuition
Imagine you are lost in a dense fog on a mountainous landscape, where altitude corresponds to log-probability. You cannot see the mountain (you cannot evaluate or normalize ), but you can feel the slope under your feet at any location — that slope is the score function . Score matching trains a neural network to reproduce that slope everywhere in the landscape, purely from the constraint that the network's "felt slope" should match the actual terrain's slope on average over where we stand (data samples). Once the network knows the slope everywhere, we can generate new samples by starting from a random position (pure noise) and following the slope uphill — this is Langevin dynamics. In the SDE framework, the landscape itself changes over time (it gets flatter as we add noise), and the score network learns the slope of this evolving landscape at every moment. The probability flow ODE is then equivalent to a GPS route that navigates deterministically through this time-indexed family of landscapes, arriving at high-altitude regions (likely data points) without any randomness.