Diffusion Models

Turn data into noise one small step at a time, learn to undo each step, and you can turn fresh noise into new data. Watch data fan out into a Gaussian, see why the endpoint of a Riemann sum suddenly matters, drag a set across an empirical distribution, and find out why a perfectly trained model would only copy its training set while a smoothed one creates points between them.

Built from the notes and meetings of the Random Training Points project, which studies Z. Chen, “On the Interpolation Effect of Score Smoothing in Diffusion Models” (ICLR 2026). Background follows J. Ho, A. Jain and P. Abbeel, “Denoising Diffusion Probabilistic Models” (NeurIPS 2020), and Y. Song, J. Sohl-Dickstein, D. P. Kingma, A. Kumar, S. Ermon and B. Poole, “Score-Based Generative Modeling through Stochastic Differential Equations” (ICLR 2021). The weight-decay result is from P. Savarese, I. Evron, D. Soudry and N. Srebro (COLT 2019). Results from the paper are labelled with its numbering; the questions and examples are written for this page. For how this subject connects to the others, see the roadmap.

InteractiveHo–Jain–Abbeel (2020); Song et al. (2021)

From data to noise and back

Sampling a new, realistic image directly is hard; sampling Gaussian noise is easy. A diffusion model connects the two. It adds noise to real data, step by step, until nothing but noise is left, and learns to undo each step. To generate, it draws fresh noise and runs the learned undoing backwards.

The idea

Write p0 for the unknown distribution of the data (all plausible cat pictures, say) and x0∼p0 for one clean example. We want a procedure that produces new samples from p0, not copies of the training images.

Forward process: adding noise. Fix small numbers β1,β2,… in (0,1), the noise schedule. At each step, shrink the current image a little and add a little fresh Gaussian noise:
xk=1−βkxk−1+βkεk,εk∼N(0,I) independent.
No learning happens here: it is a fixed random recipe.
Why the end result is Gaussian. Unroll the recursion. Every step leaves its own noise term εj, shrunk by all the steps after it, but independent Gaussians add up to a single Gaussian, so with α¯k=∏j≤k(1−βj) all k of them together are equivalent to one:
xk=dα¯kx0+1−α¯kε,ε∼N(0,I),
where =d means “has the same distribution as”.
Show the computation

After two steps,

x2=1−β2(1−β1x0+β1ε1)+β2ε2=(1−β2)(1−β1)x0+(1−β2)β1ε1+β2ε2.

The noise from step 1 has been shrunk once more by step 2. Continuing the same way, each step multiplies everything so far by 1−β and adds new noise:

xk=α¯kx0+∑j=1kβjajεj,aj=∏i=j+1k(1−βi)(ak=1).

The εj are independent standard Gaussians, so the sum is Gaussian with mean 0 and variance ∑jβjaj. Since aj−1=(1−βj)aj, each term is a difference:

βjaj=aj−(1−βj)aj=aj−aj−1,so∑j=1kβjaj=ak−a0=1−α¯k.

A mean-zero Gaussian with variance 1−α¯k is exactly the law of 1−α¯kε. Check with two steps: (1−β2)β1+β2=1−(1−β1)(1−β2).

Each step multiplies the influence of x0 by 1−β<1, so α¯k→0, while the noise piles up to variance 1−α¯k→1. Whatever the image was, xk ends up distributed approximately as N(0,I). The one-line form is also what training uses: to get a noisy xk you don't run k steps, you draw one ε.

The factor 1−β is chosen so the variance stays put: if xk−1 has variance 1, so does xk, because (1−β)+β=1. Practical schedules increase βk from about 10−4 to 0.02 over a thousand steps.

Reverse process: generating. Draw xK∼N(0,I), which is easy, and apply a learned denoiser step by step back to k=0. The randomness of the generated image comes from the starting noise (and, in some samplers, from noise injected along the way); its plausibility comes from what the denoiser learned.

Training data. Take a clean image x0, pick a step k, draw noise, and form xk by the formula above. The pair (noisy xk, clean x0 or the noise ε) is one training example for the denoiser. The same image is reused many times, each time with a fresh step and fresh noise: that is the standard training loop, and it is what lets the denoiser learn what to do at every noise level.

Aside: the continuous-time version. With many tiny steps, 1−β≈1−β/2, and the difference xk−xk−1≈−12βxk−1+βεk becomes the stochastic differential equation
dXt=−12β(t)Xtdt+β(t)dWt,
a deterministic pull toward 0 plus Brownian noise (Song et al. 2021). It is to the recursion what gradient flow is to gradient descent. Chen's paper, used in the last module, takes the simplest version, dXt=dWt, so Xt=X0+Wt: no shrinking, just noise of variance t.

