How loss falls with parameters, data, and compute, how to fit those curves without fooling yourself, how to spend a training budget, and how to make hyperparameters carry over from a small model to a large one.
Chapter 9 · Section 9.1 · 50 min

Power laws and how to fit them

You have trained six language models, from 10 million to 300 million parameters, on the same data with the same recipe. Their final losses fall from 3.4 to 2.2 nats per token. Your manager asks the question that every frontier lab asks before every large run. If we spend a hundred times more and train a 30-billion-parameter model, what loss will it reach, and is that worth the money?

You cannot answer by training it, because that is the very thing you are trying to decide. You have to extrapolate, from six points, two orders of magnitude beyond the largest one. The most valuable empirical fact in modern AI is that this extrapolation often works. Loss falls with scale along a curve so regular that a straight line on the right axes predicts it. The second most valuable fact is that it is easy to draw that line wrong.

This section is about drawing it right. We define power laws and see why they are straight on log-log axes, add the irreducible loss that bends them, fit them by least squares in log space, and put honest error bars on extrapolations with the bootstrap. Everything later in the chapter, from Kaplan's laws to Chinchilla's budget rule to the prediction of downstream accuracy, is a power-law fit, and every one of them can fail in the ways shown here.

A function that looks the same at every scale

A power law is a function of the form

y=a x−k,a>0,y = a\,x^{-k}, \qquad a > 0,

where xx is the thing we scale (parameters, tokens, or compute), yy is what we measure (usually a loss), and kk is the exponent. We write the exponent with a minus sign because in this chapter the measured quantity falls as scale grows, so k>0k > 0.

The defining property is what happens when you multiply xx by a constant cc,

y(cx)y(x)=a (cx)−ka x−k=c−k.\frac{y(cx)}{y(x)} = \frac{a\,(cx)^{-k}}{a\,x^{-k}} = c^{-k} .

In plain words, doubling the model shrinks the loss by the same factor, 2−k2^{-k}, whether you double a tiny model or a giant one. A power law has no built-in scale. Zoom in or out on its graph and it looks the same, which is why physicists call such functions scale-free.

Compare an exponential, y=a e−λxy = a\,e^{-\lambda x}. There, adding a constant to xx multiplies yy by a constant, and doubling xx squares the remaining fraction. Exponentials die quickly. Power laws decay slowly and forever, with a long tail.

Taking logarithms of the power law turns multiplication into addition,

log⁡y=log⁡a−klog⁡x.\log y = \log a - k \log x .

In plain words, on axes where both xx and yy are drawn on a logarithmic scale, a power law is a straight line, and its slope is −k-k. An exponential, by contrast, is straight on semi-log axes (only yy logarithmic). The cell below draws both on all three kinds of axes.

Python · cell 1

The power law is the straight line on the right, and the exponential is the straight line in the middle. When someone shows you a scaling plot, the first thing to check is the axes. A "linear trend" on log-log axes is a power law, and its slope is the exponent.

Small exponents, enormous multipliers

The exponents that appear in language modeling are small. Kaplan et al. (2020) measured k≈0.076k \approx 0.076 for loss against parameters and k≈0.05k \approx 0.05 for loss against compute (§9.2). Small exponents hide a brutal fact. To reduce the loss by a factor rr you must multiply scale by

c=r−1/k,so for r=0.9 and k=0.05,c=0.9−20≈8.2.c = r^{-1/k}, \qquad\text{so for } r = 0.9 \text{ and } k = 0.05,\quad c = 0.9^{-20} \approx 8.2 .

In plain words, a ten percent lower loss costs about eight times the compute, and the next ten percent costs eight times more again. This is the arithmetic behind training budgets that grow by orders of magnitude between model generations.

Python · cell 2

To halve a pure power-law loss with k=0.076k = 0.076 you would need about 9,000 times more parameters. Real losses do not halve at all, as we will see in a moment, because part of the loss cannot be removed.

Why would loss follow a power law?

Nobody derived scaling laws from first principles and then checked them. They were found in data. Hestness et al. (2017) trained models for translation, language modeling, image classification, and speech recognition on growing subsets of data and found that generalization error fell as a power law in dataset size in every domain, with exponents between about 0.07 and 0.35 (word-level language models sat at the shallow end, near 0.07). They also described three regions of a learning curve. With very little data the model does no better than a best guess, then it enters a power-law region, and finally it flattens against an irreducible error. Kaplan et al. (2020) then showed the same regularity for Transformer language models against parameters, data, and compute, over many orders of magnitude.

