AI Wiki中文/EN

Scaling laws: fit a curve without promising the future

缩放定律

Fit a synthetic loss curve with a floor, test withheld sizes, and expose a failed extrapolation after a regime change.

On this pageIntuitionMathematics & methodImplementationLimitationsExercisesResearch connections

Four times larger: which error is supposed to halve?

Imagine a synthetic experiment whose loss follows L=1.2+3/NL=1.2+3/\sqrt N, where NN is model size measured in millions of parameters. At N=1N=1, the loss is 4.2; at N=4N=4, it is 2.7. The model grew fourfold, yet its total loss did not halve. What halved was the part above the 1.2 floor: from 3 to 1.5.

A scaling law is a compact empirical description of how a measured quantity changes as resources grow under specified conditions. It can help plan experiments and check whether a larger run behaves as expected. It is not a theorem that every capability improves at the same rate or that a fitted curve remains valid indefinitely.

Kaplan and colleagues studied language-model cross-entropy against model size, data and compute, with power-law trends when the other resources did not create bottlenecks. Hoffmann and colleagues later used different experiment designs and fitted a loss surface involving both model size and training tokens. The change in experimental protocol is part of the scientific story, not an inconvenient detail to remove from a neat chart.

A floor-aware synthetic fit predicts two withheld sizes, but a constructed regime change raises its error without changing the fit.
A floor-aware synthetic fit predicts two withheld sizes, but a constructed regime change raises its error without changing the fit.

Define the measurement before fitting its shape

For a held-out token sequence with TT prediction targets, the mean next-token negative log-likelihood is

L=−1T∑t=1Tlog⁡pθ(xt∣x<t).L=-\frac1T\sum_{t=1}^{T}\log p_\theta(x_t\mid x_{<t}).

Natural logarithms give nats per token. The evaluation corpus, tokenizer, context window, masking and aggregation rule belong to the measurement. Changing the tokenizer changes what one token means. Lower per-token loss under a different tokenizer is not, by itself, proof of a better model.

One conditional scaling curve takes the form

L(N)=E+AN−α,E≥0, A>0, α>0.L(N)=E+AN^{-\alpha},\qquad E\ge0,\ A>0,\ \alpha>0.

EE is a fitted floor, AA an amplitude and α\alpha the exponent. In a finite experiment, the fitted floor need not equal the true entropy of natural language. Unmodeled data limits, optimization effects and a short measurement range can all change the inferred parameters. Specify the unit of NN: using millions instead of individual parameters changes the amplitude, though it need not change the exponent for the same curve.

If the floor were known, subtracting it would make a log–log relationship linear:

log⁡(L−E)=log⁡A−αlog⁡N.\log(L-E)=\log A-\alpha\log N.

Taking log⁡L\log L instead silently assumes E=0E=0. With a positive floor, that fit can produce a different apparent slope. Also, least squares in log loss and least squares in raw loss weight errors differently; comparing their numbers without stating the objective confounds the floor assumption with the noise model.

For a resource multiplier rr, the law predicts a ratio for the excess loss:

L(rN)−EL(N)−E=r−α.\frac{L(rN)-E}{L(N)-E}=r^{-\alpha}.

With α=0.5\alpha=0.5 and r=4r=4, the ratio is one half. This does not specify factual accuracy, a benchmark pass rate or inference latency. Those require their own observations and conditions.

Our teaching fit uses a grid of candidate exponents and minimizes squared residuals in the original loss units:

SSE⁡(E,A,α)=∑i∈train[Li−E−ANi−α]2.\operatorname{SSE}(E,A,\alpha)=\sum_{i\in\mathrm{train}}\left[L_i-E-AN_i^{-\alpha}\right]^2.

For each fixed exponent, the remaining two coefficients are a linear least-squares problem. With one row Xi=(1,Ni−α)X_i=(1,N_i^{-\alpha}), solve

(E^α,A^α)=arg min⁡E,A∥Xα(E,A)⊤−L∥22.(\widehat E_\alpha,\widehat A_\alpha)=\operatorname*{arg\,min}_{E,A}\|X_\alpha(E,A)^\top-L\|_2^2.

Discard negative-floor or nonpositive-amplitude fits, then keep the exponent with the smallest SSE. This is a finite-grid estimate, not an exact continuous optimum. With gg exponent candidates and mm observations, solving a two-column problem at each candidate costs O(gm)O(gm) arithmetic and O(m)O(m) working memory. Exponent profiling, residual plots and leave-one-out sensitivity can reveal instability; a sensitivity range is not automatically a confidence interval.

In a two-resource experiment, Hoffmann’s paper proposes

L^(N,D)=E+ANα+BDβ.\widehat L(N,D)=E+\frac{A}{N^\alpha}+\frac{B}{D^\beta}.

Here DD is the number of training tokens seen, not necessarily the count of unique documents. Their section 3.3 fits log-loss residuals with a Huber objective and L-BFGS, using multiple initializations. That differs from our one-variable raw-loss least squares. Deriving the best allocation at fixed compute is the separate catalogue topic “Compute-optimal training”; the present question is how to measure, fit and test the curve first.

