AI-410 · Lesson 3 of 12 · 29 min

Scaling laws

Training a frontier language model costs tens to hundreds of millions of dollars in compute, so organizations need to predict, before spending it, how good a model will be and how to divide a budget between model size and training data. Scaling laws make this possible. They are empirical relationships, measured across many training runs, showing that a model's loss falls smoothly and predictably as parameters, data and compute increase. This lesson explains power laws, the original OpenAI scaling laws, the compute-optimal "Chinchilla" result, why practical models are often trained far beyond that optimum, the debate over emergent abilities, the limits posed by data, and the newer scaling of compute at inference time.

Power laws

A power law has the form \(y = a x^{-b}\). Taking logarithms gives \(\log y = \log a - b \log x\), a straight line on a log-log plot with slope \(-b\). Power laws describe many phenomena where there is no characteristic scale: each tenfold increase in \(x\) reduces \(y\) by the same factor \(10^{-b}\).

In 2020, researchers at OpenAI (Kaplan and colleagues) trained hundreds of transformer language models of different sizes on different amounts of data and found that test loss followed power laws in each of three quantities when the others were not limiting: parameters \(N\), dataset size \(D\), and compute \(C\). The trends held across more than six orders of magnitude, and architectural details such as depth versus width mattered much less than total scale.

\[L(N) \approx \left(\frac{N_c}{N}\right)^{\alpha_N}, \qquad L(D) \approx \left(\frac{D_c}{D}\right)^{\alpha_D}\]

with exponents around 0.07 to 0.10 in their setup. Small exponents mean that each tenfold increase in scale reduces loss by a modest but reliable fraction, which is why progress has required exponential growth in compute.

Log-log plot of test loss against training compute for families of models of different sizes. Each model size traces a curve that falls as it trains on more tokens and then flattens. The lower envelope of all curves, the compute-efficient frontier, is a nearly straight line on the log-log axes, showing a power law relationship between compute and the best achievable loss.
Each model size flattens out; the best loss for each compute budget follows a power law.

Irreducible loss and the combined law

Loss cannot fall to zero: natural text contains genuine uncertainty (what word an author chose, what comes next in a conversation). A better functional form includes an irreducible term \(E\), the entropy of the text, plus separate terms for the limits imposed by finite parameters and finite data:

\[L(N, D) = E + \frac{A}{N^{\alpha}} + \frac{B}{D^{\beta}}\]

This form, introduced in DeepMind's 2022 Chinchilla paper, says that a model is limited both by its size and by how much data it has seen. Fitting it requires care: a pure power law fitted to small models without the irreducible term can badly mislead when extrapolated.

Fitting losses from five small models with and without an irreducible term, then extrapolating to larger models.
import numpy as np

rng = np.random.default_rng(0)
N = np.array([1e7, 3e7, 1e8, 3e8, 1e9])
true = lambda n: 1.8 + 480 / n ** 0.35
L = true(N) * (1 + rng.normal(0, 0.005, N.size))

b, log_a = np.polyfit(np.log(N), np.log(L), 1)
print(f"pure power law fit: L = {np.exp(log_a):.2f} * N^({b:.3f})")

best = None
for E in np.linspace(0.5, 2.5, 401):
    if E >= L.min():
        break
    s, c = np.polyfit(np.log(N), np.log(L - E), 1)
    err = np.sum((E + np.exp(c) * N ** s - L) ** 2)
    if best is None or err < best[0]:
        best = (err, E, s, c)
_, E, s, c = best
print(f"with irreducible term: L = {E:.2f} + {np.exp(c):.0f} * N^({s:.3f})")
for n in [1e10, 1e11]:
    p1 = np.exp(log_a) * n ** b
    p2 = E + np.exp(c) * n ** s
    print(f"N={n:.0e}  true {true(n):.3f}  pure power law {p1:.3f}  with E {p2:.3f}")
Output
pure power law fit: L = 19.08 * N^(-0.107)
with irreducible term: L = 1.78 + 419 * N^(-0.341)
N=1e+10  true 1.952  pure power law 1.617  with E 1.939
N=1e+11  true 1.868  pure power law 1.263  with E 1.850

