knowledge base Ā· entry 08
Better data beats a bigger model
A read-through of the paper that made a 1.3-billion-parameter model out-code ones ten times its size ā not with more data, but with better data.
every figure zooms ā click it, scroll to magnify, drag to pan
part one
The idea, before any jargon
figure 1 Ā· the whole idea
A 1.3B model that codes like a 15B one
Everyone had been scaling the same way: more parameters, more data scraped from the web, more compute. This paper asked a heretical question ā what if the bottleneck isn't how much data but how good it is? So they built a small model, phi-1, and fed it a tiny, carefully curated diet of "textbook-quality" code instead of the usual web dump.
It out-coded models an order of magnitude larger. On HumanEval ā the standard "can it write a correct function from a description" benchmark ā phi-1 at 1.3B parameters beat StarCoder at 15.5B, despite seeing a tiny fraction of the data.
click any figure to zoom Ā· scroll to magnify Ā· drag to pan
This is the counterweight to the scaling-laws story in the rest of this arc. Chinchilla tells you the optimal ratio of model size to data volume; phi-1 tells you that a good enough teacher can move the curve itself. Both are true, and they pull in useful tension.
figure 2 Ā· the raw material
What "textbook quality" means
The whole paper turns on one intuition, so it's worth making concrete. Most code on the internet runs but teaches nothing: no context, cryptic names, no explanation of why. A textbook example is the opposite ā self-contained, clearly named, documented, with a worked instance. Same concept, wildly different value to a learner.
A model learns the patterns in its data. Feed it landfill and it learns to imitate landfill; feed it a curriculum and it learns the concepts. The bet is that a training set should read like a textbook, and everything else in the method is just how you assemble one at scale.
part two Ā· the method
How you build a textbook
Two moves: throw away the web that doesn't teach, and manufacture more of the web that does.
figure 3 Ā· the data recipe
Filter, then fabricate
First, filtering. They took a big corpus of public code and trained a small classifier to score each file for "educational value" ā does this read like it belongs in a textbook? ā then kept only the top slice. That alone throws away the vast majority of the data.
Second, synthesis. A larger model (GPT-3.5) was prompted to write new textbook-style material: explanations, and a set of clean worked exercises. Because it's generated to be instructive, it's clean by construction.
The combined training set ā filtered code, synthetic textbooks, synthetic exercises ā comes to roughly 7 billion tokens. Next to the trillion-token corpora everyone else was using, it's a rounding error. The cleverness is entirely in the classifier and the generator; the training run itself is completely ordinary.
part three Ā· the numbers
Just how much less
figure 4 Ā· the efficiency
Smaller, and by two orders of magnitude less data
It's worth seeing the sizes side by side, because the gap is not subtle. phi-1 is smaller on every axis that usually predicts performance, and better on the one that matters.
Around 150Ć fewer training tokens, about 12Ć fewer parameters ā and a higher score. When the inputs shrink on every axis and the output goes up, the cause isn't scale. It's what the tokens contain.
part four Ā· the surprise
The fine-tune that unlocked the model
figure 5 Ā· the jump
A small, clean fine-tune reorganized what it could do
The most striking result is almost an afterthought in the method. Before the final step, phi-1-base ā already trained on textbooks and filtered code ā is good, not great. Then they fine-tune it on CodeExercises, a small set of clean worked problems, and the score nearly doubles.
What makes it more than a data point: the fine-tuned model gained abilities the exercises never demonstrated ā using libraries and patterns absent from that small set. A modest, high-quality fine-tune didn't just add facts; it seems to have reorganized the capabilities already latent in the base model. Quality, it turns out, compounds.
the math Ā· in the paper's notation
The metric, and the FLOP ledger
This paper's argument is empirical, so its math is the measuring equipment: the pass@k estimator every code benchmark runs on, and the compute arithmetic that makes "two orders of magnitude less" a number you can check.
the equations Ā· worked
How the score is scored, and what the run cost
the HumanEval metric Ā· the unbiased pass@k estimator
pass@k = Eproblems [ 1 ā ( nāck )( nk ) ]
read aloud: sample n candidate programs per problem, count the c that pass the unit tests, and compute the chance that a random draw of k contains at least one passer. The binomial-coefficient form corrects the bias of the naive "did my first sample pass" ā it is how phi-1's 50.6% pass@1 is actually computed.
- ncandidate completions sampled per problem
- chow many of them pass the problem's unit tests
- ( nk )"n choose k" ā the number of ways to pick k samples from n
the efficiency claim Ā· the standard FLOP approximation
C ā 6 Ā· N Ā· D
read aloud: training compute is about six floating-point operations per parameter per token ā two for the forward pass, four for the backward. The same approximation Chinchilla (next entry) builds its whole law on, used here just to price the two training runs being compared.
- Nparameters
- Dtraining tokens actually seen (epochs count ā phi-1 passes over its 7B-token diet ~8 times)
part five Ā· what we take from it
Textbooks for a domain
applied Ā· our reading
The most actionable lesson in the arc
For a specialist system in a regulated domain, this is the paper that changes what you do on Monday. The instinct is to scrape more source material ā more circulars, more rulings, more forms. phi-1 says the opposite: a smaller set of curated, worked examples ā the domain rendered as a textbook ā can beat a far larger pile of raw documents.
the caveat we would flag The textbooks here were authored by a larger model, so the method quietly assumes a capable teacher ā and a synthetic curriculum can inherit that teacher's mistakes, or leak the very benchmark you mean to test on. In a domain where a wrong answer is a compliance event, the curation has to be verified by a human who knows the law, not just generated and trusted.
next in the arc
Where this goes
phi-1 argues that data quality can move the curve. The next two entries in data & scaling laws pin down the curve itself: Chinchilla derives the compute-optimal ratio of model size to training tokens, and Beyond Chinchilla corrects it once you count the cost of serving the model, not just training it.
source
Gunasekar, Zhang, Aneja, et al. ā Microsoft Research (2023). Textbooks Are All You Need. arXiv:2306.11644. The HumanEval and token/parameter figures are the paper's; the code snippets and diagrams are our own illustration.
ā back to the knowledge base Ā· ā the illustrated decoder Ā· ā¶ run the forward pass
attention.sh ā a division of Jinacode Systems. Transformers,
fine-tuning, and sovereign LLMs.
we're hiring the curious ā hello@attention.sh