Advanced Mathematics

Diffusion and Generative Models

Models that learn to produce new samples like their training data; diffusion models do it by learning to remove noise step by step.

Needs a step first: 50

A generative model learns a probability distribution over data so it can draw new examples; a diffusion model fixes a forward process that gradually adds Gaussian noise until an image is pure noise: x⃗t=αˉt x⃗0+1−αˉt ε⃗\vec x_t = \sqrt{\bar\alpha_t}\,\vec x_0 + \sqrt{1 - \bar\alpha_t}\,\vec\varepsilon. A network is trained, with a simple squared-error loss, to predict the noise ε⃗\vec\varepsilon that was added. To generate, start from random noise and repeatedly subtract the predicted noise, a little at a time, until a picture appears. The maths combines the multivariate normal, Bayesian reasoning about the reverse step, and KL divergence; other generative models, including language models, sample one token at a time instead.

Where it shows up: Diffusion is the method behind most image, video and audio generators.

How to hold it: In your head

See a diffusion model as learning to predict the noise that was added, so generating means starting from pure noise and removing a little at a time.

What knowing it looks like

  • Compute a noised sample x⃗t\vec x_t from x⃗0\vec x_0, αˉt\bar\alpha_t and a noise draw, and recover x⃗0\vec x_0 from a perfect noise prediction.
  • Write the training loss of a denoising diffusion model and say what the network's input and target are.
  • Explain step by step how sampling turns pure noise into an image.

Test yourself

In one dimension, a data point is x0=2x_0 = 2. At step tt, αˉt=0.64\bar\alpha_t = 0.64, and the noise drawn is ε=−0.5\varepsilon = -0.5. Compute xtx_t. What is the distribution of xtx_t given x0=2x_0 = 2? If the network predicts ε^=−0.5\hat\varepsilon = -0.5 exactly, how do you recover x0x_0 from xtx_t?
Show the worked answer
0.64=0.8\sqrt{0.64} = 0.8 and 1−0.64=0.6\sqrt{1 - 0.64} = 0.6, so xt=0.8⋅2+0.6⋅(−0.5)=1.6−0.3=1.3x_t = 0.8\cdot2 + 0.6\cdot(-0.5) = 1.6 - 0.3 = 1.3. Given x0=2x_0 = 2, xt∼N(1.6, 0.36)x_t \sim \mathcal N(1.6,\ 0.36): mean 0.8x00.8x_0, variance 1−αˉt1 - \bar\alpha_t. Solving for x0x_0: x0=(xt−0.6ε^)/0.8=(1.3+0.3)/0.8=2x_0 = (x_t - 0.6\hat\varepsilon)/0.8 = (1.3 + 0.3)/0.8 = 2. The training loss is (ε−ε^)2(\varepsilon - \hat\varepsilon)^2, here 00.

Needs a step first: 50

Learn it with an AI

Copy this prompt into any AI assistant. It will take you through step by step at your level and finish with the test above.

Be my maths tutor. I'm learning "Diffusion and Generative Models" (Frontier tier): Models that learn to produce new samples like their training data; diffusion models do it by learning to remove noise step by step.
I already know: Training Deep Networks, The Multivariate Normal, Bayesian Inference.
Teach it Socratically: first ask what I already know; then explain the core idea with one concrete example and why it's true; then give me three problems, one at a time, easy to hard. Wait for my answer, check every step, and point out mistakes without giving the answer away.
Finish by testing me with this: In one dimension, a data point is $x_0 = 2$. At step $t$, $\bar\alpha_t = 0.64$, and the noise drawn is $\varepsilon = -0.5$. Compute $x_t$. What is the distribution of $x_t$ given $x_0 = 2$? If the network predicts $\hat\varepsilon = -0.5$ exactly, how do you recover $x_0$ from $x_t$?
Use LaTeX for formulas. When you say where it's used later (machine learning, quantum mechanics), be specific.

On the way to

Recommended