I know at least five ways to explain diffusion models, and each one sounds like a different idea, which I find strange and wonderful. You can denoise an image a little at a time, or write down a stochastic differential equation. You can regress a velocity field, chase the gradient of a log-density, or solve an ordinary differential equation. You do all this to move probability distributions around (I am underplaying its salience, but hey).
The five objects:
- the distribution \( p_t(x) \): the data, blurred toward noise. The other four views describe this object.
- the vector field \( u_t(x) \): the velocity that flows the distribution along its path.
- the score \( \nabla \log p_t(x) \): the gradient that points back toward the data.
- the SDE \( dx = f\,dt + g\,dW \): the noising as a continuous random process, which you can reverse into a generator.
- the probability-flow ODE: the same path with no randomness (because we like determinism).
The goal
Start from the goal, because you can lose it fast. You have a pile of samples, images say, or molecules, or audio, drawn from some distribution \( p_{\text{data}} \), and you have no formula for it. You would like new samples that look like they came from the same place. A generative model is a sampler you build from a finite pile of examples.
\( p_{\text{data}} \) is defined on a high-dimensional space, and its mass lies on a thin, complicated sliver of that space. The pixel arrangements that happen to look like a face take up a vanishing share of all pixel arrangements. You cannot write that distribution down or integrate against it, and you have no direct way to sample it. You do have many ways to approximate it.
The forward process
You can sample one high-dimensional distribution with your eyes closed: an isotropic Gaussian \( \mathcal{N}(0, I) \). Skip the head-on attack on \( p_{\text{data}} \), build a bridge from it to that Gaussian, and learn to walk the bridge backward. To me that is the main idea, and I write it out in equations below.
You build the bridge out of noise. Take a clean sample \( x_0 \sim p_{\text{data}} \) and corrupt it a little at a time, a touch of Gaussian noise, then a touch more, until you cannot tell the result from a draw of \( \mathcal{N}(0, I) \). Index the corruption by a time \( t \) from \( 0 \) to \( 1 \), and at each \( t \) you get a noisier version \( x_t \):
with two schedules: \( \alpha_t \), the amount of signal that remains, decreasing from \( 1 \) down to \( 0 \), and \( \sigma_t \), the noise mixed in, increasing from \( 0 \) up to \( 1 \). At \( t = 0 \) you have \( x_0 \) untouched; at \( t = 1 \) the signal is gone and only noise remains. (Many people pick \( \alpha_t^2 + \sigma_t^2 = 1 \) so the total variance stays fixed. That choice defines the "variance-preserving" path.) I build each view on this one equation.
View one: the distribution
Stop watching one trajectory and watch the whole population. Fix a time \( t \), push every data point through the same noising, and you get an entire distribution of corrupted samples. That distribution is our first object, \( p_t \):
It interpolates between the two distributions you care about. At \( t = 0 \), \( p_0 = p_{\text{data}} \), the thing you want, and at \( t = 1 \), \( p_1 \approx \mathcal{N}(0, I) \), the thing you can sample. The family \( \{p_t\} \) gives you a slow, continuous transformation from data into noise.
You use Gaussian noise because the conditional law of \( x_t \) given a specific \( x_0 \) comes out as a clean Gaussian,
centered on the shrinking signal \( \alpha_t x_0 \), spread by the growing noise \( \sigma_t \). This has two consequences, and you use both throughout. Any \( x_t \) takes a single shot to sample, with no stepping through time: you jump to whatever \( t \) you want. The conditional's density, gradient and moments all come in closed form, because it is only a Gaussian. (That location-scale move, pushing the randomness into a fixed \( \varepsilon \) so gradients still flow, is the reparameterization trick from the VAE.)
With the conditional in hand, you can picture the marginal \( p_t \) as a mixture: take every data point, replace it with a Gaussian blob centered near it of width \( \sigma_t \), and add the blobs up. At small \( t \) the blobs are tiny and centered near the data, so \( p_t \) looks like the sharp, spiky data distribution. As \( t \) grows the blobs widen and overlap, filling the gaps and smoothing the spikes into hills, until by \( t = 1 \) they merge into one broad mound. You can read the whole forward process as a gradual blur filter.
Most of diffusion modeling is built around the fact that the marginal is not Gaussian. The conditional is a Gaussian, but the marginal \( p_t(x) \) is that mixture over every data point at once:
To evaluate it at a single \( x \) you would integrate against \( p_{\text{data}} \), the one thing you cannot do. Mathematicians call it intractable. You can draw from \( p_t \) for free, by noising a random data point, and you can almost never evaluate \( p_t(x) \). Fitting a normalized model \( q_\theta \approx p_t \) does not help either, because its normalizing constant \( Z_\theta = \int q_\theta \) is the same intractable integral. You pick the wrong target if you chase the density as a number, so in each remaining view you track something attached to \( p_t \) that you can handle with no normalizer.
Easy to sample, hard to evaluate
\( x_t = \alpha_t x_0 + \sigma_t \varepsilon \) gives you a sample of \( p_t \) in one step, while \( p_t(x) = \int \mathcal{N}(x;\, \alpha_t x_0,\, \sigma_t^2 I)\, p_{\text{data}}(x_0)\, dx_0 \) stays out of reach, because you cannot do that integral.
View two: the vector field
Picture the family \( p_t \) as frames of a film: data at the start, noise at the end. You watch a film and you see motion, and motion implies a velocity. The vector field \( u_t(x) \) is that velocity: at each point in space and each instant, its value is the direction and speed of probability mass. Get this field and you generate by following the arrows, a method so easy it embarrasses me.
If you transport mass with velocity \( u_t(x) \), the density can change only in ways that conserve probability. You write that bookkeeping as the continuity equation,
which reads: the rate density piles up at a point equals the net mass flowing in. Any field satisfying this moves \( p_0 \) through the exact frames \( p_t \). Find \( u_t \) and you generate by solving an ordinary differential equation,
starting from a noise sample at \( t = 1 \) and integrating back down to \( t = 0 \). You add no randomness along the way.
You get \( u_t \) with the same trick as everywhere in diffusion: one data point is easy, and the whole distribution is hard. Condition on a clean \( x_0 \). That point lies on the curve \( x_t = \alpha_t x_0 + \sigma_t \varepsilon \) for a frozen \( \varepsilon \), and you read its velocity off the time derivative. Substitute \( \varepsilon = (x - \alpha_t x_0)/\sigma_t \) and you get
That formula is explicit, but it gives you the velocity for one data point, and mass from many points can pass through the same \( x \) at time \( t \). The true field is the posterior average over all of them,
an expectation over \( p(x_0 \mid x_t) \), as intractable as the marginal density itself. You skip computing it and regress against the easy conditional target, because the least-squares solution is that average:
The minimizer of a squared error is a conditional mean, so a network that best fits the easy, per-sample targets predicts their average, and that average is the marginal field \( u_t(x) \) you could not write down. You never form the expectation yourself, because its value is the minimizer of the loss. People call this flow matching. Take the straight-line schedule \( \alpha_t = 1 - t,\, \sigma_t = t \): it gives \( x_t = (1-t)x_0 + t \varepsilon \) and a constant conditional velocity \( u_t(x \mid x_0) = \varepsilon - x_0 \), so each data point drifts in a straight line toward its noise. I find that straight line succulent.
Flow matching
\( \displaystyle \min_\theta\, \mathbb{E}\,\big\| v_\theta(x_t, t) - u_t(x_t \mid x_0) \big\|^2 \;\Rightarrow\; v_\theta(x, t) \to u_t(x) = \mathbb{E}\big[\, u_t(x \mid x_0) \mid x_t = x \,\big]. \)
View three: the score
In view one, you could not compute the normalizing constant. The score does not depend on that constant. Instead of the density, track its log-gradient \( \nabla \log p_t(x) \), a field pointing in the direction of steepest increase in density. Write any density as \( p_t(x) = \tilde p_t(x) / Z_t \), an unnormalized part over a constant. Take the log-gradient (people who train energy-based models will know this one):
\( Z_t \) does not depend on \( x \), so its gradient is zero and the constant drops out, which I still find lovely. The score describes the shape of the density, where it rises and falls, without its absolute scale, and for generation that is plenty: to reach the data you need only the direction! You approximate the rest with a model, since that is what a function learner is good for anyways.
The conditional is Gaussian, so you can write its log-gradient down in one line,
using \( x = \alpha_t x_0 + \sigma_t \varepsilon \). The right-hand side shows that the conditional score is the noise you added, rescaled. Point along \( -\varepsilon \) and you point straight back at the clean sample. I read the score as a denoiser. The marginal score is again a posterior average, and you take it by regression instead of integration:
That loss is denoising score matching, with the same least-squares magic as flow matching: the conditional mean that minimizes it is the marginal score. Spell that mean out and you get Tweedie's formula,
which says the score at \( x \) is a straight line to the expected clean sample given \( x \). You can learn the score, predict the noise or build an optimal denoiser, and you have trained one network under three names. You can also generate from the score alone: Langevin dynamics, \( x \leftarrow x + \tfrac{\eta}{2} \nabla \log p_t(x) + \sqrt{\eta}\, z \), is a gradient ascent step on the log-density plus a little noise for exploration.
Score = denoiser
\( \nabla_x \log p_t(x) = -\dfrac{x - \alpha_t\, \mathbb{E}[x_0 \mid x_t = x]}{\sigma_t^2}. \) You cannot evaluate this density, yet its gradient gives you a rescaled estimate of the noise.
View four: the SDE
Up to now you have treated the path as a sequence of snapshots. Zoom in between the frames and you find a stochastic differential equation: a rule for nudging a sample forward by a deterministic drift plus a continuous drizzle of noise,
where \( f \) is the drift and \( g \) scales \( dW \), an increment of Brownian motion, the continuous-time limit of sprinkling in fresh Gaussian noise at every step. The choice \( f = -\tfrac{1}{2}\beta(t) x \) and \( g = \sqrt{\beta(t)} \) is the continuous limit of the DDPM noising chain, and stepping it forward from \( x_0 \) ends near \( \mathcal{N}(0, I) \). Its distribution at time \( t \) is our \( p_t \), and you link the two with the Fokker-Planck equation,
Anderson proved that the time-reversal of that forward SDE is itself an SDE,
which you integrate from \( t = 1 \) back to \( t = 0 \). The reverse drift is the forward drift, corrected by the score from view three. You still add noise at each step, and the score term adds a drift toward the data at each instant. Drop in a trained \( s_\theta \approx \nabla \log p_t \), start from \( \mathcal{N}(0, I) \), integrate down, and you land with a sample from \( p_0 \) in your hands. The reverse equation differs from the forward one by a single score term, and I like that.
Reverse-time SDE
\( dx = \big[\, f - g^2\, \nabla_x \log p_t(x) \,\big]\, dt + g\, d\bar W. \) Run the noising backward, steer it with the score, and you turn noise back into data.
View five: the probability-flow ODE
You can generate well with the reverse SDE, but you carry randomness the whole way home, a fresh coin flip at each step. Suppose you want the trip deterministic: same starting noise, same final image on each run. Go back to the Fokker-Planck equation and rewrite its diffusion term as a transport term, using \( \nabla^2 p_t = \nabla \cdot (\nabla p_t) \) and the identity \( \nabla p_t = p_t \nabla \log p_t \):
Fold it back in and the whole right-hand side collapses into a single divergence, \( \partial_t p_t = -\nabla \cdot \big( [\, f - \tfrac{1}{2} g^2 \nabla \log p_t \,]\, p_t \big) \). Set that beside the continuity equation from view two, \( \partial_t p_t + \nabla \cdot (p_t u_t) = 0 \). You are looking at the same equation twice, and matching them gives you the velocity:
That equation is the probability-flow ODE, and it is the marginal vector field of view two, written in the language of the score of view three. You close the loop between the views right there, and I cannot get over how tidy that loop is. Set it beside the reverse SDE drift \( f - g^2 \nabla \log p_t \): you have the same ingredients, with the score's coefficient halved. The SDE has twice the score coefficient because its extra score term offsets the noise added at each step. The ODE adds no noise, so half the coefficient is enough.
Strip the randomness and you get three things:
- Deterministic sampling. Fix the initial noise and you fix the output. You get a map from latent to image that is a true function, so interpolation and editing are well defined.
- Exact likelihoods. A deterministic flow is a continuous normalizing flow, so you recover \( \log p_0(x) \) with the instantaneous change-of-variables formula, by integrating the divergence of the field along the trajectory. You can now compute, after the fact and through the ODE, the density I called unreachable in view one.
- Fast solvers. With no Brownian term, you can take large, accurate steps with off-the-shelf ODE integrators. DDIM is one such discretization, and with it a handful of steps can be enough.
Probability-flow ODE
\( \dfrac{dx}{dt} = f - \tfrac{1}{2} g^2\, \nabla_x \log p_t(x). \) Cut the noise from the reverse SDE, halve the score term, and you keep every marginal \( p_t \).
Summary
Line the views up and you see one density \( p_t \) carrying data to noise. The vector field shows that density in motion, and the score shows it through its gradient. The SDE is the random process whose law at every instant is that density. The probability-flow ODE is the same path with the noise deleted, and it equals the vector field written in the score's language. You get four handles on one object. Learn the score by denoising and you can run any of the generators, because you build the field, the reverse SDE and the ODE from it.
Schrödinger stayed fascinated with particles. In another article I will explore his bridges (Schrödinger bridges).