Hide the largest two sizes from the fitter

The following complete Python 3.12/NumPy 1.26.4 program creates eight authored measurements, not data from either paper. The generating rule is 1.2+3/N1.2+3/\sqrt N plus fixed small perturbations. Fit only the first six sizes, from 1 to 32 million nominal parameters; reserve 64 and 128 for extrapolation checks. No neural network is trained and no actual parameter memory is allocated.

"""Fit original synthetic loss measurements, not published LLM experiments."""
import json
import math
import numpy as np


def measurements():
    sizes = 2.0 ** np.arange(8)
    noise = np.array([.004, -.006, .003, -.002, .005, -.004, .003, -.003])
    return sizes, 1.2 + 3 / np.sqrt(sizes) + noise


def fit(sizes, losses):
    n, y = np.asarray(sizes, float), np.asarray(losses, float)
    if n.ndim != 1 or y.shape != n.shape or len(n) < 3:
        raise ValueError("Need at least three paired observations")
    if not np.all(np.isfinite(n)) or not np.all(np.isfinite(y)) or np.min(n) <= 0:
        raise ValueError("Sizes must be positive and all observations finite")
    if np.min(y) <= 0 or len(np.unique(n)) < 3:
        raise ValueError("Need positive losses at three distinct sizes")
    best = None
    # For each exponent, floor and amplitude are a two-variable linear fit.
    for alpha in np.linspace(.1, 1.2, 1101):
        matrix = np.column_stack([np.ones_like(n), n ** -alpha])
        floor, amplitude = np.linalg.lstsq(matrix, y, rcond=None)[0]
        if floor < 0 or amplitude <= 0:
            continue
        sse = float(np.sum((matrix @ [floor, amplitude] - y) ** 2))
        if best is None or sse < best["sse"]:
            best = dict(floor=float(floor), amplitude=float(amplitude),
                        alpha=float(alpha), sse=sse)
    if best is None:
        raise ValueError("No admissible decreasing power law in this exponent grid")
    return best


def predict(sizes, model):
    n = np.asarray(sizes, float)
    if np.any(n <= 0) or not np.all(np.isfinite(n)):
        raise ValueError("Sizes must be finite and positive")
    return model["floor"] + model["amplitude"] * n ** -model["alpha"]


def demo():
    n, loss = measurements()
    train_n, train_y = n[:6], loss[:6]
    model = fit(train_n, train_y)
    pred = predict(n, model)
    slope, intercept = np.polyfit(np.log(train_n), np.log(train_y), 1)
    zero_floor = np.exp(intercept) * n ** slope
    changed_regime = loss[6:] + .3
    leave_one_out = [fit(np.delete(train_n, i), np.delete(train_y, i))["alpha"] for i in range(6)]
    return dict(size_millions=n.tolist(), synthetic_loss=loss.tolist(), fit=model,
                fitted=pred.tolist(), zero_floor=zero_floor.tolist(),
                zero_floor_alpha=float(-slope),
                heldout_rmse=float(np.sqrt(np.mean((pred[6:] - loss[6:]) ** 2))),
                shifted_heldout_rmse=float(np.sqrt(np.mean((pred[6:] - changed_regime) ** 2))),
                changed_regime=changed_regime.tolist(),
                leave_one_out_alpha=leave_one_out,
                reduction_at_four_times=4 ** -model["alpha"])


if __name__ == "__main__":
    print(json.dumps(demo(), ensure_ascii=False, indent=2))

The fit returns approximately E=1.204376E=1.204376, A=2.997669A=2.997669 and α=0.502\alpha=0.502. The two held-out losses have an RMSE of about 0.003559. A zero-floor log–log fit instead gives an exponent near 0.256152; it uses both a different floor assumption and a different residual objective, so do not interpret the difference as an isolated estimate of one effect.

Now change only the two held-out synthetic measurements by adding 0.3. This explicitly constructed regime change leaves the training fit untouched but raises held-out RMSE to about 0.298723. A convincing line through the small runs cannot rule out a change beyond the measured regime.

Leaving out one training observation at a time gives exponents between 0.488 and 0.509. That is a sensitivity diagnostic for these six points. It is not a probabilistic uncertainty interval: the perturbations are fixed, no sampling model is specified, and we have not sampled repeated training runs.

Tests recover an exact known curve, verify least-squares normal equations, convert millions to individual parameters, and check both ordinary and changed-regime held-out behavior. The numerical example teaches curve fitting and failure analysis; it supplies no estimate of the performance of a real large language model.

Keep experiments comparable before comparing exponents

Kaplan’s selected setup counts non-embedding parameters, uses WebText2 and reports specific context and training choices. Their Figure 1 separates parameter, data and compute curves. A model trained nearly to convergence with abundant data is not the same experiment as one stopped at a fixed total compute budget. At fixed compute, increasing parameter count can reduce the amount of training; the resulting curve need not be monotonically decreasing. The original setup makes those axes and conditions explicit.

