← All tutorials

On this page

1 Power laws in data, model size and compute 2 Estimating the irreducible loss 3 Compute-optimal model size and data 4 Fitting a scaling law 5 Common fitting mistakes 6 References

Scaling Laws

How test loss falls as data, model size and compute grow.

Once a model trains well with the controls in Optimizers in Practice: AdamW, SAM, Schedules and Clipping, how much data, model size and compute should it get? Scaling laws say test loss, the error on unseen data, falls as a power of the data, the parameters (the numbers inside the model, its size) or the compute. A fit runs once, after finished runs at several sizes, and costs only those runs; its compute-optimal split is chosen before the large run.

1 Power laws in data, model size and compute

A power law, found empirically across many domains, raises the resource you grow to a power.

Every law on this page is an irreducible loss plus a gap that shrinks as a power of the resource.
L = L∞ + A · X−α
The test loss L is the irreducible loss L∞ plus a gap that shrinks as the resource X grows. X is data, parameters or compute; L∞ is the loss no amount of X gets under, set by noise in the data; A is the gap at X = 1; and the exponent α (alpha) sets how fast the gap closes. The minus sign is what makes the gap shrink: each doubling of X cuts it by the same fraction.
log(L − L∞) = log A − α · log X
Taking the log of the gap turns the power into a straight line in log X, with slope minus α and intercept log A. That is why scaling plots use log-log axes, where each equal step multiplies the value by the same factor; a steeper line means a larger α.

Compute is counted in FLOPs, multiplies or adds on floating-point numbers, about six per parameter per token for the forward and backward pass. The total a run may use is its compute budget.

An illustrative compute law; its exponent is near the 0.05 Kaplan et al. (2020) measured, and real coefficients come from your own runs.

The compute law is an irreducible loss plus a gap that shrinks as compute grows.
L = 1.5 + 2.0 · C−0.05
Loss falls from a starting gap of 2.0 toward an irreducible loss of 1.5 as compute C grows, with α = 0.05. An exponent that small means progress comes only from multiplying compute, never from adding to it.
Multiplying the resource shrinks the gap by a fixed factor.
gap aftergap before = k−α
Grow the resource k times and the gap above the irreducible loss is multiplied by k to the minus α, wherever you start. Every 10× removes the same fraction of the remaining gap, and since the gap keeps shrinking, that fraction is worth fewer points of loss each time.
0 0.5 1 1 10 10³ 10⁶ times more resource (log scale) 89% 50% 71% compute, α = 0.05 data, α = 0.5

Figure 1. Share of the gap kept on this page's toy laws, for each multiple of a resource.

Do not compare the exponents: the resources differ in units, and more compute buys both data and parameters.

a straight line10181024compute (log scale)gap (log scale)

Figure 2. The illustrative compute law drawn on log-log axes.

power law (illustrative) your budget 10× more

Figure 3. Every 10× of compute lowers the loss by less than 0.03.

2 Estimating the irreducible loss

If more data still lowers the test loss, the irreducible loss, the irreducible error no run removes, is not reached. Only the gap above it follows the power law, so only the right guess makes the gap straight on log-log axes.

Over data size the law keeps the same form, an irreducible loss plus a gap.
L = 1.5 + 2√D
Loss is an irreducible loss of 1.5 plus a gap of 2 over the square root of the data size D. The square root is a power of 0.5, so four times the data halves the gap. The five illustrative runs come from this curve.
guess too lowright end flattensguess righta straight lineacross: data size (log scale)up: loss above the guess (log)

Figure 4. The loss gap on log axes, for a guess too low and for the right guess.

The runs are made with irreducible loss 1.5 and true α = 0.50, which a good fit recovers. straightness scores a guess by how close log D and the log gap are to a line, 1 for a perfect one.

import numpy as np

# five runs: sizes, losses
D = np.logspace(3, 7, 5)
L = 1.5 + 2 / np.sqrt(D)
log_D = np.log(D)

def straightness(floor):
    g = np.log(L - floor)
    c = np.corrcoef(log_D, g)
    return abs(c[0, 1])
  1. 1Five runs, irreducible loss 1.5, α = 0.5.
  2. 2Straightness of the log gap against log D.

The sweep tries 50 guesses from 1.3 to just under the lowest loss, keeping every gap positive.

# keep every gap above 0
top = 0.9999 * L.min()
floors = np.linspace(1.3, top)
s = []
for f in floors:
    s.append(straightness(f))
floor = floors[np.argmax(s)]
g = np.log(L - floor)
fit = np.polyfit(log_D, g, 1)
k, log_A = fit
alpha = -k  # slope is −α
  1. 1Keep the straightest guess.
  2. 2Line fit; slope minus α, intercept log A.
straightness
one run per data size straight-line fit

Figure 5. The guess where straightness peaks is the irreducible loss.

A high irreducible loss means noisy data, so no model gets much lower; a large exponent such as 0.5 means more data still lowers the loss quickly.

The same law works over model size and compute; under a hard compute cap, as on a small device, it gives the best reachable loss.

3 Compute-optimal model size and data

