AI & Machine Learning · Paper 05 / 05

Scaling Laws for Neural Language Models

Jared Kaplan, Sam McCandlish, Tom Henighan, Tom B. Brown, Benjamin Chess, Rewon Child, Scott Gray, Alec Radford, Jeffrey Wu, Dario Amodei

2020 · arXiv · ~12 min read

Read the original paper

Nobody knew whether bigger models would keep getting better. This paper measured it: loss falls as a smooth power law in model size, data and compute, which is why the labs kept scaling.

The problem: should we build a bigger one?

By the end of 2019 bigger language models had been better at every step from GPT to GPT-2, but nobody knew whether that would continue, by how much, or at what cost. Training the next model was a bet of millions of dollars on an unmeasured trend. Three questions had no quantitative answer. If we double the parameters, how much does the loss fall? If we have a fixed compute budget, should it go to a larger model or to more data? And does the shape of the network, its depth and width, matter as much as its size?

The idea: measure the trend, and it turns out to be a power law

Kaplan and colleagues at OpenAI trained hundreds of models across seven orders of magnitude of size and plotted the test loss against parameters, dataset size and compute. On logarithmic axes the points fell on straight lines. Loss as a function of model size, N, is (Nc/N)0.076; as a function of data, D, it is (Dc/D)0.095; as a function of compute, a similar law with exponent 0.050. The architectural details that researchers spent their time on, depth versus width, the number of heads, mattered far less than the sheer count of parameters, within wide limits.

parameters (log)L ∝ N^−0.076dataset tokens (log)L ∝ D^−0.095compute (log)L ∝ C^−0.050loss, log scale on the vertical axis · straight means a power law · the lines held over seven orders of magnitude
The three laws. Plotted on logarithmic axes, loss against parameters, data and compute is a straight line, which means a power law. Small exponents mean slow progress per unit, but the lines did not bend over seven orders of magnitude.

How it works

The second finding is about allocation. Large models are more sample-efficient: they reach a given loss having seen fewer tokens. So for a fixed budget the paper concluded that most of the increase should go to model size, with data growing more slowly, and that a model should be trained well short of convergence. The calculator below uses the paper’s fitted constants, and lets you vary the data-to-parameter ratio, because the ratio is where the story continued.

Try itSpend a compute budget

Choose a training budget in floating-point operations and a data-to-parameter ratio. The calculator splits the budget into model size and tokens and reads the predicted loss off the paper's power law.

parameters28.9BN = √(C / 6·ratio)
training tokens577.4BD = ratio × N
predicted loss (size-limited)1.84nats/tokenKaplan's L(N)
predicted loss (data-limited)1.54nats/tokenKaplan's L(D)
2.03.04.05.01M10M100M1.0B10.0B100.0B1.0Tparameters (log)test loss, nats per token
L(N) = (8.8·10¹³ / N)^0.076

Around twenty tokens per parameter is the Chinchilla-optimal split: the lowest loss for a fixed budget. Note how flat the curve is on a log axis: each halving of loss costs orders of magnitude more compute, which is the whole economics of the field.

In 2022, DeepMind’s Chinchilla paper re-ran the experiment with the learning-rate schedule set correctly for each run and found a different split: parameters and data should grow together, about twenty tokens per parameter. Under the original recipe Gopher had 280 billion parameters trained on 300 billion tokens; under the new one, the same compute bought a 70 billion-parameter model trained on 1.4 trillion tokens, and the smaller model won on almost every benchmark while costing a quarter as much to run. The power laws survived; the exponents and the advice did not.

same compute budget · 2020 recipe (Gopher)parameters: 280 Btokens: 300 Bsame compute budget · 2022 recipe (Chinchilla)parameters: 70 Btokens: 1.4 Tthe 70 B model scored higher on nearly every benchmarkand costs a quarter as much to run
Same compute, two recipes. The 2020 allocation favours a huge model on modest data; the 2022 correction trains a model a quarter the size on nearly five times the tokens, and it scores higher.

What it changed

This paper, with GPT-3 six months later, is the quantitative case for scaling, and the reason training budgets went from millions to billions: the lines said the money would buy something. Chinchilla corrected the split; LLaMA and its successors then went past it, training small models on far more than twenty tokens per parameter because a model that is cheap to serve is worth more than one that is optimal to train. Scaling laws are now measured for everything, from data mixtures to inference-time compute, and “does it follow a clean scaling law” is the first question asked of any new technique.

Where you meet it today

  • Model cards and launch posts quoting parameters and training tokens: the two axes of this paper.
  • Compute-optimal versus inference-optimal as a design decision, when a team picks a model size.
  • Loss curves on log axes in every training report, and the expectation that they be straight.
  • The economics of the field. A small exponent means each halving of loss costs orders of magnitude more compute; that arithmetic is the reason for the data centres.