The GPT twin
Same network, causal mask: one letter per pass.
| diffusion | GPT | |
|---|---|---|
| passes | – | 255 |
| time in this browser | – | – |
| real words, 50 seeds | – | – |
Can a language model write a whole passage at once? A tiny diffusion model starts from 255 blanks and fills them in everywhere over a few passes, sometimes taking a letter back. Beside it, a GPT of exactly the same size writes the same length one letter at a time. Both were trained from scratch on Shakespeare and run here, in your browser.
Same network, causal mask: one letter per pass.
| diffusion | GPT | |
|---|---|---|
| passes | – | 255 |
| time in this browser | – | – |
| real words, 50 seeds | – | – |
The ring is one passage of 256 characters, read clockwise from the top. Position 0 is a line break that both models are given; the other 255 are written. A blank is a faint smudge. When the diffusion model commits a letter, that position becomes a short brush stroke whose shape is drawn from the letter: vowels curve, consonants stand straight or hook, capitals are longer, punctuation is a dab, a space is a dot and a line break a notch. The set is made up for this page. The newest strokes are blue-violet. A letter the model takes back fades out, returns to a blank smudge, and is written again later. The text inside the ring is the same passage, plainly.
Both are the same transformer, written for this page in PyTorch and trained from scratch on the same text with the same settings. The only differences are the attention mask and the loss.
| diffusion | GPT | |
|---|---|---|
| attention | both ways | causal |
| trained to | fill in blanks | predict the next letter |
| parameters | ||
| validation loss, nats per letter | ||
| training time |
The diffusion model (absorbing-state masked diffusion, as in MDLM) learns by having a random share of a passage replaced with blanks, anywhere from none to all of it, and guessing them all at once from both sides. Its loss is an upper bound (an ELBO, estimated on 400 validation passages), so its true loss may be lower than the number above: that comparison favours the GPT.
Writing. The diffusion model runs K passes. Each pass reads all 256 positions and draws a letter for every blank; a random set of those letters is kept, so that after pass s about 255·s/K are written (random order, as in MDLM's sampler). Keeping the letters it was most sure of instead (as LLaDA does) made this small model fill the ring with its safest word, “you you you”. We saw that first, so the page uses random order, and the variety check below was added after seeing it. With remasking on, in the middle half of the run a few of the least confident earlier letters go back to blank to be guessed again with more context (confidence-based remasking, after ReMDM). The GPT runs 255 passes, each adding one letter after the last, with a cache so it never rereads. Both sample at temperature 0.8, with the same seed.
Passes are network runs, one after another. Time is measured live in this browser: the compute time of each model's run, in a background worker. Real words is the share of the words a model writes (runs of letters, inner apostrophes allowed) that appear anywhere in tiny-shakespeare, over seeds 1–50, measured with this page's own code and weights, not live.
The ring is drawn live as the passes are computed, at least 90 ms per pass so it can be watched. Compare replays both runs side by side, one pass per tick, so you see the count of passes, not their cost. The real times are in the readout.
Fewer passes do not mean faster here. Each diffusion pass reads every position, while a GPT pass reads one new letter, so on a CPU the GPT finishes first. Diffusion can pay off on hardware that runs a whole pass at once, like a GPU, with models large enough to keep it busy; that is not measured here. Both models are under a million parameters with 256 letters of context: they get Shakespeare's shape, not its sense.
Space write, C compare, ← → step through the passes, Esc close
Subham Sahoo et al., “Simple and Effective Masked Diffusion Language Models” (MDLM), NeurIPS 2024. Aaron Lou, Chenlin Meng and Stefano Ermon, “Discrete Diffusion Modeling by Estimating the Ratios of the Data Distribution” (SEDD), ICML 2024. Shen Nie et al., “Large Language Diffusion Models” (LLaDA), 2025, for the loss weighting and the confidence-ordered unmasking tried here. Guanghan Wang et al., “Remasking Discrete Diffusion Models with Inference-Time Scaling” (ReMDM), 2025.
Andrej Karpathy's nanoGPT (MIT) for the GPT design. nathanrs's tiny-diffusion (MIT) for the idea of a GPT twin that shares the diffusion model's code; read, not copied. Text: tiny-shakespeare from Karpathy's char-rnn (Shakespeare, public domain). Fonts: Lora and Inter, SIL Open Font License.
How it was made: idea, direction and every taste call by Joe; code written by Claude Code under his review.
This piece needs JavaScript and Web Workers.