The pure power law fits the five points but predicts losses that keep falling steeply, missing the floor that the true curve approaches. The form with an irreducible term extrapolates far better. Scaling-law practice involves exactly this kind of fitting on small runs, then checking predictions against a few larger runs before committing the full budget.

Compute-optimal training: Chinchilla

Given a fixed compute budget \(C \approx 6ND\), should you train a larger model on fewer tokens or a smaller model on more tokens? The 2020 OpenAI analysis suggested putting most extra compute into larger models, and models such as GPT-3 (175 billion parameters, about 300 billion tokens) followed that advice. In 2022, DeepMind's Hoffmann and colleagues trained over 400 models and concluded that parameters and tokens should grow in roughly equal proportion with compute, which works out to about 20 training tokens per parameter.

They demonstrated this with Chinchilla, a 70-billion-parameter model trained on 1.4 trillion tokens. It used about the same compute as their earlier 280-billion-parameter Gopher model (trained on 300 billion tokens) but outperformed it on most benchmarks, and being four times smaller it was also cheaper to use. A 2024 replication by Epoch AI corrected the paper's fitted constants for the parametric loss function, giving values close to \(E = 1.82\), \(A = 482\), \(B = 2085\), \(\alpha = 0.35\), \(\beta = 0.37\), consistent with the roughly 20-to-1 rule.

Compute-optimal model size and tokens from the parametric loss (replication constants), and three ways to spend Chinchilla's budget.
import numpy as np

E, A, B, alpha, beta = 1.82, 482.0, 2085.4, 0.348, 0.366


def loss(N, D):
    return E + A / N ** alpha + B / D ** beta


for C in [1e20, 1e21, 1e22, 1e23, 1e24]:
    N = np.logspace(7, 13, 4000)
    D = C / (6 * N)
    L = loss(N, D)
    i = int(np.argmin(L))
    print(f"C={C:.0e}  best N={N[i] / 1e9:7.2f}B  D={D[i] / 1e9:8.0f}B  tokens/param={D[i] / N[i]:5.1f}  loss={L[i]:.3f}")

C = 5.8e23
for N in [70e9, 280e9, 530e9]:
    D = C / (6 * N)
    print(f"same compute, N={N / 1e9:4.0f}B  D={D / 1e9:5.0f}B  loss={loss(N, D):.3f}")
Output
C=1e+20  best N=   0.85B  D=      20B  tokens/param= 22.9  loss=2.553
C=1e+21  best N=   2.78B  D=      60B  tokens/param= 21.6  loss=2.306
C=1e+22  best N=   9.06B  D=     184B  tokens/param= 20.3  loss=2.142
C=1e+23  best N=  29.44B  D=     566B  tokens/param= 19.2  loss=2.034
C=1e+24  best N=  95.94B  D=    1737B  tokens/param= 18.1  loss=1.962
same compute, N=  70B  D= 1381B  loss=1.976
same compute, N= 280B  D=  345B  loss=1.995
same compute, N= 530B  D=  182B  loss=2.018
Plot of predicted loss against model size for three fixed compute budgets, 10 to the 21, 10 to the 22 and 10 to the 23 FLOPs. Each curve is U-shaped: too small a model is limited by its size, too large a model sees too few tokens. The minimum of each curve, marked with a dot, moves to larger models as compute grows, and a dashed line connects the minima.
For each compute budget there is an optimal model size; it grows with compute.

Worked problem

Allocating a budget

A lab has \(10^{24}\) FLOPs. Using the 20-tokens-per-parameter rule, what model size and token count are compute-optimal?

Show solution
  1. With \(D = 20N\): \(C = 6N \times 20N = 120 N^2\).
  2. \(N = \sqrt{10^{24}/120} = \sqrt{8.33 \times 10^{21}} = 9.1 \times 10^{10}\), about 91 billion parameters.
  3. \(D = 20N = 1.8 \times 10^{12}\), about 1.8 trillion tokens.

Answer: About 91 billion parameters trained on 1.8 trillion tokens, close to the grid search result in the code (96 billion and 1.74 trillion). Both N and D grow as the square root of compute, so a hundredfold increase in compute means ten times more parameters and ten times more data.

