A diffusion model never learns to draw. It learns to remove a little noise, and generation is denoising repeated from pure static. Destroy a spiral with real math, then watch it come back.
Sign in to save progress
The Core Idea: Generate by Learning to Denoise
The forward process destroys structure: over T = 50 steps it mixes the data with Gaussian noise until nothing recognizable remains. A neural network then learns the reverse: given a noisy sample and the timestep, undo a little of the damage. Chain those small denoising steps together, starting from pure noise, and you have a generator. The slider below runs the exact closed-form forward process on a real point cloud, so every number you see is computed live.
Forward Process: Destroying the Spiral
300 deterministic points, T = 50 timesteps
Closed-Form Forward Process
x_t = sqrt(alphaBar_t) * x0 + sqrt(1 - alphaBar_t) * eps alphaBar_0 = 1.0000 x_0 = 1.000 * x0 + 0.000 * eps
alphaBar_t is the cumulative product of the per-step alphas under the cosine schedule. Any noisy x_t can be sampled in one jump from x0, no need to loop through every step during training.
What You Are Seeing
Each point keeps the same eps at every timestep, so dragging the slider moves every point along its own straight line between its data position and its noise position. At t = 50 the spiral is gone: the cloud is indistinguishable from an isotropic Gaussian. That destruction is exactly what the reverse process must undo.
Noise Schedule Intuition
The schedule decides how fast alphaBar_t falls from 1 (all signal) to near 0 (all noise). Both curves below are computed from the actual schedules used by the slider above.
A schedule that destroys structure too quickly wastes most of its timesteps on pure noise, where there is nothing left to learn. One that is too slow wastes steps on nearly clean data, where the denoising task is trivial.
The cosine schedule was proposed exactly because the linear one spends too many late steps at very low alphaBar. You can verify that on the chart: the dashed linear curve dives early, while the cosine curve spreads the destruction more evenly across all 50 steps. Flip the toggle above and watch how the same slider position produces a different amount of noise.
Reverse Process: Denoising Step by Step
Watch the trajectory from pure noise (t = 50) back to data (t = 0)
Honest Caveat
This panel uses the true data as a perfect denoiser to show the trajectory shape; real models ESTIMATE the noise with a trained network. We kept x0, so we can walk each point back along its exact forward path. A real diffusion model never sees x0 at sampling time: it must predict the noise at every step and can only approximate this trajectory.
The Training Objective
loss = MSE(eps, eps_hat) where eps_hat = network(x_t, t)
The network is trained to predict eps from (x_t, t). That is the whole objective: a plain regression on the noise. Sampling then repeatedly subtracts the predicted noise, moving from t = 50 down to t = 0.
Why Diffusion Beat GANs for Images
Three qualitative reasons. Training is stable: the loss is a plain regression on noise, not the fragile minimax game GANs play. There is no mode collapse: the objective covers every training example, so the model cannot win by producing only a few crowd-pleasers. And the objective is likelihood-adjacent: it optimizes a bound related to how probable the data is under the model, which gives a smoother, more predictable training signal.
Latent Diffusion
Stable Diffusion does not denoise pixels directly. An autoencoder first compresses the image into a much smaller latent space, the diffusion process runs there, and a decoder maps the result back to pixels. Working in a compressed representation makes each denoising step far cheaper. Those learned compressed representations are close cousins of embeddings.
Text Conditioning
In one line: guidance steers denoising toward the prompt. A text encoder turns your words into vectors, and every reverse step is nudged toward samples that match them. For how models represent text in the first place, see What is an LLM.