Mini transformer

The Tiny LLM Lab only looks at the last token. Real LLMs use a transformer, where every token can look back at all the tokens before it. This is a real one, small enough to see inside, trained in your browser.

Untrained · random weights
Step 1 · Train

Train it on a few sentences

We add one sentence to the Tiny LLM Lab's text: "Ruby likes River." Now the word after "likes" depends on who is doing the liking, which the last word alone can't tell you.

Training steps0
Error (loss)–
Weights–
Error over time
The test: same last word, different sentence. What comes next?
Step 2 · Look inside

Follow a prompt through the model

Click any block, or step through them in order. Every number shown is computed live by this model for your prompt.

Lab 2covered in Text to numbersNewnew in this labLab 1covered in Tiny LLM Lab
Scale

From this mini model to real ones

Same blocks, same training rule. Real models are bigger in every direction and stack the transformer block many times.

A simplified model for understanding: one transformer block with one attention head, and no layer normalization. Real transformers use many heads per block, layer normalization, and dozens of stacked blocks, but every block does the same two jobs shown here: attention moves information between tokens, and the feed-forward network processes it inside each token. Next: how one of these weights is made.