Search

Search papers and lessons

Scaling Laws for Neural Language Models

Jared Kaplan, Sam McCandlish, Tom Henighan et al. · 2020

Kaplan et al. find that Transformer language-model loss follows power laws in parameters, data and compute, so a bigger model with the right data can be planned before it is trained.

On this page

  • Colour = topic mix
  • Calculus
  • Probability
  • Neural network basics
  • Linear algebra
  • Discrete math
  • Architectures
  • Sign in to see your progress

TL;DR

Kaplan and colleagues trained hundreds of decoder-only Transformers on web text and found that the test loss falls as a smooth power law in three quantities: the number of non-embedding parameters, the size of the dataset, and the training compute. The shape of the model matters much less than its size. Within a fixed compute budget, the best use of compute is a very large model stopped well before convergence.

The result turns model building into planning. Before training, you can predict roughly how much loss a larger model will reach, and how much data and compute it needs.

Where you'll see it: deciding how large a language model to train for a given budget, choosing how much text to collect, and justifying the multi-billion-dollar training runs that followed the paper.

The problem

By 2020, language models were getting larger, but the trade-offs were unclear. Researchers chose architectures by trial and error, and they did not know how much a larger model would gain, or how much more data it would need. Two questions were open. First, does a bigger model keep improving, or does it stop helping at some size? Second, if compute is fixed, should you train a bigger model for fewer steps, or a smaller one for longer?

The paper's answer is that the loss shows no sign of leveling off at the upper end of the range it measured (though it must flatten eventually before reaching zero), and that the trade-off is governed by simple exponents. It also says that the exponents are stable enough to extrapolate.

Key idea

The central claim is that performance is determined mainly by scale. Three inputs matter: the number of non-embedding parameters NN, the number of training tokens DD, and the compute CC. Each one, when it is the bottleneck, produces a straight line on a log-log plot. Changing the depth or width of a Transformer, at fixed NN, barely changes the loss.

The second claim is about overfitting. If NN and DD are scaled together, training is efficient. If one is held fixed while the other grows, returns diminish. The penalty depends on one combined quantity, N0.74/DN^{0.74}/D. This means the data needed to avoid overfitting grows much more slowly than the model.

The third claim is about compute. Models trained with the optimal batch size should be stopped before convergence, and most of any extra compute should go to a larger model.

The method

Setup

The models are decoder-only Transformers trained with Adam (Adafactor for the largest, above 1B parameters) on WebText2, a web-text dataset tokenised with byte-pair encoding and a vocabulary of 50,257 tokens. The loss is the average cross-entropy over a 1024-token context, which is the paper's main metric. The authors also trained LSTMs and Universal Transformers for comparison. Model sizes range from about 768 to 1.5 billion non-embedding parameters, and dataset sizes from 22 million to 23 billion tokens.

The compute estimate is C≈6NBSC \approx 6 N B S, where BB is the batch size in tokens and SS is the number of parameter updates. The factor of 6 counts floating-point operations per parameter per token: the forward pass costs about 2N2N (a multiply and an add per parameter), and the backward pass costs about twice the forward pass, so 2N+4N=6N2N + 4N = 6N.

The three power laws

When one factor is the bottleneck, the test loss follows a power law:

L(N)=(NcN)αN,αN≈0.076,Nc≈8.8×1013L(N) = \left(\frac{N_c}{N}\right)^{\alpha_N}, \qquad \alpha_N \approx 0.076, \quad N_c \approx 8.8 \times 10^{13} L(D)=(DcD)αD,αD≈0.095,Dc≈5.4×1013L(D) = \left(\frac{D_c}{D}\right)^{\alpha_D}, \qquad \alpha_D \approx 0.095, \quad D_c \approx 5.4 \times 10^{13} L(Cmin⁡)=(Ccmin⁡Cmin⁡)αCmin⁡,αCmin⁡≈0.050,Ccmin⁡≈3.1×108 PF-daysL(C_{\min}) = \left(\frac{C_c^{\min}}{C_{\min}}\right)^{\alpha_C^{\min}}, \qquad \alpha_C^{\min} \approx 0.050, \quad C_c^{\min} \approx 3.1 \times 10^{8} \text{ PF-days}

The constants NcN_c, DcD_c and Ccmin⁡C_c^{\min} depend on the vocabulary and tokenisation, so they have no fundamental meaning. The exponents are the useful part. The paper points out that doubling NN multiplies the loss by 2−0.0762^{-0.076}, which is about 0.95.

A single formula for overfitting