Several theories try to explain the regularity. They are hypotheses with supporting evidence, not settled results.

  • The data manifold. Sharma and Kaplan (2020) argue that a network fits data lying on a manifold of intrinsic dimension dintd_{\text{int}}, and that the error of a piecewise approximation with NN parameters falls like N−4/dintN^{-4/d_{\text{int}}} for a smooth target and cross-entropy loss. Small exponents then mean high intrinsic dimension.
  • Variance-limited and resolution-limited regimes. Bahri et al. (2021) separate the regime where one resource is nearly unlimited and the loss approaches its limit like 1/x1/x (a variance effect) from the regime where the resolution of the fit limits it, which gives the small exponents seen in practice.
  • Quanta. Michaud et al. (2023) propose that a model learns discrete skills ("quanta") whose usefulness follows a Zipf distribution. The derivation below shows how that alone produces a power law.
∂ A power law from Zipf-distributed skills

Suppose the knowledge needed to predict text comes in discrete pieces, ordered from most to least useful, and piece jj is needed on a fraction pjp_j of tokens, with

pj=j−(1+γ)Z,γ>0,Z=∑j≥1j−(1+γ).p_j = \frac{j^{-(1+\gamma)}}{Z}, \qquad \gamma > 0, \qquad Z = \sum_{j \ge 1} j^{-(1+\gamma)} .

Assume a model that has learned pieces 11 to nn predicts those tokens well, and pays an extra loss bb on each token that needs a piece it lacks. Its expected loss is the floor plus bb times the probability mass of the missing pieces,

L(n)=E+b∑j>npj≈E+bZ∫n∞t−(1+γ) dt=E+bZγ n−γ.\mathcal{L}(n) = E + b\sum_{j > n} p_j \approx E + \frac{b}{Z}\int_n^\infty t^{-(1+\gamma)}\,dt = E + \frac{b}{Z\gamma}\, n^{-\gamma} .

(The sum is approximated by the integral, which is accurate for large nn because the summand changes slowly.) If the number of pieces a model can hold grows in proportion to its parameter count NN, then n∝Nn \propto N and

L(N)=E+A N−γ\mathcal{L}(N) = E + A\,N^{-\gamma}

for a constant AA. A heavy-tailed distribution of skills, learned most-frequent first, produces exactly a power law with a floor. The exponent of the loss is the tail exponent of the skill distribution.

For the rest of the chapter we treat power laws as what they are, the best empirical description we have, valid over the range where they were measured and no further without evidence.

The floor you cannot get below

Language is not deterministic. After "I had a cup of" the next word might be "tea" or "coffee", and no model, however large, can know which. Recall from §0.5 and §3.1 that the cross-entropy of a model qq on data from pp splits as H(p,q)=H(p)+DKL(p∥q)H(p, q) = H(p) + D_{\mathrm{KL}}(p \Vert q). Training can drive the KL term toward zero, but the entropy H(p)H(p) of the text itself is a floor. A pure power law ignores this. It promises that the loss goes to zero.

The fix is to add a constant. The saturating power law is

L(x)=E+A x−α,E≥0,  A>0,  α>0.\mathcal{L}(x) = E + A\,x^{-\alpha}, \qquad E \ge 0,\; A > 0,\; \alpha > 0 .

Here L\mathcal{L} is the loss, xx is the scaled resource, EE is the irreducible loss, and A x−αA\,x^{-\alpha} is the reducible part. In plain words, the loss is a floor that no amount of scale removes, plus an excess that falls as a power law.

EE is best read as "the loss this family of models would reach with unlimited scale on this data, with this tokenizer". It estimates the entropy of the text, but it also absorbs any limitation shared by all the models, so it is a fitted parameter, not a measured constant. Chinchilla's fit (§9.3) put it at E=1.69E = 1.69 nats per token on its data.

The floor bends the line

Take logarithms of the saturating law and the straight line is gone. The local slope on log-log axes is

dlog⁡Ldlog⁡x=1L dLdx x=−αA x−αE+A x−α=−α L−EL.\frac{d\log\mathcal{L}}{d\log x} = \frac{1}{\mathcal{L}}\,\frac{d\mathcal{L}}{dx}\,x = \frac{-\alpha A\,x^{-\alpha}}{E + A\,x^{-\alpha}} = -\alpha\,\frac{\mathcal{L} - E}{\mathcal{L}} .

