Language Diffusion Models · Interactive

Watch text dissolve
and re-form.

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.

noise  t = 1.00 step 0 / 0 pure noise
Kernel — what the noise is
Reveal order — how it unmasks
Noise level  ( 0 = clean · 1 = pure noise )
speed
Your sentence
◂ the reverse trajectory · noise → clean · click a frame to jump
revealed (true letter) [MASK] — absorbing random letter — uniform

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.

try:
link copied ✓

01 — the whole idea

Diffusion, in four moves

Every diffusion model — for images or text — is the same loop: break it, then learn to fix it. Here it is end to end.

1

Start with clean text

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.

the cat sat on the mat
2

Add noise — the forward process

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.

the cat→t▦e c▦t→▦▦▦ ▦▦▦
3

Train a denoiser to undo one step

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.

t▦e c▦t— guess →the cat
4

Generate — run it backward

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.

▦▦▦ ▦▦▦→th▦ c▦t→the cat
👆 Intuition: autoregressive models paint left-to-right like typing; diffusion is more like a photo developing — the whole image (sentence) emerges at once, blurry to sharp. That parallelism is the reason people are excited about diffusion LLMs.

02 — what the noise is

Two flavors of noise

"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

👆 Why masking wins: a [MASK] is an explicit "fix me here" flag — the model knows exactly which letters are missing. A random letter is indistinguishable from a real one, so the model can't even tell what's corrupted. That's why modern diffusion LLMs (MDLM, LLaDA) use the masking kernel.

03 — the sampling trick

Why reveal the confident letters first?

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:

◆ confidence-first

Structure locks in early — words are already legible. Stays coherent with far fewer steps.

◇ random order

Reveals are scattered — no word is whole yet, so later guesses have less to go on. Needs many more steps to recover.

👆 This is MaskGIT / LLaDA confidence sampling (Lesson 4): commit the most-certain tokens first. It's the single biggest lever for making diffusion generation fast — good text in a handful of steps instead of hundreds.

04 — the self-correction trick

What if the model could take a guess back?

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:

◇ commit & freeze

Position 5 was revealed as b early and locked. The run finishes fluent but wrong — "bat", forever.

◆ remask & self-correct

Same bad draw — but a later step un-commits it (↺) and re-fills it with the context now in place. Ends correct.

step 0

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":

confidencehighest probability of its top token wins the next reveal — the LLaDA / MaskGIT default.
marginbiggest gap between the top-2 tokens — reveals only where the model has clearly decided.
entropylowest entropy over the whole distribution — reveal the least-uncertain position.
randomthe baseline: reveal in random order. Usually the worst — order really matters.
👆 One fixed model, big quality swings — how you decode is a lever as strong as what you trained. Lesson 6 verifies remasking helps at every step budget. Open Lesson 6 ↗

05 — the real thing

Train a diffusion LM live, in your browser

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.

step 0 / 500 · loss —

MASKED CROSS-ENTROPY LOSS · lower = better at filling in the blanks

press Train (~10 s), then Generate to sample from the model you trained
👆 This is exactly Lesson 1 — mask, predict, cross-entropy — just small enough for JavaScript (a 2-layer net instead of a transformer). If the samples come out a little rough, that's the tiny model talking; the notebook version uses a real transformer and trains in seconds.

06 — how it learns

The training idea, in plain words

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?"

Ready for the real thing? Every idea here is built from scratch and verified in the six notebooks — tiny models you can train in seconds. Start with Lesson 1.