created November 27, 2026 · 11 min read
More memory or a bigger model? Five rounds on a tiny language model
Longer memory helped up to a point. A bigger model only memorised. The real limit is the amount of text.
Lab · Experiment series · Tests Inside a tiny language model
I gave my tiny Shakespeare model a longer memory, then a bigger brain, one change at a time. Longer memory helped up to a point. A bigger model only memorised. The real limit is the amount of text.
Question
My tiny language model reads 256 characters of text and guesses the next one. Two obvious ways to make it better are to let it see further back, or to make it bigger. Which one actually helps, and when does it stop helping?
Short answer
Seeing 512 characters back instead of 256 helped it keep track of who is speaking in a scene. Seeing 1,024 back added nothing more. A model 2.4 times bigger just memorised the practice text faster, and once extra dropout stopped the memorising, it only tied the small model. With about one million characters of Shakespeare, the text is the limit, not the model.
The rules
- One change per round. Everything else stays as it was: the same text, the same split into practice text and held-back text, the same random seed (1337), the same 5,000 training steps and the same learning-rate schedule.
- The same scorecard every time. Each round is scored on held-back text it never trained on, on 32 long samples of 3,000 characters, and on the same 512 held-back passages for the "how far back does it use" test.
- Compare against the baseline. The baseline is the model from the Learn series: 6 layers, 6 attention heads, rows of 384 numbers, a 256-character window and 64 passages per training step, about 10.65 million settings in total.
What I measured, in plain words:
- Held-back error score. How wrong the model's guesses are on text it never practised on (the validation loss from Step 3). Lower is better. I report the best score during training and the score at the end.
- Speaker names per 1,000 characters. Real scenes keep coming back to the same few speakers: real Shakespeare has 2.46 different names per 1,000 characters. A model that forgets who is in the scene invents new names, so its number is higher.
- Copied stretches. The share of 30-character stretches in its writing that appear word for word in the practice text. High means memorising, not writing.
All samples use the settings from Step 4: temperature 0.8, top 40, the same seed, so differences come from the model, not the dice.
All five rounds at a glance
| Run | What changed | Best score (step) | End score | Speaker names per 1,000 | Grade |
|---|---|---|---|---|---|
| Baseline | 256 memory, 64 passages | 1.483 (2,250) | 1.675 | 4.18 | – |
| Round 1 | 512 memory, still 64 passages | 1.482 (1,000) | 2.084 | 2.70 | C |
| Round 2 | 512 memory, 32 passages | 1.470 (2,000) | 1.646 | 2.50 | B+ |
| Round 3 | 1,024 memory, 16 passages | 1.477 (2,500) | 1.500 | 2.21 | C |
| Round 4 | Round 2, bigger model | 1.488 (1,750) | 2.354 | 2.92 | D |
| Round 5 | Round 4, more dropout | 1.472 (2,500) | 1.637 | 2.36 | C |
Real Shakespeare: 2.46 speaker names per 1,000 characters. Speaker names are from the end-of-training samples.
Round 1: a longer window (512 characters)
What changed: the window went from 256 to 512 characters. The window is how much text each character can look back at through attention (Step 2); Step 1 shows how much text 256 characters holds.
What happened: speaker names fell from 4.18 to 2.70 per 1,000 characters, much closer to real Shakespeare. But the best score barely moved (1.482 against 1.483), the model hit it at step 1,000 and then memorised hard, ending at 2.084. Keeping 64 passages per step meant each step read twice as much text, so it also took twice the time and memory.
Grade: C. A real gain in speaker tracking, but two things changed at once: the window and the amount read per step.
Round 2: the fair retest (512 characters, half the passages)
What changed: still 512 characters of memory, but 32 passages per step instead of 64, so each step reads the same amount of text as the baseline.
What happened: the best score of the series, 1.470 at step 2,000, at the same cost as the baseline. Speaker names dropped to 2.50 per 1,000 characters (real: 2.46), and 71% of speaker turns went to someone already in the scene (real: 75%; baseline: 57%).
Grade: B+. It answers Round 1's question: the speaker gain comes from the longer memory, not from reading more per step.
Round 3: an even longer window (1,024 characters)
What changed: 1,024 characters of memory, with 16 passages per step so the reading per step stays the same.
What happened: no measurable gain. Its guesses were no better after reading 1,024 characters than after 512, the best score was a hair worse (1.477), and the speaker results were the same as Round 2 within noise. In real Shakespeare, 59% of returning speakers last spoke within 512 characters and 73% within 1,024, so there was something to gain; the model just didn't learn to use it.
Grade: C. Clear answer, no improvement: it levels off.
Round 4: a bigger model
What changed: Round 2's setup, but 8 layers instead of 6, 8 attention heads instead of 6, and rows of 512 numbers instead of 384. That's 25.21 million settings, 2.4 times the baseline. Each head stays the same size.
What happened: it learned fastest early on, then peaked at step 1,750 with 1.488, worse than Round 2, and memorised from there. By the end its practice score was 0.18 and its held-back score 2.35. It copied 1.1% of 30-character stretches straight from the practice text, against 0.06% for Round 2. It cost 1.8 times the time and memory.
Grade: D. It just memorises faster.
Round 5: the bigger model with more dropout
What changed: Round 4 exactly, but dropout went from 0.2 to 0.35. Dropout randomly switches off part of the model's internal signals during practice, so it can't lean on any one memorised detail.
What happened: the memorising was fixed. The end score fell from 2.35 to 1.64 and copying fell to 0.17%. But the best score, 1.472, only tied Round 2's 1.470, and the held-back score still crept up after its best step at the same pace as the small model.
Grade: C. Overfitting was Round 4's problem, but fixing it brought no gain over the small model.
What I found
- 512 characters of memory helped. The model kept the same cast in a scene, close to real Shakespeare, at no extra cost once the reading per step was held fixed.
- 1,024 characters leveled off. Real scenes do reach further back, but the model gained nothing measurable from seeing it.
- A bigger model memorises without more text. 2.4 times the settings, the same text, and it learned the practice text by heart instead of learning more about Shakespeare.
- Dropout fixes the memorising but doesn't beat the small model. Kept in check, the big model ties the small one at 1.8 times the cost.
- So the data is the limit. Every run's best score lands between 1.47 and 1.49. About one million characters of text only holds so much to learn.
Security analogy: tuning a detection on one month of logs. Widening the correlation window from 5 to 10 minutes catches many more multi-stage attack chains; widening it to 20 catches none extra, because most chains finish inside 10. Then you add far more rules: the detection fits that month perfectly, down to one admin's Tuesday habits, and flags ordinary traffic the next month. Stricter rules stop the false alarms, but it catches no more than the simple version did. One month of logs only contains so many patterns. Where it breaks down: a correlation rule uses a wider window the moment you set it; the model has to learn from examples to use text that far back, so the 1,024 result may be a learning limit as much as a real ceiling. And collecting more logs is usually easy, while this text is fixed at about one million characters of Shakespeare.
Limits
- One seed. Every setup ran once, with seed 1337. Gaps of 0.01 in the best score are within run-to-run noise; the memorising in Rounds 1 and 4 is not.
- The learning rate was never retuned. Halving the passages per step (Rounds 2 and 3) and growing the model (Rounds 4 and 5) usually call for a different learning rate. I kept it fixed to change one thing at a time, so each result is that setting, not its best possible version.
- A quirk in the trainer. Each time the trainer saves a snapshot, it resets its random number generator, so the 50 practice batches after each snapshot repeat the ones from the start of training. Every run has this at the same steps, so the comparisons are like for like, but every run practised on some repeated batches.
- Second changes. Rounds 2 and 3 also changed the passages per step (to keep the reading per step fixed), and Round 4 also changed the number of attention heads (to keep each head the same size).
- Coarse checkpoints. Scores were checked every 250 steps, so a true best could sit between checks. The baseline has no saved model at its best step (2,250), so its best-step samples come from step 2,500.
- Small samples. Speaker and copying numbers come from 32 samples per model; some gaps between rounds are inside the noise, and I've only called the ones that aren't.
What's next
More text. Every change to the model's memory or size ran into the same ceiling, so the next experiment changes the data, not the model: train the same small model on more text and see whether the best score finally moves.
Sources
- Model code: Andrej Karpathy's nanoGPT, open source under the MIT license.
- Text: Tiny Shakespeare, from Karpathy's char-rnn.
Learn the pieces this tests: Step 1, how text becomes numbers · Step 2, how the model uses context · Step 3, how training sets the numbers · Step 4, how the model writes