Basis Lab

Answers · How models work

Why is the model's noise prediction really the score of the noised image distribution?

In shortThe network's noise prediction, divided by the noise level and given a minus sign, is the direction that makes a noised image more plausible.

The prediction is the score because the forward process is Gaussian, so the noise and the gradient of the log density are related by one fixed division and one sign. If the predicted noise is εθ(x,t)\varepsilon_\theta(x,t) and the noise level is 1−αˉt\sqrt{1-\bar\alpha_t}, the score is −εθ(x,t)/1−αˉt-\varepsilon_\theta(x,t)/\sqrt{1-\bar\alpha_t}.

FIG 1The identity
the distribution of real pictures blurred by the noise belonging to time t
the direction from this point that most increases plausibility, with length saying how steeply
the trained prediction of the noise present in this input
the noise level at this time, which is the only thing converting between the two
The equality is exact for an optimal noise predictor. The minus sign says that removing the predicted noise and moving uphill in log density are the same direction.

Where the divisor comes from

Take one clean image x0x_0 and the usual variance-preserving step. The noised point is xt=αˉtx0+1−αˉtϵx_t=\sqrt{\bar\alpha_t}x_0+\sqrt{1-\bar\alpha_t}\epsilon with ϵ∼N(0,I)\epsilon\sim N(0,I). Conditioned on x0x_0, the density of xtx_t is Gaussian with mean αˉtx0\sqrt{\bar\alpha_t}x_0 and variance (1−αˉt)(1-\bar\alpha_t) in every direction. Differentiating its log with respect to xtx_t gives minus the displacement from that mean, divided by the variance. But the noise that was added is exactly ϵ=(xt−αˉtx0)/1−αˉt\epsilon=(x_t-\sqrt{\bar\alpha_t}x_0)/\sqrt{1-\bar\alpha_t}, so the same derivative is −ϵ/1−αˉt-\epsilon/\sqrt{1-\bar\alpha_t}. For a whole distribution rather than one image, the optimal network output is the conditional mean of ϵ\epsilon given xtx_t, and the identity carries through with that mean.

pt(xt∣x0)=N ⁣(αˉtx0, (1−αˉt)I),∇xtlog⁡pt(xt∣x0)=−xt−αˉtx01−αˉt=−ϵ1−αˉt.p_t(x_t\mid x_0)=N\!\left(\sqrt{\bar\alpha_t}x_0,\,(1-\bar\alpha_t)I\right),\qquad \nabla_{x_t}\log p_t(x_t\mid x_0)=-\frac{x_t-\sqrt{\bar\alpha_t}x_0}{1-\bar\alpha_t}=-\frac{\epsilon}{\sqrt{1-\bar\alpha_t}}.

The missing divisor

The common slip is to treat the predicted noise as the score itself, up to a sign. The divisor is not bookkeeping: it changes with the noise level and it changes the size of the field. Suppose the network predicts the same value ϵθ=0.3\epsilon_\theta=0.3 at two times. At αˉt=0.96\bar\alpha_t=0.96 the divisor is 0.04=0.2\sqrt{0.04}=0.2, so the score is −0.3/0.2=−1.5-0.3/0.2=-1.5. At αˉt=0.36\bar\alpha_t=0.36 the divisor is 0.64=0.8\sqrt{0.64}=0.8, so the score is −0.3/0.8=−0.375-0.3/0.8=-0.375. The same prediction is four times stronger as a gradient at the lower noise level. Forgetting the divisor erases the fact that the field is steep near the data and shallow far from it, and that is exactly the variation the sampler uses as it reduces the noise.

FIG 2
alpha barnoise levelpredicted noisescore
0.960.20.3-1.5
0.750.50.3-0.6
0.360.80.3-0.375

Why the blur is not cosmetic

A clean photograph is a point in a space of about three million dimensions, and real photographs fill a region so thin that the density is zero almost everywhere else. Where the density is zero its gradient is zero too, and zero is not a small amount of guidance: it is no direction at all. Blurring with noise spreads the density over the space, so a point away from the data still has a slope telling it which way the data lies. The price is that the blurred density no longer distinguishes the fine detail of the original, which is why the noise level is reduced as the walk proceeds. The log also removes the normalising constant: multiplying a density by any constant leaves its log gradient unchanged, so the one part of the density that cannot be computed from samples never appears in the score.

Where the identity stops

The identity is exact only under the assumptions that produced it. At αˉt=1\bar\alpha_t=1 the divisor is zero and there is no score to speak of, which is why the path never quite reaches a clean image in the training schedule. If the forward process is not the variance-preserving Gaussian one, the divisor is replaced by whatever the corresponding noise level is, and the sign and scale must be rederived. If the network predicts x0x_0 or a velocity rather than the noise, the right hand side must be converted before it is a score. And for a network that has not converged, the equality is an approximation: the optimal predictor gives the score, the trained one gives an estimate of it.

Once the output is read as a field, the denoising loop is only one way to follow it. The field says which way to move and how strongly at every point; a sampler can follow it with Euler steps, with a higher-order method, or with anything else that advances along a direction. That is why the same trained network can be used in samplers that look nothing like the original loop: they are changing the numerical method, not the quantity the network computes.

Worth keeping

  • A perfect noise predictor and the gradient of the log density differ only by division by the noise level and a sign.
  • Blurring with noise is what gives the density a usable slope away from the data.
  • The normalising constant of the density never enters the score, which is why the score can be learned from samples.

Where this goes next

This question is one step of How Noise Becomes a Picture, a course that works through its subject from the beginning. The page that teaches this part of it is What the Prediction Really Is, and it reads the whole way through whether or not you have an account.

What an account changes is the practice: problems standing under every idea, marked with a reason rather than a tick, in a copy of the course that is yours.

Read that pageThe whole course

Other questions people ask about this

  1. Why does diffusion add Gaussian noise instead of any random corruption?Diffusion adds Gaussian noise because Gaussian errors combine exactly: each step keeps the spread fixed and gives a closed-form noisy picture at any later step, which makes the reverse step learnable.
  2. How do you turn the predicted noise into the mean of the previous image?Subtract a small scheduled fraction of the predicted noise from the current image, then rescale to undo the forward step's shrinkage.
  3. Why does the forward noising process have to be a Markov chain?The forward process is made memoryless so that each step is a fixed random rule and any later state can be computed straight from the original picture.
  4. What does classifier-free guidance actually add together, and why does it make the prompt stronger?It adds the unconditional prediction to several times the gap between the conditional and unconditional predictions, pushing past the conditional answer so the prompt is obeyed more strictly.
  5. Why does the model get stuck repeating the same sentence over and over?The model is not stuck in a memory loop: once it has written a phrase, that phrase is in its context and makes writing it again more likely, so a decoder that always picks the top word cannot leave.
  6. Why does the same request cost more tokens in some languages than in others?A token is learned from a corpus, so a language that was rare in the training text is split into many more pieces for the same meaning, and the price multiplier follows.

Read alongside