Hoffmann and colleagues compare training-curve envelopes, fixed-compute profiles and a parametric loss surface. In their account, matching the learning-rate decay schedule to the intended training horizon matters; sampling an early point from a much longer schedule can overestimate the loss attainable at that shorter horizon. They also discuss a different model-size range. These are the authors’ supported protocol comparisons, not this encyclopedia independently proving that a single factor explains every difference. Sections 2 and 3 provide the relevant methods.

For your own study, begin with a table of runs: data version, tokenizer, parameter-count convention, tokens seen, schedule, compute definition and held-out metric. Keep comparable runs together, hold out larger scales, inspect residuals and repeat selected sizes with different seeds where possible. A constant or simple linear baseline helps establish whether the more elaborate curve actually predicts better. Report the range tested; “power law” is a description of that evidence, not permission for unlimited extrapolation.

Read what the curve actually says

  1. For L=1.2+3/NL=1.2+3/\sqrt N, calculate the losses at N=1N=1 and N=4N=4. What halves?

Answer: They are 4.2 and 2.7. Subtracting 1.2 gives 3 and 1.5. The excess above the floor halves; the total loss does not.

  1. Rewrite the same law using the actual parameter count P=106NP=10^6N.

Answer: Since N=P/106N=P/10^6, the law is L=1.2+3000P−0.5L=1.2+3000P^{-0.5}. The amplitude changes from 3 to 3000, while the exponent remains 0.5. Comparing amplitudes without their units is misleading.

  1. Does the synthetic leave-one-out range 0.488–0.509 mean the true exponent lies there with 95% probability?

Answer: No. It records how the fit changes when each of six points is omitted. A confidence or posterior interval requires an uncertainty model and an appropriate inference procedure; the deletion range alone supplies neither.

  1. Two labs report per-token loss on different tokenizers, with different learning-rate schedules. Can their exponents settle which architecture scales better?

Answer: Not from those numbers alone. Token units and optimization conditions differ. First align the measurement and training protocol, or explicitly model the differences and test the resulting predictions on comparable held-out runs.

Read methods alongside the famous lines

Kaplan et al., arXiv v1, Figure 1 and sections 2.2–3.2, supply the empirical curves, parameter convention and selected training setup. Hoffmann et al., arXiv v1, sections 2–3.3, supply the protocol comparison, fixed-compute profiles and fitted two-variable surface. Neither paper is reduced here to a universal exponent. The next step is to study compute allocation with an explicit constraint; reliable allocation depends on whether the fitted loss surface survives the checks taught in this article.

Make a prediction, then check

If L=1.2+3N^(-0.5), what halves when N grows fourfold?

Choose one answer

Learning objectives

  • State the metric, units, tokenizer and controlled variables before comparing curves.
  • Fit a nonnegative loss floor and check residuals on withheld sizes.
  • Explain why changed schedules or evaluation conditions can invalidate extrapolation.

Prerequisites & connections

Explore related knowledge →

References

  1. Scaling Laws for Neural Language Models — arXiv v1
    Jared Kaplan; Sam McCandlish; Tom Henighan; Tom B. Brown; Benjamin Chess; Rewon Child; Scott Gray; Alec Radford; Jeffrey Wu; Dario Amodei · 2020
  2. Training Compute-Optimal Large Language Models — arXiv v1
    Jordan Hoffmann; Sebastian Borgeaud; Arthur Mensch; Elena Buchatskaya; Trevor Cai; Eliza Rutherford; Diego de Las Casas; Lisa Anne Hendricks; Johannes Welbl; Aidan Clark; Tom Hennigan; Eric Noland; Katie Millican; George van den Driessche; Bogdan Damoc; Aurelia Guy; Simon Osindero; Karen Simonyan; Erich Elsen; Jack W. Rae; Oriol Vinyals; Laurent Sifre · 2022

Version1 · Editorial status: Recorded technical checks completed

View technical check record (AI)

Codex · 2026-09-20 · Single AI author checked Kaplan v1 Figure 1/Table 1/sections 2.2–3.2 and Hoffmann v1 sections 2–3.3/equations 2–3. Seven paired equations and four explained exercises; synthetic floor fit, normal equations, parameter-unit conversion, withheld sizes, regime change and deletion sensitivity. Zero-floor comparison changes objective as well as floor. No LLM training, universal exponent or confidence-interval claim.

  • Single AI author checked Kaplan v1 Figure 1/Table 1/sections 2.2–3.2 and Hoffmann v1 sections 2–3.3/equations 2–3. Seven paired equations and four explained exercises; synthetic floor fit, normal equations, parameter-unit conversion, withheld sizes, regime change and deletion sensitivity. Zero-floor comparison changes objective as well as floor. No LLM training, universal exponent or confidence-interval claim.
  • Four computed SVG variants per topic; 10 numeric/geometry tests and 24 responsive cases passed. Eight Chinese-mobile/English-desktop figure screenshots actually viewed. Full article acceptance recorded separately.

Source locations checked:

Related topics

No matches. Try a synonym or acronym.

0 results shown

Wrap the whole query in double quotes for a phrase match.