Language Diffusion Models · Interactive
Autoregressive models (like GPT) write left-to-right, one token at a time. Diffusion models do something stranger: they start from pure noise and denoise the whole sentence at once, over many small steps. Scroll to build the whole idea from the ground up — drag, toggle, and play at every step.
Try it: drag the noise slider, then press Play to watch the sentence denoise. Switch the kernel to see the two kinds of noise, and flip reveal order to feel why confident-first beats random. This animates the ideas — it is not the trained model. space plays/pauses.
01 — the whole idea
Every diffusion model — for images or text — is the same loop: break it, then learn to fix it. Here it is end to end.
A real sentence from the data — this is the target. The model never sees it at generation time; it has to invent one like it.
Corrupt letters, more and more, until nothing is left. Corruption needs no learning — it's a coin flip per letter. Fully-noised text carries zero information about the original, which is why generation can start from it.
Show a transformer the corrupted text and ask it to guess the blanks. Measure how wrong (cross-entropy) and nudge. Because it reads the whole sentence at once (left and right context), filling a blank in the middle is as easy as at the edge.
Start from pure noise and denoise step by step, revealing the sentence as you go. No left-to-right order — the whole sequence sharpens in parallel. That's the playground above, and the practical win: you choose how many steps to spend.
02 — what the noise is
"Noise" is just a rule for what a letter turns into next step. Write that rule as a little table of probabilities — the transition matrix $Q_t$ — and you've chosen your diffusion (Lesson 2). Pick a kernel and drag the corruption rate:
rows = from · columns = to · brighter = more likely
03 — the sampling trick
When you denoise, you decide which blanks to fill each step. Fill the ones you're sure about first, and they pin down the rest. Here's the same sentence, both ways, at the same halfway point:
Structure locks in early — words are already legible. Stays coherent with far fewer steps.
Reveals are scattered — no word is whole yet, so later guesses have less to go on. Needs many more steps to recover.
04 — the self-correction trick
Confidence-first has a catch: the instant you reveal a token, it's frozen. One early bad draw becomes a permanent typo — every later step just builds around the mistake. Remasking fixes this: if the model stops supporting a token it committed, un-mask it (↺) and let a later, better-informed step re-fill it. Watch the same run, both ways:
Position 5 was revealed as b early and locked. The run finishes fluent but wrong — "bat", forever.
Same bad draw — but a later step un-commits it (↺) and re-fills it with the context now in place. Ends correct.
And confidence isn't the only way to pick which blank to fill next. Lesson 6 races the whole decoding zoo — different scores for "which token is the model surest about":
05 — the real thing
Everything above was an animation. This is not. Press train and a real (tiny) masked-diffusion model — a small neural net with hand-written backprop, no libraries — learns to denoise 16 toy sentences right here on your machine. Watch the loss fall, then generate from the model you just trained.
MASKED CROSS-ENTROPY LOSS · lower = better at filling in the blanks
06 — how it learns
Strip away the theory and training is almost embarrassingly simple:
Blank some letters → ask the model to guess them → measure how wrong (cross-entropy) → nudge the weights. Repeat a few thousand times.
That's it. The intimidating "diffusion math" (the ELBO) mostly just tells you how much to weight each noise level — noisier examples vs. nearly-clean ones. Each lesson in the course is a different, verified answer to "what exactly should the network predict, and how do we weight it?"