Model Explorer
A real, tiny decoder-only transformer, run in your browser. Type a prompt and see which word it predicts next, then follow any word through the 26 steps of the forward pass that produced that prediction. Every number on this page is computed live by a JavaScript port of the NumPy reference implementation, which you can download and run. The two agree to within 1e-9 on every attention weight, final hidden state and logit, and the canonical traces are available as a golden fixture. The trained weights are downloadable too.
What you are looking at
Section titled “What you are looking at”The model has 2 layers, 2 attention heads, a 16-dimensional residual stream and a 25-entry vocabulary (23 words, a period and a start token). It was trained for 4,000 steps on a tiny synthetic grammar (subjects, verbs, objects, places and “then it …” follow-ups) using the Adam optimizer, so its predictions are grammatical for that toy language, but it knows nothing else. The Weights switch (Trained or Untrained) runs the identical computation with random weights: the arithmetic is the same, the predictions are not. The training script (tools/train_model.py), weights and checksum are all in the project, and every value can be reproduced independently, by hand or in code with Lab 10.
| Choice | This model | A typical production LLM |
|---|---|---|
| Tokenizer | 25 entries: 23 whole words, a period and <bos> | Subwords (BPE), 30k to 200k entries |
| Positions | Fixed sinusoidal, added once | Often rotary (RoPE), applied inside attention |
| Normalization | RMSNorm before each sub-block, no learned scale | Same pre-norm pattern |
| MLP | GELU, no biases | Often gated (SwiGLU) |
| Output | Weights tied to the embedding | Tied or separate |
To see how this model relates to real ones, read Compare with the toy model. Read the chapters for the full story: attention, the transformer block and tokens and embeddings.
Try this
Section titled “Try this”- Follow
satand open step 7, Hide the future. Every token after it is blocked. - Move to step 8, Turn scores into attention, and switch to Numbers. Check that the weights sum to 1 and that the blocked tokens get exactly 0.
- On step 6, Score every pair, open Numbers and recompute one score yourself from the displayed q and k.
- Switch between head 0 and head 1 at the same step. Heads are free to attend to different places.
- Try the example “the cat sat on the” and flip Weights between Trained and Untrained. Only the trained model puts almost all of its probability on
matandbed. - Follow an earlier word to the last step. The model makes a prediction at every position; the Notice tells you whether it guessed the word that actually comes next.
- Shorten the prompt and compare: earlier tokens’ outputs do not change, because a token never reads the tokens after it.
Worked comparisons
Section titled “Worked comparisons”Inspect specific calculations from the model, with computed results and explanations.
Spotted a mistake, a confusing explanation or a broken widget? Report a problem with this page