In plain words, the slope you see on a log-log plot is the true exponent multiplied by the fraction of the loss that is still reducible. Early on, when most of the loss is reducible, the slope is close to −α-\alpha. As models approach the floor, the reducible fraction shrinks and the curve flattens.

Here is a worked example with Chinchilla's constants for the parameter term, E=1.69E = 1.69 and α=0.34\alpha = 0.34. At a loss of 3.0 the reducible fraction is 1.31/3.0=0.441.31/3.0 = 0.44, so the local slope is −0.34×0.44=−0.15-0.34 \times 0.44 = -0.15. At a loss of 2.0 it is 0.31/2.0=0.1550.31/2.0 = 0.155, and the slope is −0.053-0.053. The same law looks three times flatter at the large end than at the small end.

This is the first way a naive fit misleads. Fit a straight line on log-log axes to small models and you measure the steep early slope. Extend that line and it predicts losses far below what large models achieve, eventually below the floor itself.

Python · cell 3

From models up to 316 million parameters the straight line has slope −0.123-0.123, and at 30 billion parameters it already predicts 1.24 nats, below the floor of 1.69, when the truth is 1.80. At 300 billion it predicts 0.94 against a truth of 1.74. Every number in this cell is noiseless. The error comes entirely from using the wrong functional form.

Warm-up

The local exponent of a saturating law

Implement local_exponent(x, E, A, alpha) returning the local log-log slope dlog⁡L/dlog⁡xd\log\mathcal{L}/d\log x of L(x)=E+Ax−α\mathcal{L}(x) = E + Ax^{-\alpha}, elementwise for an array x. It is negative, and its magnitude is at most alpha.

Hidden tests, hints, and AI help, from $1.99 a month.

Fitting a pure power law, and why in log space

Start with the easy case, data that follow y=ax−ky = a x^{-k} up to noise. Taking logs gives a linear model, log⁡yi=log⁡a−klog⁡xi+εi\log y_i = \log a - k\log x_i + \varepsilon_i, so ordinary least squares on the points (log⁡xi,log⁡yi)(\log x_i, \log y_i) gives the answer in closed form. With ui=log⁡xiu_i = \log x_i and vi=log⁡yiv_i = \log y_i,

−k^=∑i(ui−uˉ)(vi−vˉ)∑i(ui−uˉ)2,log⁡a^=vˉ+k^ uˉ,-\hat k = \frac{\sum_i (u_i - \bar u)(v_i - \bar v)}{\sum_i (u_i - \bar u)^2}, \qquad \log\hat a = \bar v + \hat k\,\bar u ,

where bars are means. In plain words, the exponent is the slope of the best straight line through the log-log plot, and the prefactor comes from its intercept. With two points the line is exact, and you can do it by hand. Two models of 10810^8 and 10910^9 parameters with losses 3.10 and 2.70 give k^=log⁡(3.10/2.70)/log⁡10=0.060\hat k = \log(3.10/2.70)/\log 10 = 0.060, and a third point is what tells you whether a straight line was the right model at all.

Why fit in log space rather than minimizing ∑i(yi−axi−k)2\sum_i (y_i - a x_i^{-k})^2 directly? There are two reasons, and both matter for scaling laws.

  1. The noise is relative. Rerunning a training job with a new seed changes its loss by a roughly fixed percentage, not a fixed amount. Squared error in log space, (log⁡yi−log⁡y^i)2≈((yi−y^i)/yi)2(\log y_i - \log\hat y_i)^2 \approx ((y_i - \hat y_i)/y_i)^2, weights every point by its relative error, which matches that noise.
  2. Linear space lets the largest values dominate. The smallest models have the largest losses, so a linear-space fit spends its effort on them and treats the large models, the ones closest to what you want to predict, as afterthoughts.

The cell below fits the same noisy data both ways.

Python · cell 4

Both fits are right on average, but the linear-space estimate is almost three times as noisy (a spread of 0.009 against 0.003), because it effectively listens only to the few smallest-xx points with the largest values. An exponent that wobbles by 0.009 sounds harmless until you extrapolate. Over four decades, it moves the prediction by 104×0.009−1≈910^{4 \times 0.009} - 1 \approx 9 percent.

Warm-up

Fit a pure power law in log space

Implement loglog_fit(x, y) returning (a, k) for the model y=a x−ky = a\,x^{-k}, fitted by least squares on (log⁡x,log⁡y)(\log x, \log y). Return k as a positive number when yy falls with xx, and a on the original scale, not its logarithm.