At one compute budget a bigger model leaves fewer training tokens, so which split of the budget gives the lowest loss?

Models used to grow much faster than their data. Hoffmann et al. (2022) trained Chinchilla and showed that at a fixed budget, model size and training tokens (word-pieces of text, the unit the model reads) should scale together, about 20 tokens per parameter: 70B (billion) parameters on 1.4T (trillion) tokens.

Loss depends on parameters and tokens together, under one compute budget.
L = L∞ + AN·N−αN + AD·D−αD
Loss is the irreducible loss plus one gap per resource: the parameter count N and the token count D each shrink their own term, with their own constant and exponent. Because the gaps add, growing only one resource leaves the other term as a lower bound, so a huge model trained on few tokens stops improving once the data term dominates. The paper's fit uses other letters: its E = 1.69 is L∞, its A = 406.4 and α = 0.34 are AN and αN, and its B = 410.7 and β = 0.28 are AD and αD.
C = 6 · N · D
Compute C is about six times N times D: roughly 2 FLOPs per parameter per token for the forward pass and 4 for the backward pass. For a fixed C, a bigger N forces a smaller D, so the question is how to split one product between the two gap terms.
Data-limitedL∞paramsdatagrow the dataModel-limitedL∞paramsdatagrow the model
Figure 6. Loss as a stack on L∞; the bigger piece says what to grow.

The split in NumPy at 1023 FLOPs with the Chinchilla paper's constants: E is the irreducible loss L∞, A and B the constants, α and β the exponents.

import numpy as np
# the Chinchilla paper's fit
E, A, B = 1.69, 406.4, 410.7
alpha, beta = 0.34, 0.28
C = 1e23  # FLOPs
N = np.logspace(8, 12, 400)
D = C / (6 * N)  # C = 6·N·D
L_N = A / N**alpha
L_D = B / D**beta
L = E + L_N + L_D
best = np.argmin(L)
ratio = D[best] / N[best]
  1. 1Fitted constants and budget C.
  2. 2400 sizes N, each with the tokens D left.
  3. 3Score each split.
  4. 4Best split, tokens per parameter.

Too param-heavy, the model has more parameters than its tokens can train; too data-heavy, it is too small to use its tokens.

bottom of the Uparam-heavydata-heavytokens per parameter (log scale)loss

Figure 7. Loss against the split at one compute budget.

predicted loss vs split your split optimum

Figure 8. The curve of Figure 7; the readout gives your split's loss above the optimum.

The best ratio is very sensitive to how the fitted constants are rounded.

1101001000Chinchilla, 20refit near 20 toothis page, 78rounded fittokens per parameter (log scale)
Figure 9. Best tokens per parameter at 1023 FLOPs; the refit is Besiroglu et al. 2024.

4 Fitting a scaling law

The law is fit once, to the final losses of finished runs; the Chinchilla paper fit all its constants together, minimizing a Huber loss on the log losses with L-BFGS from a grid of starts. The snippet does this in SciPy on the five runs; bounds keep the irreducible loss and A positive (so SciPy uses L-BFGS-B), and fit.x holds the irreducible loss, A and α.

import scipy.optimize as so
from scipy.special import huber
def cost(p):  # floor L∞, A, α
    floor, A, a = p
    pred = floor + A / D**a
    gap = np.log(pred / L)
    h = huber(1e-3, gap)  # δ
    return h.sum()
x0 = [1.0, 1.0, 0.3]
pos = (0, None)
B = [pos, pos, (0.01, 2)]
opt = so.minimize
fit = opt(cost, x0, bounds=B)
  1. 1Huber loss on the log losses.
  2. 2Start and bounds.
  3. 3Fit all three, L-BFGS-B.

The fit takes seconds; each point is a full training run, and the Chinchilla paper trained over 400 models. Its Huber δ was 10−3 (a larger δ is closer to squared error, a smaller one ignores large misses more), robust to outliers and good at predicting held-out runs, with C ≈ 6·N·D (Chinchilla paper). It released no fitting code; the 2024 replication publishes data and code (replication paper).

5 Common fitting mistakes

symptomlikely causefix or reading
The fitted line bends at the right endirreducible loss guessed too lowrefit the irreducible loss (Section 2)
A fit on two nearby sizesany slope fits two pointsfit across sizes spread over several powers of ten
Not enough fresh datarepeating the same dataup to 4 epochs of repeats changed loss negligibly; beyond that, returns fade (Muennighoff et al. 2023)
A capability appears suddenlyloss is smooth, but capabilities can jump (emergence)use the law to plan data, model size and compute, not to predict skills

6 References

  1. Kaplan, J., et al. (2020). Scaling laws for neural language models. arXiv:2001.08361.
  2. Hoffmann, J., et al. (2022). Training compute-optimal large language models. arXiv:2203.15556.
  3. Muennighoff, N., et al. (2023). Scaling Data-Constrained Language Models. arXiv:2305.16264.
  4. Besiroglu, T., et al. (2024). Chinchilla Scaling: A replication attempt. arXiv:2404.10102.