Beyond compute-optimal: training for inference

Chinchilla optimality minimizes the cost of training for a given loss. But a model that will serve billions of requests also incurs inference costs, which grow with model size. Training a smaller model on far more tokens than the 20-to-1 rule costs more training compute for the same loss, but gives a model that is cheaper to run for its whole life. Since 2023, many widely used models have been trained this way: Meta's Llama 3 8B model, for example, was trained on about 15 trillion tokens, nearly 1,900 tokens per parameter. Loss continues to improve with more tokens, only more slowly than the compute-optimal path. Small models trained long, often with distillation from larger "teacher" models, now power many on-device and low-cost applications.

Worked problem

Training cost versus inference cost

Option A: a 70 B model trained on 1.4 T tokens. Option B: a 35 B model trained on 4 T tokens, assumed to reach similar quality. The model will generate \(10^{13}\) tokens over its life (inference costs about \(2N\) FLOPs per token). Compare total compute.

Show solution
  1. A training: \(6 \times 7 \times 10^{10} \times 1.4 \times 10^{12} = 5.9 \times 10^{23}\); inference: \(2 \times 7 \times 10^{10} \times 10^{13} = 1.4 \times 10^{24}\); total \(2.0 \times 10^{24}\).
  2. B training: \(6 \times 3.5 \times 10^{10} \times 4 \times 10^{12} = 8.4 \times 10^{23}\); inference: \(7 \times 10^{23}\); total \(1.5 \times 10^{24}\).

Answer: Option B costs about 40% more to train but about 23% less overall, because inference dominates at this usage. The more a model will be used, the more it pays to "over-train" a smaller model.

Scaling, capabilities and emergence

Loss falls smoothly, but what users care about is capabilities: answering questions correctly, writing working code, solving problems. Benchmark accuracy also tends to improve with scale, and some capabilities have appeared to emerge suddenly, near zero for smaller models and then rising sharply above some size, an observation reported widely in 2022. A 2023 analysis by Schaeffer and colleagues argued that many apparent jumps are artefacts of the metrics used: an all-or-nothing score such as exact match of a multi-step answer rises abruptly even when the underlying probability of each step improves smoothly. With continuous metrics the trends are usually smooth. Predicting specific capabilities remains harder than predicting loss, which is one reason labs evaluate models extensively for both useful and dangerous capabilities as they scale.

Worked problem

Why all-or-nothing metrics look sudden

A task requires 10 steps to all be correct. If per-step accuracy rises from 0.80 to 0.90 to 0.97 as models grow, what is task accuracy?

Show solution
  1. \(0.80^{10} = 0.11\); \(0.90^{10} = 0.35\); \(0.97^{10} = 0.74\).

Answer: Task accuracy jumps from 11% to 74% while per-step accuracy rises steadily, so the capability appears to "emerge" even though the underlying improvement is gradual.

The data constraint

Compute-optimal scaling requires ever more training tokens, but the supply of high-quality human-written text is finite. Estimates suggest that the stock of public, high-quality text is in the hundreds of trillions of tokens, a limit that frontier training could approach within a few years. Responses include:

  • Repeating data: experiments (Muennighoff and colleagues, 2023) found that repeating a dataset for up to about four epochs gives almost the same benefit as fresh data, with diminishing returns after that.
  • Better filtering: extracting more value from each token through quality selection.
  • Synthetic data: text, code and reasoning traces generated by models, verified where possible (for example by running code or checking math answers). Training only on unverified model outputs can cause model collapse, a gradual loss of diversity and accuracy.
  • Multimodal data: images, audio and video add very large data sources.
  • Licensed and private data: books, news archives and specialized data obtained through agreements.

Scaling inference-time compute

Since 2024, a second scaling axis has become central: compute spent while answering. Reasoning models, starting with OpenAI's o1 (September 2024) and followed by DeepSeek-R1 (January 2025) and reasoning modes in other model families, are trained with reinforcement learning to produce long chains of intermediate reasoning before answering (Lesson 5). Their accuracy on math, science and coding problems rises smoothly with the number of reasoning tokens they are allowed to generate, roughly log-linearly, much as training loss improves with training compute. Other forms of test-time scaling include sampling many answers and choosing by majority vote or a verifier. This makes inference infrastructure, latency and cost an even larger part of the economics of AI (DCE-410).