Explore

Data
40 examples being noised, step by step. They start on the data and fan out into noise.
4,000 noised examples at step k. exact density, a mixture of N(α¯ky,1−α¯k) N(0,1), the target.

Worked example

Constant schedule β=0.1. Data: x0=±1 with probability 12 each, so x0 has mean 0 and variance 1.

  1. After 10 steps, how much of x0 is left, and how much noise?

    α¯10=0.910≈0.349, so x10=0.59x0+0.81ε. The two clean values have become two overlapping bumps centred at ±0.59, each with standard deviation 0.81.

  2. After 50 steps?

    α¯50=0.950≈0.005: x50≈0.07x0+ε. The data contribute a shift of ±0.07 to a unit-variance Gaussian: essentially pure noise.

  3. Check that the variance never changed.

    Var(xk)=α¯kVar(x0)+(1−α¯k)=1 for every k. The process trades signal for noise without changing the overall scale.

Check your understanding

Which part of a diffusion model is learned?

  1. The noising process.That is a fixed recipe: shrink and add Gaussian noise.
  2. The denoiser, trained on pairs of (noisy, clean) examples made by the noising process.
The forward process manufactures unlimited training pairs from each clean image. The network learns the reverse.

Why multiply by 1−β before adding βε, instead of just adding noise?

  1. It keeps the variance at 1, so the endpoint is the fixed law N(0,I) rather than noise of ever-growing size.
  2. Without it the result wouldn't be random.It would still be random, just with variance growing with k.
Just adding noise (Xt=X0+Wt) also works, with variance Var(X0)+t; generation then starts from N(0,TI). That is the “variance-exploding” version used in Chen's paper; the recursion here is “variance-preserving”.

Two different starting noise vectors usually generate two different images. Where does that variety come from?

  1. From the random starting noise (and any noise added during sampling); the denoiser maps each one to a plausible image.
  2. From randomness inside the trained network.A trained network is a fixed function.
With the deterministic (probability-flow) sampler of the later modules, the map from starting noise to output is a fixed, one-to-one function. Whether its outputs are new or copies of the training images is the question of the last module.

Practice

Unroll the recursionInduction

Show that xk has the same distribution as α¯kx0+1−α¯kε with ε∼N(0,I), by induction on k (an alternative to the telescoping sum).

Solution

If it holds for k−1, then xk=1−βk(α¯k−1x0+1−α¯k−1ε′)+βkεk. The two noise terms are independent Gaussians with variances (1−βk)(1−α¯k−1) and βk, which add to 1−α¯k. A sum of independent Gaussians is Gaussian, so they combine into 1−α¯kε for a single standard Gaussian ε: an equality in distribution, which is all that matters for the law of xk.

From steps to an SDEHeuristic limit

Let βk=β(tk)h for small step h. Show that xk−xk−1≈−12β(t)xh+β(t)ΔW, with ΔW∼N(0,h).

Solution

1−βh=1−12βh+O(h2), and βhε=β(hε) with hε∼N(0,h), a Brownian increment. Note the noise is of size h, much bigger than the drift's h: that is why the next module is needed.

InteractiveBackground for Song et al. (2021)

Integrating against noise

An SDE dX=bdt+σdW means Xt=X0+∫0tbds+∫0tσdWs. The first integral is ordinary calculus. The second sums a coefficient times random increments of Brownian motion, and one surprise is all you need to know about it: where you evaluate the coefficient in each piece changes the answer.

The idea

Brownian motion. W0=0, continuous paths, independent increments, and Wt−Ws∼N(0,t−s). An increment over a step h has size about h, not h, which is why the paths are continuous but nowhere differentiable.

Riemann sums, endpoints and all. For an ordinary smooth function, ∫0tfdg is the limit of ∑if(si)(g(ti+1)−g(ti)), and it doesn't matter whether si is the left endpoint, the right endpoint or the midpoint of each piece: all three give the same limit. Try the same with ∫0tWdW:

∑iWti+1ΔWi⏟right−∑iWtiΔWi⏟left=∑i(ΔWi)2 ⟶ t.

The sum of squared increments does not vanish: each (ΔWi)2 has mean equal to the length of its piece, and they add up to t (the quadratic variation).

Show the computation

Split [0,t] into pieces of length hi, so ΔWi∼N(0,hi), independent. Then E[(ΔWi)2]=hi and Var[(ΔWi)2]=2hi2 (for a Gaussian, EZ4=3σ4). Hence

