Neural Scaling Laws
Summary
Kaplan et al. (2020) show that the test cross-entropy of an autoregressive Transformer language model is a power law in each of three scale variables, non-embedding parameters , dataset tokens and training compute , “when not bottlenecked by the other two”, with trends spanning six to eight orders of magnitude. Architecture shape (depth, width, heads) matters little at fixed . A single formula governs overfitting, a second formula governs learning curves, and together they imply that under a fixed compute budget one should train very large models and stop far short of convergence, with and data growing only as . That allocation was later revised by Compute-Optimal Training (Chinchilla); the power-law form itself has held up.
Overview
The experiments train decoder-only Transformers on WebText2 ( tokens, vocabulary 50,257, context 1,024), varying model size from 768 to 1.5 billion non-embedding parameters, dataset size from 22 million to 23 billion tokens, and shape, context length and batch size (Sec. 3). Default training is Adam for steps at batch tokens with a 3,000-step warmup and cosine decay to zero.
Two bookkeeping conventions make the trends clean:
- Count only non-embedding parameters. under the standard (Eq. 2.1). With embeddings included, loss appears to depend on depth; with them excluded, all depths collapse onto one curve (Fig. 6).
- Compute is for batch size (tokens) and steps, i.e. FLOPs per training token, quoted in PF-days ( FLOPs).
Main Content
Single-variable power laws ^thm-power-laws
(Eqs. 1.1-1.3; fitted values from Appendix A, Table 5.)
for models trained to convergence on sufficiently large data;
for large models with early stopping;
for optimally allocated compute at small batch size. The exponents are the substantive content; the scale constants “depend on the vocabulary size and tokenization and hence do not have a fundamental meaning.”
The relations hold “across eight orders of magnitude in , six orders of magnitude in , and over two orders of magnitude in .” The exponents are small: doubling multiplies loss by .
Joint law and the overfitting criterion
(Eqs. 1.5, 4.1-4.4.)
with joint fit , , , (Table 2). The relative overfitting penalty depends only on the combination :
Requiring to stay below the seed-to-seed noise in the loss () gives
The functional form was chosen by three principles (Sec. 4.1): (1) it must permit rescaling under a change of tokenizer; (2) it must reduce to as and to as ; (3) it should be analytic in at , because “overfitting should be related to the variance or the signal-to-noise ratio of the dataset, and this scales as “. The authors call the third “more speculative”. The fit is excellent except at the smallest dataset ( tokens). The sub-linear rule means “every time we increase the model size 8x, we only need to increase the data by roughly 5x to avoid a penalty.”
Learning-curve law
(Eqs. 1.6, 5.6; Table 3.) After an initial transient, in the infinite-data limit,
where is the number of steps that would have been needed at very large batch size.
Critical batch size ^def-bcrit
Training to a fixed loss with steps and examples satisfies (Eq. 5.1). The critical batch size is ; training there costs steps and examples, a near-optimal time/compute compromise. Empirically
independent of model size and roughly doubling for every 13% decrease in loss (Fig. 10). The adjustments and (Eqs. 5.4-5.5) standardize runs made at a fixed batch size.
Compute-efficient allocation (Kaplan version) ^thm-kaplan-allocation
Substituting into and minimizing over at fixed compute gives (Eqs. 1.7-1.8, 6.1-6.5, Appendix B):
The predicted and agree with the direct empirical fits , , , , and one-epoch data (Table 6). At the optimum one trains to a loss about above the converged loss (Eq. B.5).
Hence the headline advice: “we attain optimal performance by training very large models and stopping significantly short of convergence.” Each 10x of compute should buy roughly 5x more parameters and 2x more data (Fig. 14). Relative to training to within 2% of convergence, compute-efficient training “uses 7.7x fewer parameter updates, 2.7x more parameters, and 65% less compute to reach the same loss” (Appendix B.3). The optimum is flat: models between 0.6x and 2.2x the optimal size cost only 20% more compute (Fig. 12).
Other findings
- Shape barely matters. At fixed , loss varies by a few percent across wide ranges of aspect ratio, feed-forward ratio and head dimension; an model is within 3% of (Fig. 5).
- Large models are more sample-efficient, reaching the same loss in fewer steps and fewer tokens (Figs. 2, 4).
- Transfer. Loss on other distributions (Books, Wikipedia, Common Crawl) is a power law in with nearly the same exponent and a roughly constant offset; it “depends almost exclusively on the in-distribution validation loss” (Sec. 3.2.2).
- Transformers beat LSTMs at equal because they keep improving on later tokens in the context (Fig. 7).
Where the laws must fail
Loss cannot fall to zero because text has non-zero entropy. More sharply (Sec. 6.3): avoiding overfitting needs , yet compute-efficient single-epoch training supplies only . The two curves and cross near PF-days, parameters, tokens, nats/token, though the authors warn these values are highly uncertain, varying by an order of magnitude in either direction with the fitted exponents. The authors conjecture that estimates the entropy of natural language. For comparison, Hoffmann et al. later fit an irreducible term with a different tokenizer and corpus. Appendix C states the central caveat plainly: “we do not have a solid theoretical understanding for any of our proposed scaling laws.”
Examples
Using the laws as a planning tool.
- How much data for a 1B-parameter model? tokens, which is why the 22B-token WebText2 sufficed for all models below parameters.
- What does 10x compute buy? Loss falls by the factor . Optimal grows by x and tokens by x.
- Predicted converged loss. At : nats per token.
Fitting a scaling law from pilot runs.
import numpy as np
from scipy.optimize import curve_fit
# pilot results: non-embedding params N, tokens D, final test loss L
def L_ND(X, log_Nc, log_Dc, aN, aD): # Kaplan Eq. (1.5)
N, D = X
return ((np.exp(log_Nc) / N) ** (aN / aD) + np.exp(log_Dc) / D) ** aD
theta, cov = curve_fit(L_ND, (N, D), L, p0=[np.log(1e14), np.log(1e13), 0.08, 0.10])
# extrapolate to the planned run and propagate the fit uncertainty in covThis is an extrapolation exercise with the usual hazards. The fitted exponent is a slope in log-log space estimated from small-scale runs and applied orders of magnitude outside the data. Hoffmann et al. show that precisely this step, extrapolating from small models under a fixed learning-rate schedule, biased Kaplan’s allocation exponents. A Bayesian fit with a prior predictive check on the implied losses at target scale, and posterior uncertainty carried through to the design decision, is the natural upgrade.
Connections
- Compute-Optimal Training (Chinchilla): re-estimates the allocation and finds ; read together with this note.
- Autoregressive Language Modeling and Pretraining: defines , , and .
- Overfitting and Information Criteria: is an overfitting penalty that grows with a parameter-to-data ratio, in the spirit of the parameter-count penalties of AIC and WAIC, but measured directly on held-out loss and with a sub-linear exponent .
- Power Analysis and Sample Size: both are design-stage calculations that use an assumed functional form to choose sample size before the expensive study is run. The scaling-law analogue of effect size is the exponent; the analogue of power is predicted loss at target scale.
- Shape (Saturation) Effects: power-law diminishing returns in each input, the same qualitative shape as media response curves.
- In-Context Learning and Few-Shot Prompting: GPT-3 was sized using these laws and extends the trend by two more orders of magnitude.
See Also
- Transformers and LLM Foundations - Overview
- Transformer Architecture and Positional Encoding
- Cross Validation Checking: held-out loss as the target of model evaluation.
- Geo-Experiment Design and Power Analysis: simulation-based design under a fixed budget.
- Effective Sample Size and Monte Carlo Standard Error: another setting in which error falls as a power of effort () and the practical question is how much effort to buy.