Hidden tests, hints, and AI help, from $1.99 a month.

Fitting with an irreducible term

Now the real case, L(x)=E+Ax−α\mathcal{L}(x) = E + A x^{-\alpha}, with three unknowns. The model is no longer linear in its parameters, so there is no closed form, and the loss surface has awkward valleys. There are three good ways to fit it, and you should know all of them.

Profile over the floor (variable projection). If you knew EE, the rest would be easy, since log⁡(L−E)=log⁡A−αlog⁡x\log(\mathcal{L} - E) = \log A - \alpha\log x is a straight line. So try many values of EE between 0 and just below the smallest observed loss, fit the line for each, and keep the EE whose fit has the smallest error in log space. This search over one variable is robust, cannot get stuck in a bad local minimum, and gives a profile of the error against EE that shows how well determined the floor is.

Nonlinear least squares in log space. Minimize ∑i(log⁡yi−log⁡(E+Axi−α))2\sum_i \big(\log y_i - \log(E + A x_i^{-\alpha})\big)^2 with a general optimizer such as scipy.optimize.least_squares, starting from the profile solution or from several starting points.

The Chinchilla recipe. Hoffmann et al. (2022) fit their two-variable law (§9.3) by minimizing a Huber loss of the log residuals with L-BFGS, from a grid of starting points. They write the model as a log-sum-exp, which keeps EE and AA positive automatically and makes the problem better conditioned,

log⁡L^(x)=LSE⁡(a−αlog⁡x,  e),A=ea,  E=ee.\log\hat{\mathcal{L}}(x) = \operatorname{LSE}\big(a - \alpha\log x,\; e\big), \qquad A = e^{a},\; E = e^{e} .

In plain words, the logarithm of a sum of two positive terms is the log-sum-exp of their logarithms, so we can optimize aa and ee freely over the real line. The Huber loss is quadratic for small residuals and linear for large ones, so a single bad run (a diverged job, a mislabeled checkpoint) cannot drag the whole fit. Chinchilla used a threshold of δ=10−3\delta = 10^{-3} on log-loss residuals. We implement this version in PyTorch at the end of the section.

Interview

Fit a power law with an irreducible loss

Implement fit_saturating(x, y) returning (E, A, alpha) for y≈E+Ax−αy \approx E + A x^{-\alpha}, minimizing squared error in log space. Your fit must handle data whose true floor is zero, must keep 0≤E0 \le E below the smallest observed y, and must be accurate enough to extrapolate. This is a classic interview task at labs that train large models, and a fit that "usually works" is not good enough. Use NumPy and SciPy only.

Hidden tests, hints, and AI help, from $1.99 a month.

How far can you extrapolate?

Even with the right functional form, a fit to a short range of scales cannot pin down all three parameters. The reason is a near-degeneracy. Over a few decades, a law with a lower floor and a smaller exponent looks almost exactly like one with a higher floor and a larger exponent, because both bend by about the same amount inside the range. They separate only beyond it, which is precisely where you want to predict.

You can see this by profiling. Fix EE, fit the best AA and α\alpha, and plot the remaining error against EE.

Python · cell 5

With twelve models from 10710^7 to 108.510^{8.5} parameters (blue), every floor from 1.52 to 1.78 fits within a factor of two of the best error, and those floors predict anything from 1.59 to 1.80 at 101210^{12} parameters. With two more decades of models (orange), the valley is sharp, only the true floor survives, and the prediction is pinned to within a few thousandths. The lesson is that the range of scales you fit matters more than the number of points. Ten models spread over three decades beat thirty models crowded into one.

How far can you trust a power law fitted to small models?
Each dot is the loss of one model, drawn from a saturating power law with noise. Drag the fit range, choose the model you fit, and compare the prediction at a million times the smallest size with the truth.
Loading interactive figure…

Error bars with the bootstrap

A single fitted curve hides how uncertain it is. The simplest honest error bar for an extrapolation is the bootstrap (Efron 1979), which §0.11 used for test-set statistics. Here the resampled unit is a training run rather than a test question. Pretend your nn data points are the whole population. Draw nn points from them with replacement (some appear twice, some not at all), refit, and record the prediction at the scale you care about. Repeat a few hundred times. The spread of the recorded predictions estimates how much the prediction would change if you had run a different set of models of similar sizes.