E[∑i(ΔWi)2]=∑ihi=t,Var[∑i(ΔWi)2]=2∑ihi2≤2tmaxihi→0.

A sum whose mean is t and whose variance goes to 0 converges to t. For a differentiable g, |Δgi|≤Chi, so ∑(Δgi)2≤C2tmaxihi→0 instead.

For a smooth path the same sum is of order h⋅t→0, which is why ordinary calculus never notices.

Three answers. As the pieces shrink,
∑iWtiΔWi→12(Wt2−t),∑iWti+Wti+12ΔWi=12Wt2,∑iWti+1ΔWi→12(Wt2+t).
The left-endpoint choice is the Itô integral, the standard one: it only uses information available at the start of each piece, and it has mean zero. The averaged choice is the Stratonovich integral, which obeys the ordinary chain rule. Ordinary calculus would say 12Wt2 for all three.

Explore

Integrate against
The path W on [0,1]. Each piece shows its left-endpoint and right-endpoint values; the sums use these times the increment ΔW across the piece.

Check your understanding

Why does the endpoint matter for ∫WdW but not for ∫fdg with smooth f,g?

  1. The difference is ∑(ΔW)2→t; for smooth paths ∑(Δg)2→0.
  2. Brownian motion is discontinuous.Its paths are continuous, just very rough.
Increments of size h have squares of size h, and there are t/h of them. For a differentiable path the squares are of size h2.

The left-endpoint (Itô) sum has mean zero. Why?

  1. Wti is independent of the next increment ΔWi, which has mean zero.
  2. Because W has mean zero.The right-endpoint sum also uses W, and its mean is t/2.
E[WtiΔWi]=E[Wti]E[ΔWi]=0. With the right endpoint, E[Wti+1ΔWi]=E[(ΔWi)2]=ti+1−ti: it peeks at the increment it multiplies.

Practice

The telescoping trickWhere ½(W² − t) comes from

Show Wti+12−Wti2=2WtiΔWi+(ΔWi)2 and deduce the Itô answer.

Solution

Expand (Wti+ΔWi)2. Summing over i, the left side telescopes to Wt2, so ∑WtiΔWi=12(Wt2−∑(ΔWi)2)→12(Wt2−t).

InteractiveSong et al. (2021); Chen (2026), §2

Empirical distributions and the score

A model never sees the data distribution, only finitely many examples. To say what it is trained on, we need the empirical distribution of those examples, which is easy to understand as a function on sets and awkward as a density. Noise turns it into something smooth, and the denoiser learns its score.

The idea

A distribution is a function on sets. A probability distribution P assigns to each (measurable) set A the number P(A)∈[0,1]: how likely the random value is to land in A. For a coin, P({H})=P({T})=12, P({H,T})=1, P(∅)=0. A density, when there is one, is just a convenient way to compute P(A)=∫Af.
Empirical distribution. Given samples y1,…,yn, the empirical distribution assigns to each set the fraction of samples inside it:
Pn(A)=#{k:yk∈A}n.
It estimates the whole distribution, set by set, not just a single number such as the mean. Its only possible values are 0,1n,…,1.

Why densities are awkward here. Pn puts mass 1n on each sample point and none anywhere else, so its “density” is 1n∑kδ(x−yk), a sum of Dirac deltas: infinitely tall spikes of zero width and area 1n. As a function of sets it is perfectly simple; as a density it is barely a function. Adding noise fixes this: replace each spike by a Gaussian bump of width t,

pt(n)(x)=1n∑k=1nφt(x−yk),φt(u)=e−u2/2t2πt,

which is exactly the law of yK+Wt for a uniformly chosen training point yK (the forward process Xt=X0+Wt started from the training set). As t→0 the bumps sharpen back into spikes.