When both NN and DD are finite, the authors propose one formula that covers both limits and the overfitting between them:

L(N,D)=[(NcN)αN/αD+DcD]αDL(N, D) = \left[\left(\frac{N_c}{N}\right)^{\alpha_N/\alpha_D} + \frac{D_c}{D}\right]^{\alpha_D}

Its limits are the two single-factor laws above. Its 1/D1/D term is a choice the authors justify by the variance of the data, though they call this argument speculative. Fitting this form to their runs, with 10 percent dropout and early stopping, gives αD≈0.103\alpha_D \approx 0.103 and Nc≈6.4×1013N_c \approx 6.4 \times 10^{13}. The authors also define the relative overfitting δL=L(N,D)/L(N,∞)−1\delta L = L(N,D)/L(N,\infty) - 1, which depends on NN and DD only through the combination NαN/αD/DN^{\alpha_N/\alpha_D}/D. From this they estimate that avoiding overfitting to within about 0.02 nats of loss needs D≳5×103 N0.74D \gtrsim 5 \times 10^3 \, N^{0.74} tokens.

The exponent 0.740.74 is the ratio αN/αD\alpha_N/\alpha_D. It explains the paper's rule of thumb: each 8x increase in NN needs only about a 5x increase in DD, since 80.74≈4.78^{0.74} \approx 4.7.

Training curves and the critical batch size

The paper also fits learning curves. For a model trained for SS steps with enough data, the loss is approximately

L(N,S)=(NcN)αN+(ScSmin⁡(S))αS,Sc≈2.1×103,αS≈0.76L(N, S) = \left(\frac{N_c}{N}\right)^{\alpha_N} + \left(\frac{S_c}{S_{\min}(S)}\right)^{\alpha_S}, \qquad S_c \approx 2.1 \times 10^3, \quad \alpha_S \approx 0.76

Here Smin⁡S_{\min} is the minimum number of steps needed, given the batch size. The critical batch size BcritB_{\rm crit} is the largest batch that still gives near-optimal steps per sample. It follows a power law in the loss, Bcrit(L)=B∗/L1/αBB_{\rm crit}(L) = B_*/L^{1/\alpha_B} with B∗≈2×108B_* \approx 2 \times 10^8 tokens and αB≈0.21\alpha_B \approx 0.21. Above BcritB_{\rm crit}, extra batch size wastes data. Below it, extra batch size saves steps almost for free. This is the same trade-off studied in Critical Batch Size.

Optimal allocation of compute

Combining these pieces gives the paper's main planning result. Let NN, BB, SS and D=BSD = B S be the model size, batch size, steps and dataset size. For a fixed budget Cmin⁡C_{\min}, the optimum scales as:

N∝Cmin⁡0.73,B∝Cmin⁡0.24,S∝Cmin⁡0.03N \propto C_{\min}^{0.73}, \qquad B \propto C_{\min}^{0.24}, \qquad S \propto C_{\min}^{0.03}

The exponents sum to 1, which is what you expect from C≈6NBSC \approx 6 N B S. Almost all extra compute goes into model size. Data grows more slowly, roughly as C0.27C^{0.27}, and most of that growth shows up as a larger batch rather than more serial steps. The authors caution that the exponent for SS is small enough that it may be zero.

Results

The power laws held over the measured range: about six orders of magnitude in NN, two in DD, and eight in Cmin⁡C_{\min}. The fit of L(Cmin⁡)L(C_{\min}) improved once the authors standardised to the critical batch size, which removed a bias from comparing runs at a fixed batch.

The optimal-allocation results were checked two ways. Fitting the best model at each budget gave empirically N∝Cmin⁡0.73N \propto C_{\min}^{0.73}, and the prediction from the learning-curve fit is N∝Cmin⁡0.71N \propto C_{\min}^{0.71}, which the authors say matches to within a few percent. The empirical fit also gives optimal model size growing about fivefold per tenfold increase in compute, while the number of data examples processed grows about twofold. The theory also says to train to a fixed percentage above the converged loss, αN/αS≈10%\alpha_N/\alpha_S \approx 10\%, which is what "stop well before convergence" means in numbers.

Figure 13 of the paper shows that the adjusted L(Cmin⁡)L(C_{\min}) trend is the one to extrapolate. The unadjusted trend in compute is less clean. The authors also note a visible kink where networks go from one layer to two, and they exclude one-layer networks from the fits.

The transfer results follow the same logic. On text from other distributions the loss improves smoothly with NN in parallel with the WebText2 loss, with a roughly constant offset (the figure caption calls it small and very slowly growing). Generalisation depends almost entirely on the in-distribution validation loss, not on how long the model trained.