Two cautions. The bootstrap measures only the uncertainty that comes from noise in the points you have. It cannot know that the true curve breaks to a different slope beyond your data, a real phenomenon that Caballero et al. (2022) model with broken power laws, smooth joins of several power-law segments. And resampling points requires enough of them for each resample to contain distinct scales, so with six models the band itself is noisy. With so few runs, a common alternative is the residual bootstrap. Fit once, then build each replicate by adding resampled log residuals to the fitted curve at the original scales, which keeps every scale in every replicate at the price of assuming the functional form is right. Besiroglu et al. (2024) turned this reasoning around, asked how many runs an interval as narrow as Chinchilla's would need, and concluded that the published intervals were far too narrow to be true (§9.3).

Core

Bootstrap an extrapolation

Implement bootstrap_predict(x, y, x_new, fit, n_boot=200, seed=0) returning (median, lo, hi), the median and the 5th and 95th percentiles of the bootstrap distribution of the prediction at x_new. fit(x, y) returns (E, A, alpha) and the setup provides a fast one. Use rng = np.random.default_rng(seed) and, for each of the n_boot replicates in order, idx = rng.integers(0, n, size=n) to resample pairs (xi,yi)(x_i, y_i) together. Skip a replicate whose resample has fewer than 3 distinct x values (but still draw its indices, so the random stream stays in step). Use np.percentile for all three numbers.

Hidden tests, hints, and AI help, from $1.99 a month.

Here is the bootstrap applied to our six small models, and then to ten models reaching two decades further, with each band drawn over the whole range of scales.

Python · cell 6

With six models up to 3×1083\times10^8 parameters, the 90 percent band at 101210^{12} runs from 1.13 to 1.90 nats, far too wide to plan with, and its lower edge sits below the true floor of 1.69. With ten models reaching 101010^{10}, it narrows to 1.70 to 1.75 and contains the truth, 1.72. Most of that gain comes from the wider range, as the profile above showed with the number of models held fixed.

The ways a scaling fit goes wrong

Most failed extrapolations are not caused by the fitting algorithm. They come from the data that went into it. Here are the mistakes that recur, with where in this chapter each one is examined.

mistakewhat it doesthe fix
pure power law where a floor existspredicts too much improvement, eventually below the entropy of the datafit E+Ax−αE + Ax^{-\alpha}, or fit log⁡(L−E)\log(\mathcal{L} - E) with EE known
a narrow range of scalesfloor and exponent trade off, the extrapolation is unconstrainedspread models over as many decades as you can afford
models outside the power-law regiontiny models sit in the "best guess" region, and models trained on too little data overfitdrop the smallest models, and keep data large enough for every size
intermediate checkpoints of a long schedulea run's loss mid-way through a cosine schedule overstates the loss of a run tuned for that lengthtrain each point to the end of its own schedule (§9.2, §9.3)
hyperparameters tuned at one size onlylarge models are under-tuned, the curve bends upwardretune per size, or use muP so the tuning transfers (§9.5)
inconsistent countingnon-embedding versus total parameters, or FLOP counts that omit the output layer, change the exponentcount everything, and say what you counted (§9.2)
losses compared across tokenizersnats per token are not comparable between vocabulariescompare bits per byte (§6.6)

In PyTorch

The Chinchilla fitting recipe, in one dimension. The model is written as a log-sum-exp, the objective is a Huber loss on log residuals, and L-BFGS starts from a small grid of initial values, keeping the best result. This is the same procedure §9.3 applies to the two-variable law.

🔥 In PyTorchfor a machine with PyTorch

With twelve noisy models over three decades, AA comes out 28 percent high, α\alpha a little high, and EE a little high, errors that largely cancel. The prediction a hundred times past the data is off by 0.012 nats, under 1 percent. That is the near-degeneracy of the previous section in action. Individual constants are poorly determined, while the predictions they make together near the data are much better determined.

Note reduction="sum". Besiroglu et al. (2024) traced part of Chinchilla's fitting problem to averaging the Huber losses instead of summing them, which shrinks the objective so much that the optimizer's stopping tolerance is reached too early (§9.3).

Read more

Watch next

🎬 AI can't cross this line and we don't know why. · Welch LabsA beautifully animated tour of the compute-efficient frontier, the power laws behind it, and the data-manifold theory of where the exponents come from.
🎬 Lec 20. Scaling Laws · MIT OpenCourseWarePhillip Isola's MIT lecture on power laws in deep learning, their limits, and the theories that try to explain them.