Prediction lab.
How does a tiny language model decide what comes next?
How does a tiny language model decide what comes next?
It does only one thing: guess the next character. Everything else is doing that again and again.
Inside a prediction.
Follow your characters through the network and see how one becomes the next draw.
Next character
TOP 5Each bar shows a chance. Draw once to add one character to your prompt.
How many bits would a character cost?
Causal attention
Read across a row to see how much weight that position gives each visible character.
Kill-a-Head Lab
Select one head to silence it. Select it again to restore it. Validation losses use the recorded fixed-batch experiment. Predictions below are computed for your current prompt.
All heads · top five
Selected configuration · top five
Learning curves
Lower loss means the model gave the observed characters higher probability.
Character embeddings
PCA projects learned character vectors onto their two strongest directions.
Validation and test results
| Split | Model | CE (nats) | BPC | Top-1 | Top-5 |
|---|---|---|---|---|---|
| Val | Unigram | 3.3074 | 4.7716 | 0.153 | 0.406 |
| Val | Bigram | 2.4959 | 3.6009 | 0.261 | 0.651 |
| Val | Trigram | 2.0512 | 2.9593 | 0.387 | 0.763 |
| Val | Transformer | 1.4865 | 2.1446 | 0.554 | 0.848 |
| Test | Unigram | 3.3476 | 4.8296 | 0.149 | 0.398 |
| Test | Bigram | 2.5031 | 3.6112 | 0.265 | 0.653 |
| Test | Trigram | 2.1471 | 3.0977 | 0.373 | 0.741 |
| Test | Transformer | 1.7479 | 2.5217 | 0.510 | 0.821 |
111,475 validation targets · 111,476 test targets. Test CE 1.7479 is higher than validation CE 1.4865. The last 10% of Tiny Shakespeare covers a different stretch of text and was evaluated once after freezing.
Browser parity and precision
Reported PyTorch vs JS maximum absolute logit difference: 6.47e-06 over 20 fixed prompts.
Checkpoint size: fp32 6,598,975 bytes · fp16 3,314,307 bytes. Fixed-batch validation loss: 1.4942 and 1.4937, respectively. This preview uses the float32 export.
Limitations
1.1M characters of training corpus before splitting · 64-character context · character-level generation · CPU-only training. Attention is a weight inside the model, not proof of why it chose a character.
Evaluation details & temperature samples
Search the course notes
Search four excerpts from the AIML reference and CN lab programs.