Why it mattered

The paper turned scale from an intuition into a forecasting tool. Labs could estimate, before a large run, what loss a larger model would reach. The framework shaped how later large models were sized and budgeted. GPT-3, which OpenAI released in 2020 with Tom Brown as a coauthor of both papers, is the best-known example of its scale.

The compute-optimal recipe also says to stop before convergence. That was a departure from common practice, and later work refined it. In 2022, Hoffmann and colleagues revisited the allocation question with new experiments, and they found that the optimal data per parameter was higher than Kaplan et al. had estimated. That revision did not contradict the paper's main claim that loss follows smooth power laws, but it changed the recommended split between model size and data.

Reading guide

Read the paper in this order, with these prerequisites in hand.

  1. Section 1, the summary. Needs Neural Scaling Laws for the general idea of a power-law trend, and Power Law for the exponents. Read the summary bullets before the details.
  2. Section 2, the setup. Needs Transformer for the decoder-only architecture, and Language Model for next-token loss. The batch size and the Adam optimizer are described here; Adam Optimizer explains the update.
  3. Section 3, the basic laws. Needs Cross-Entropy Loss for the metric, and Logarithm to read the log-log plots.
  4. Section 4, overfitting. Needs Overfitting and Dropout for the 10 percent regularisation, and Early Stopping for how the runs were stopped.
  5. Sections 5 and 6, training curves and compute. Needs Stochastic Gradient Descent for the step counting, and Critical Batch Size for the batch-size argument. Skip the derivation of the exponent sum on a first read.

Check yourself

QuestionDoubling the parameter count multiplies the loss by about 0.95 under L(N) = (N_c/N)^0.076. Why does that matter for planning?Show answer

Each doubling buys only a small absolute improvement, so the returns from parameters are slow but steady. Because the law is a straight line on a log-log plot, the same factor appears at every scale. A planner can therefore estimate the gain from any size increase with one multiplication. The paper's statement is only about the loss ratio. Converting it into a loss value at a given size needs the fitted constant NcN_c as well.

QuestionIf a model grows by a factor of 8 in parameters, roughly how much data does it need to avoid overfitting, according to D proportional to N^0.74?Show answer

Compute 80.748^{0.74}. Since ln⁡8≈2.079\ln 8 \approx 2.079, we have 0.74×2.079≈1.5380.74 \times 2.079 \approx 1.538, and e1.538≈4.66e^{1.538} \approx 4.66. So the data should grow by about 4.7 times, which the paper rounds to 5. The model grows 8 times, but the data only needs to grow about 5 times. This is the sublinear scaling the paper emphasises.

QuestionWith a fixed compute budget, the paper recommends a larger model stopped before convergence. Why not train a smaller model to convergence instead?Show answer

Training to convergence spends compute on the last few percent of loss reduction, which a small model reaches slowly. The paper's allocation puts most of a larger budget into parameters, N∝C0.73N \propto C^{0.73}, and only a little into steps, S∝C0.03S \propto C^{0.03}. A large model stopped early therefore reaches a lower loss for the same compute than a small model run to convergence. The paper's data supports this for the budgets it measured, and it is why the recommended recipe stops well short of convergence.

QuestionThe exponents for N, B and S are 0.73, 0.24 and 0.03. Why do they sum to about 1, and what does that mean?Show answer

The compute estimate is C≈6NBSC \approx 6 N B S. If NN, BB and SS all scale as powers of Cmin⁡C_{\min}, their exponents must add up to the exponent of CC, which is 1. The paper's values sum to 0.73+0.24+0.03=1.000.73 + 0.24 + 0.03 = 1.00. Practically, this means a 10x increase in compute is split as about 5.4x in model size, 1.7x in batch size, and 1.1x in steps. The model absorbs almost all of it.

QuestionWhy does the paper report the loss on text from other distributions as a constant offset, and why does that matter?Show answer

When models are evaluated on text unlike WebText2, the loss is still a power law in NN with nearly the same exponent, and it sits at a roughly constant offset above the WebText2 loss (the paper's figure caption says the offset is small and very slowly growing). So improving the in-distribution loss also improves out-of-distribution loss by a predictable amount. A practical reading is that a bigger model transfers its gains to new text, and the penalty for a shift in the data stays small as the model scales.

Sources

Read the full paper

Jared Kaplan, Sam McCandlish, Tom Henighan et al., 2020. arXiv:2001.08361