Paper Breakdowns  /  Phi (Textbooks Are All You Need)
Paper 61~11 min readMicrosoft · 2023worked math + runnable code
Paper Breakdown

Textbooks are
all you need.

The reigning wisdom was blunt: bigger models, more data, better results. Then a 1.3-billion-parameter model — a tenth the size of its rivals — matched them on coding, not by being cleverer but by being fed better. Not more internet, but curated, textbook-quality examples. The lesson landed hard: what a model learns depends less on how many tokens it sees than on how much of each token actually teaches. Here's the data-quality argument, made quantitative.

Video breakdown
The animated walkthrough is in production.
Read the full breakdown below in the meantime ↓
01

Scale vs quality

The scaling laws gave the field a simple, powerful recipe: capability rises predictably with model size, data, and compute. Bigger, trained on more, is better. It worked so well it became the default strategy — pour in web-scale data, grow the parameter count, watch benchmarks climb.

But that framing quietly assumes all tokens are equal. Web data is not: it's a mix of the brilliant and the banal, the correct and the wrong, the novel and the thousandth near-duplicate. Phi's question was whether the composition of the data — its quality — is a lever as powerful as its sheer quantity. If you could feed a model only the good stuff, how small could the model, and the dataset, be?

The one-sentence version

What teaches a model is useful signal, not raw tokens — so a small model on curated, high-quality data can match a much larger one trained on noisy web text.

02

Textbook-quality data

Phi's core move is to treat data quality as the primary design variable. It built a training set of what the authors call textbook-quality data — clear, correct, self-contained, pedagogically structured examples, the way a good textbook explains a concept rather than the way a random forum post does. Two ingredients:

Building the training set
FilterA classifier scores existing code for educational value; keep only the instructive.
GenerateA stronger model writes synthetic textbook-style lessons and exercises.
ResultA small, dense corpus where almost every token teaches something.

The formalization is simple. Not every token carries useful learning signal; if a fraction q (the quality) does, the effective signal in a dataset of N tokens is N·q. Web data is enormous N with tiny q; textbook data is small N with q near 1 — and the product can favor the small clean set.

effective signal = N · q  →  curated (7B × 0.9 = 6.3B) beats web (300B × 0.02 = 6.0B)

Forty times fewer raw tokens, more actual teaching — because the curated set wastes almost nothing. The runnable version below computes this trade and the compute a smaller model saves.

03

Small beats big

The result was striking. phi-1, at 1.3 billion parameters trained on this small curated set, matched or beat models roughly an order of magnitude larger on Python coding benchmarks like HumanEval. The follow-ups (phi-1.5, phi-2, and the phi-3 family) extended the recipe beyond code to general reasoning, repeatedly showing small models punching far above their parameter count.

And the win compounds at deployment. A forward pass costs roughly 2 × params FLOPs per token, so a 1.3B model is about ten times cheaper per token than a 13B one. A small model that matches a big one on quality doesn't just train cheaply — it runs cheaply forever after, which for anything served at scale is the number that matters most.

04

Why quality wins

Why should clean data be so much more efficient? A few reasons stack up. Redundancy: web corpora repeat the same easy patterns endlessly, so most tokens teach nothing new — the model has already learned them. Noise: incorrect or low-quality examples actively mislead, spending capacity on things you'd rather the model not learn. Density: a textbook introduces concepts deliberately, in a logical order, with worked examples — a far higher rate of genuinely new, correct information per token.

Put together, curated data means the model spends every parameter and every gradient step on signal instead of drowning it in noise and repetition. That's why a small model can keep up: it isn't wasting its limited capacity memorizing junk. Quality doesn't add a constant bonus — it changes the exchange rate between tokens and learning.

RUN IT YOURSELF

Effective signal, not raw tokens

The data-quality thesis is a product you can compute. This models effective signal as tokens × quality and shows a curated 7-billion-token set at 90% quality (6.3B signal) beating a 300-billion-token web set at 2% quality (6.0B signal) — forty times fewer tokens, more teaching. It then prices inference at ~2×params FLOPs per token, making a 1.3B model ten times cheaper than a 13B one, and shows how many raw tokens each quality level needs to hit a signal budget. Change the quality or sizes and watch which dataset wins.

CPython · WebAssembly
05

The caveats

The result was influential and also debated. Two honest cautions travel with it:

CaveatWhat to watch
Benchmark contaminationWhen training data is synthetic and targeted, it may resemble evaluation tasks. Strong scores must be checked for leakage between train and test.
Narrow vs generalGreat numbers on Python coding don't prove broad capability; the recipe had to be re-validated as phi expanded to general reasoning.
Quality is hard to define"Textbook-quality" is judged by a classifier and a generator model — quality is itself model-dependent and imperfect.
Synthetic-data risksGenerating training data with a stronger model can inherit its blind spots and biases.

None of these overturned the central finding — that data quality is a first-class lever — but they are why the community treated the specific benchmark numbers with care while embracing the broader thesis. Measuring quality, and guarding against contamination, became active areas precisely because phi made quality matter.

06

What it started

Phi helped shift the field's attention from "scale everything" to "curate ruthlessly." The small language model movement — capable models in the 1–4B range that run on a laptop or a phone — owes much to the demonstration that careful data can substitute for raw size. Data curation, filtering, and synthetic generation became central research topics, not afterthoughts, and "data-centric" work gained the status the scaling laws had given model-centric work.

Its lasting idea complements, rather than contradicts, scaling. The scaling laws describe how capability grows with size for a fixed data quality; phi showed that quality is another axis entirely, one you can push to buy the same capability at a fraction of the size and cost. Both are true — and the practical frontier is to scale and curate, spending compute where it teaches most.

Worth knowing

The efficiency of curated data also reshapes the Chinchilla view: compute-optimal token counts assume a fixed data quality, so higher-quality tokens can shift the optimal balance — fewer, better tokens doing the work of many.

Frequently asked

Quick answers

What did phi show?

A 1.3B model trained on curated textbook-quality data matched models ~10x larger on coding — data quality, not just scale, drives capability.

How can small beat big?

What teaches is useful signal, not raw tokens. A small dataset that's almost all high-quality can hold more effective signal (tokens × quality) than a giant noisy one.

What is textbook-quality data?

Clear, correct, self-contained, pedagogically structured examples — built by filtering code for educational value and generating synthetic textbook-style content.

What are the caveats?

Benchmark contamination from synthetic data, and narrow-vs-general capability. The quality thesis held, but specific numbers need careful checking.

Finished this one? 0 / 101 Paper Breakdowns done

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Paper Breakdowns