Score. The score of a density p is s(x)=∇xlog⁡p(x). The logarithm undoes the exponential in Gaussian densities: for N(μ,t), s(x)=−(x−μ)/t, an arrow pointing back to the centre, stronger for smaller t. Generation runs dx/dt=−12st(x) backwards in time (the probability-flow ODE), so the score is all a sampler needs.
The empirical score (Tweedie's formula). For the mixture pt(n),
∇log⁡pt(n)(x)=x^t(x)−xt,x^t(x)=∑kwk(x)yk,wk(x)=φt(x−yk)∑jφt(x−yj).
x^t(x) is the best guess of the clean training point given the noisy x: an average of the training points weighted by how likely each was to produce x. The score points from x to that guess.
Show the computation

The score is ∇log⁡p=∇p/p. Each bump is φt(x−yk)=ce−|x−yk|2/2t, whose gradient is −x−yktφt(x−yk). So

∇log⁡pt(n)(x)=∑kφt(x−yk)yk−xt∑jφt(x−yj)=1t(∑kwk(x)yk−x∑kwk(x))=x^t(x)−xt,

using ∑kwk=1. The factor 1n and the constant c cancel between numerator and denominator.

Training minimizes tE‖sθ(X)−∇log⁡pt(n)(X)‖2, whose exact minimizer is this empirical score.

Explore

Top: the true density p0 and n samples drawn from it (ticks). Drag the ends of the shaded set A. Bottom: the noised empirical density pt(n), one Gaussian bump per sample, and its score ∇log⁡pt(n), which points to the nearest training points.

Worked example

Two training points, y=±1, so pt(n)=12φt(x+1)+12φt(x−1).

  1. Compute x^t(x).

    x^t=φt(x−1)−φt(x+1)φt(x−1)+φt(x+1). Since (x∓1)2=x2∓2x+1, the common factors cancel and x^t=ex/t−e−x/tex/t+e−x/t=tanh⁡(x/t).

  2. Evaluate the score at x=0.5, t=0.1.

    tanh⁡(5)≈0.9999, so the score is (0.9999−0.5)/0.1≈5.0: a strong push toward +1.

  3. What does the score look like as t→0?

    tanh⁡(x/t)→sgn(x), so the score approaches (sgn(x)−x)/t: pointing to the nearest training point, with a jump of size 2/t at the midpoint 0. That jump is the subject of the next module.

Check your understanding

You have 4 samples. Which values can P4(A) take?

  1. 0,14,12,34,1
  2. Any number in [0,1].It counts samples: only multiples of 14.
The empirical distribution only ever asks “how many of my samples are in this set?”. Compare the empirical mean, which estimates one number; the empirical distribution estimates every probability at once.

For a single point A={y1} and a continuous p0, how do P(A) and Pn(A) compare?

  1. P(A)=0 but Pn(A)=1n.
  2. They are equal.A continuous law gives each single point probability zero.
The empirical distribution concentrates on the samples, so on tiny sets it is completely wrong, while on large sets it is close (by the law of large numbers). Smoothing with noise is a way of not trusting it at small scales.

Why do diffusion models learn the score ∇log⁡p rather than the density p?

  1. The sampler only needs the score, and the score doesn't depend on the unknown normalizing constant of p.
  2. The score is always smaller than the density.Not true, and not the reason.
∇log⁡(cp)=∇log⁡p for any constant c. And the probability-flow ODE dx/dt=−12∇log⁡pt is driven by the score alone.
InteractiveChen, “On the Interpolation Effect of Score Smoothing in Diffusion Models” (ICLR 2026)

Memorization, and how smoothing creates new points

If a diffusion model learned the empirical score perfectly, it would only ever reproduce its training data. Yet trained models do produce new samples. Chen's paper explains one mechanism in a setting simple enough to solve exactly: the network can't afford the empirical score's sharp jumps, and the smoothed version it learns instead sends some noise to points between the training data.

The idea

The perfect fit is useless. Plug the exact empirical score into the backward flow dxt=−12∇log⁡pt(n)(xt)dt. It exactly reverses the noising of the training set, so the output at t=0 is the empirical distribution 1n∑kδyk: copies of the training points. This is memorization. A model that generates anything new must be using an imperfect fit, and the question is which imperfection, and why it helps.

Two points. Take y=±1. For small t the empirical score is close to the piecewise linear score s¯t(x)=(sgn(x)−x)/t, which jumps by 2/t at the midpoint.

What a regularized network prefers (Savarese et al. 2019; Chen eq. (10)). For a wide two-layer ReLU network on scalar inputs, training with weight decay amounts, in function space, to penalizing the total curvature R[f]=∫|f″(x)|dx: for a piecewise linear f, the sum of the sizes of its slope changes. A jump costs infinitely much.
The smoothed score (Chen eq. (9)). For δ∈(0,1], keep s¯t within δ of each training point and replace the jump by a straight line:
s^t,δ(x)={−(x+1)/t,x≤δ−1,δ1−δ⋅xt,|x|<1−δ,−(x−1)/t,x≥1−δ.
Its total curvature is 2/((1−δ)t), finite. With δt=κt, its score-matching loss stays at a fixed small level as t→0, and among all functions that fit the empirical score that well it is within a factor 1+8ϵ of the least curved (Chen Prop. 1, for κ large enough).
The flow, solved exactly (Chen Prop. 3). With δt=κt, the backward flow is piecewise linear in t and splits the (x,t) plane into three regions. Starting at time t from x:
  • if x≤δt−1 (region A) or x≥1−δt (region B), it ends exactly on the training point −1 or +1;
  • if |x|<1−δt (region C), it ends at x/(1−δt), strictly between them.
So the output is a mixture: atoms at the training points (what is left of memorization) plus a smooth density on [−1,1], the noised distribution stretched by 1/(1−δt).

How much is new? Only the Gaussian tails that reach region C become new samples. For small starting time this fraction is about Φ¯(κ)=P(Z>κ): 11.5% for κ=1.2 (the value in the paper's experiment), 2.8% for κ=1.91. So “interpolation” here means a non-zero smooth part, not mostly new samples. (This count is from the project notes, not the paper.)

Not early stopping. Stopping the exact flow before t=0 leaves Gaussian blur around each training point, spreading in every direction. Smoothing lands samples exactly on the segment between the points. In higher dimensions the smoothed score smooths only along the direction joining the points, so samples collapse onto the line through the data but spread along it (Chen Prop. 5): it recovers the structure without memorizing the points.

Explore

Score used for generating
Backward trajectories in the (x,t) plane, from t0 down to 0. region C, where trajectories land between the points; elsewhere they land on ±1.
Where 4,000 samples from pt0(n) end up at t=0. Bars at ±1: copies of the training points. In between: new points.
The two scores at t0, scaled by t0. empirical (exact tanh form, and its jump in the limit) smoothed, a straight line through the middle.

Worked example

κ=1, start at t0=0.25, so δt0=κt0=0.5.

  1. What is region C at t0?

    |x|<1−δt0=0.5: the interval (−0.5,0.5).

  2. Where do the points x=0.3 and x=0.8 end up?

    0.3 is in C: it ends at 0.3/(1−0.5)=0.6, a new point. 0.8 is in region B: it ends exactly on the training point +1.

  3. About what fraction of the samples are new?

    A sample from N(−1,0.25) lands in region C when x>−0.5: more than 0.5=κt0, one standard deviation, to the right of −1. That has probability Φ¯(1)≈15.9% (minus a tiny chance of overshooting past +0.5), and the same holds for +1. The figure\'s stats show the simulated fraction.

Check your understanding

Why does the exact empirical score only reproduce the training points?

  1. It is the exact score of the noised training set, so running the flow backward exactly undoes the noising of that set.
  2. Because the network is too small.The exact empirical score is what a perfect fit would give, however large the network.
Perfect training means memorization. Whatever produces new samples has to be a systematic deviation from the training objective's minimizer.

Why must the smoothing window shrink like t?

  1. The noised data live within about t of each training point, so only a window of that size keeps the fitting loss at a fixed level.
  2. To make the curvature finite.Any δ<1 makes it finite.
With a fixed δ, the smoothed score would be wrong right where the data are as t→0, and the loss would blow up. With δt=κt, rescaling by t leaves a loss depending only on κ.

How is smoothing different from simply stopping the exact flow early?

  1. Early stopping leaves blur around each point in every direction; smoothing puts samples exactly on the segment between the points.
  2. There is no difference.Compare the supports: a neighbourhood of the points versus the segment joining them.
In higher dimensions this is the point: smoothing recovers the line (or manifold) the data lie on, while early stopping produces fuzz off it.

Practice

The middle regionSolve the ODE

In region C the backward flow is dxds=−12⋅δs(1−δs)sx with δs=κs. Check that xs=c(1−κs) solves it, and deduce where a point starting at x at time t ends.

Solution

ddslog⁡(1−κs)=−κ2s(1−κs)=−12δs(1−δs)s. With xt=x, c=x/(1−δt), and at s=0, x0=c=x/(1−δt). It is a straight line in (x,s) coordinates, as in the figure.

Counting the new massGaussian tails

Show that for small t0 the probability that a sample from pt0(n) lands in region C is about Φ¯(κ).

Solution

A sample from N(−1,t0) is in C when x>δt0−1, i.e. (x+1)/t0>κ: probability Φ¯(κ), minus the exponentially small chance of overshooting past 1−δt0. The same holds for +1, and the mixture weights 12 average to Φ¯(κ). With n equally spaced points the same count gives about 2Φ¯(κ)(n−1)/n, since the two end points have only one inner side.