Plot of accuracy on a reasoning benchmark against the number of reasoning tokens per problem on a logarithmic axis, from 1,000 to 64,000. Accuracy rises roughly linearly with the logarithm of tokens, from about 30% to about 75%, for an illustrative reasoning model. A second, flatter line shows a non-reasoning model that gains little from more tokens.
Illustrative test-time scaling: accuracy rises with the log of reasoning tokens.

Lesson 4 looks at the other half of the scaling equation, the training data itself: where it comes from, how it is filtered and deduplicated, and what happens as high-quality text runs short.

Common mistakes

  • MistakeExtrapolating a pure power law fitted to small models.

    InsteadInclude an irreducible loss term and validate on larger runs.

  • MistakeSpending all extra compute on model size.

    InsteadGrow parameters and tokens together (about 20 tokens per parameter for training-optimal).

  • MistakeIgnoring inference cost when choosing model size.

    InsteadHeavily used models justify training smaller models on more tokens.

  • MistakeConcluding capabilities appear from nowhere.

    InsteadCheck whether all-or-nothing metrics hide smooth improvement.

  • MistakeTraining repeatedly on unverified synthetic data.

    InsteadVerify synthetic data and mix in real data to avoid model collapse.

Summary and key terms

  • Loss follows power laws in parameters, data and compute over many orders of magnitude.
  • The combined law L = E + A/N^α + B/D^β includes irreducible loss.
  • Chinchilla: grow N and D together, about 20 tokens per parameter; 70 B on 1.4 T beat 280 B Gopher.
  • Compute-optimal N and D each scale as the square root of compute.
  • Models used heavily are often trained far beyond 20 tokens per parameter to cut inference cost.
  • Apparent emergence often reflects all-or-nothing metrics.
  • High-quality data is a growing constraint; repetition, filtering and verified synthetic data help.
  • Reasoning models scale accuracy with inference-time compute.
Scaling law
An empirical relationship between scale and model performance.
Power law
A relationship y = a·x^(−b), a straight line on log-log axes.
Irreducible loss
The loss floor due to genuine uncertainty in the data.
Compute-optimal
The allocation of N and D that minimizes loss for a given compute.
Chinchilla
DeepMind's 70 B model showing roughly 20 tokens per parameter is training-optimal.
Over-training
Training beyond the compute-optimal token count to get a smaller model.
Emergent ability
A capability that appears to arise abruptly with scale.
Model collapse
Degradation from training repeatedly on model-generated data.
Test-time compute
Computation spent at inference, such as reasoning tokens or sampling.
Distillation
Training a smaller model to imitate a larger one.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. On a log-log plot, what does a power law look like?

    Show answer

    A straight line with slope −b.

  2. Loss falls by 15% per tenfold increase in compute. What is b?

    Show answer

    10^(−b) = 0.85, so b ≈ 0.071.

  3. Why include an irreducible term E?

    Show answer

    Text has genuine uncertainty, so loss approaches a floor rather than zero.

  4. Compute-optimal N and D for C = 10²² using 20 tokens/parameter?

    Show answer

    N = √(10²²/120) ≈ 9.1 B; D ≈ 183 B tokens.

  5. Compute increases 100×. How do compute-optimal N and D change?

    Show answer

    Each increases about 10×.

  6. Why was Chinchilla better than Gopher at equal compute?

    Show answer

    It balanced size and data; Gopher was under-trained on tokens.

  7. Why train an 8 B model on 15 T tokens?

    Show answer

    To get the best small model for cheap, heavy inference.

  8. A 5-step task with per-step accuracy 0.9. Task accuracy?

    Show answer

    0.59.

  9. About how many epochs of repeated data remain nearly as useful as new data?

    Show answer

    About four.

  10. What is test-time scaling?

    Show answer

    Improving accuracy by spending more compute at inference, such as longer reasoning.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz