◆ AI All-in-One

Level 3 In-Depth AI · Transformers and Language Models

Scaling Laws

A language model's loss falls smoothly and predictably as you add parameters, data and compute, following simple power laws. These laws let labs forecast a model's quality before training it, and tell them how to split a compute budget between model size and data.

Level
●●●●● Intermediate
Reading
13 min
To learn it well
1 hour to read
↗ Plan a path here

Read first

Pretraining Large Language Models

This leads to

—
The full path from zero — 33 concepts before this one
  1. What Is AI?
  2. Vectors
  3. Derivatives and Slopes
  4. Probability Basics
  5. Python for AI
  6. How Machines Learn
  7. Partial Derivatives and Gradients
  8. Matrices and Matrix Multiplication
  9. The Chain Rule
  10. Dot Product, Norms and Similarity
  11. Tokenization
  12. Supervised, Unsupervised and Reinforcement Learning
  13. Gradient Descent
  14. Language Modeling and Next-Token Prediction
  15. Supervised Learning
  16. Linear Regression
  17. The Perceptron
  18. Logistic Regression
  19. Neural Networks
  20. Recurrent Neural Networks
  21. Backpropagation
  22. Activation Functions
  23. Vanishing and Exploding Gradients
  24. Normalization Layers: BatchNorm and LayerNorm
  25. LSTMs and GRUs
  26. Residual Connections
  27. Sequence-to-Sequence Models
  28. Attention
  29. Self-Attention and Multi-Head Attention
  30. Positional Encodings
  31. The Transformer
  32. GPT and Decoder-Only Models
  33. Pretraining Large Language Models
  34. Scaling Laws

Read them roughly in this order. See it on the concept map →

Why it matters

Training a frontier language model costs tens to hundreds of millions of dollars. Before spending that, you'd like answers to two questions: how good will it be? and how should I spend the budget: a bigger model, or more data?

Remarkably, both have usable answers. In 2020 researchers at OpenAI showed that a language model's test loss falls as a smooth power law in model size, dataset size and training compute, across many orders of magnitude. Train a series of small models, fit a straight line on a log-log plot, and you can predict the loss of a model a hundred or a thousand times larger. In 2022 DeepMind's Chinchilla paper refined the recipe and showed that most large models of the time were too big for the data they were trained on. Its rule of thumb, about 20 training tokens per parameter for compute-optimal training, changed how models were built.

Scaling laws are why AI labs could raise money for ever-larger training runs with some confidence, why compute became the field's central resource (AI Hardware: GPUs, TPUs and Accelerators, Epoch AI tracks it), and why "just make it bigger" kept working for longer than many expected. Their limits matter too: loss is not the same as usefulness, and data is finite.

The intuition

Imagine you're learning a language by reading. Doubling your reading improves your fluency, but by less each time: the first thousand pages teach you the most common words, the next thousand the less common ones, and so on. The returns diminish, but steadily, never stopping abruptly.

Similarly, a bigger brain can store more patterns, but each doubling helps a bit less than the last. A power law is the mathematical shape of "steady diminishing returns": every time you multiply the input by 10, the output improves by the same factor. On ordinary axes it's a curve that flattens out. On log-log axes, where each step along an axis is a multiplication by 10, it becomes a straight line, and straight lines are easy to extend.

Now suppose you have a fixed budget of effort. You can be a big brain reading a little, or a small brain reading a lot. Both are wasteful at the extremes: a huge brain with almost nothing to read learns little, and a tiny brain can't absorb a vast library. Somewhere in between is the best split. Chinchilla found where.

Kaplan et al. (2020): test loss falls as a power law, a straight line on log-log axes Bigger models (data not limiting) 2 3 4 5 6 100K 1M 10M 100M 1B 10B non-embedding parameters N L = (8.8×10¹³ / N)^0.076 each 10× in N multiplies the loss by 10^−0.076 ≈ 0.84 More data (model not limiting) 2 3 4 5 6 10M 100M 1B 10B 100B training tokens D L = (5.4×10¹³ / D)^0.095 each 10× in D multiplies the loss by 10^−0.095 ≈ 0.80 loss in nats per token on the paper's WebText2 test set; curves drawn from the paper's fitted formulas Both axes are logarithmic: a straight line means each 10× in the input shrinks the loss by the same factor. Dashed: extrapolation beyond the range the paper measured.
Fig. 1 Kaplan et al.'s fitted power laws, drawn on log-log axes. Left: loss versus model size when data is plentiful. Right: loss versus dataset size when the model is large enough. Both are straight lines: each tenfold increase multiplies the loss by a constant factor.

Key idea Loss falls as a power law in parameters, data and compute: a straight line on log-log axes. For a fixed compute budget C≈6NDC \approx 6ND, the loss is lowest when parameters and tokens grow together, about 20 tokens per parameter (Chinchilla).

How it works

What is being measured

The quantity on the vertical axis is the cross-entropy loss on held-out text, in nats per token: the same next-token loss used to train the model (Language Modeling and Next-Token Prediction, Pretraining Large Language Models). Three things go on the horizontal axis:

  • NN: the number of model parameters (Kaplan counted only non-embedding parameters).
  • DD: the number of training tokens.
  • CC: the training compute in FLOPs, approximately 6ND6ND (Pretraining Large Language Models explains the 6).

Kaplan et al. (2020)

Scaling Laws for Neural Language Models by Jared Kaplan, Sam McCandlish and colleagues at OpenAI opens: "We study empirical scaling laws for language model performance on the cross-entropy loss. The loss scales as a power-law with model size, dataset size, and the amount of compute used for training, with some trends spanning more than seven orders of magnitude."

Their fitted laws, each holding when the other factors are not the bottleneck, are

L(N)=(NcN)αN,αN≈0.076,  Nc≈8.8×1013L(N) = \left(\frac{N_c}{N}\right)^{\alpha_N}, \quad \alpha_N \approx 0.076, \; N_c \approx 8.8 \times 10^{13}
L(D)=(DcD)αD,αD≈0.095,  Dc≈5.4×1013 tokensL(D) = \left(\frac{D_c}{D}\right)^{\alpha_D}, \quad \alpha_D \approx 0.095, \; D_c \approx 5.4 \times 10^{13} \text{ tokens}

NcN_c and DcD_c are fitted constants (they set where the line sits), and the small exponents α\alpha set its slope. Read the first law as: every tenfold increase in parameters multiplies the loss by 10−0.076≈0.8410^{-0.076} \approx 0.84, a 16% reduction, again and again. For data, each tenfold increase multiplies the loss by about 0.80.

Worked example. A model with 10810^8 non-embedding parameters: 8.8×1013/108=880,0008.8 \times 10^{13} / 10^8 = 880{,}000, and 880,0000.076=e0.076×ln⁡880,000=e0.076×13.69=e1.04≈2.83880{,}000^{0.076} = e^{0.076 \times \ln 880{,}000} = e^{0.076 \times 13.69} = e^{1.04} \approx 2.83 nats per token. At 10910^9 parameters, 2.83×0.84≈2.382.83 \times 0.84 \approx 2.38.

Other findings: within a wide range, the shape of the network (depth versus width, number of heads) barely mattered compared with the total parameter count. And their abstract concluded: "Larger models are significantly more sample-efficient, such that optimally compute-efficient training involves training very large models on a relatively modest amount of data and stopping significantly before convergence." Their fitted allocation said that as compute grows, most of it should go to model size, with Nopt∝C0.73N_{\text{opt}} \propto C^{0.73}. GPT-3 (175 billion parameters, 300 billion tokens, under 2 tokens per parameter) followed this advice.

Chinchilla: Hoffmann et al. (2022)

Training Compute-Optimal Large Language Models by Jordan Hoffmann, Sebastian Borgeaud, Arthur Mensch and colleagues at DeepMind revisited the question with over 400 models, from 70 million to over 16 billion parameters, trained on 5 to 500 billion tokens. Crucially, they matched each run's learning-rate schedule to its length, which Kaplan's setup had not done. Their conclusion, in the abstract: "We find that current large language models are significantly undertrained", and "for compute-optimal training, the model size and the number of training tokens should be scaled equally: for every doubling of model size the number of training tokens should also be doubled."

They used three methods. Two of them fitted the optimum directly and gave Nopt∝C0.49N_{\text{opt}} \propto C^{0.49} to C0.50C^{0.50} and Dopt∝C0.50D_{\text{opt}} \propto C^{0.50} to C0.51C^{0.51}: equal scaling. The third fitted a formula for the loss as a function of both NN and DD:

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

Read it as three terms. EE is the irreducible loss, the entropy of text itself: even a perfect model can't predict the next word of human writing with certainty. A/NαA/N^\alpha is the penalty for a finite model, and B/DβB/D^\beta the penalty for finite data. Both shrink as you scale, but EE never does.

To test the prediction they trained Chinchilla: 70 billion parameters on 1.4 trillion tokens, the same compute as their earlier Gopher (280 billion parameters on 300 billion tokens). Chinchilla, four times smaller, beat Gopher across the board, scoring 67.5% on the MMLU benchmark, more than 7 points above Gopher. A smaller model is also cheaper to run for every user query afterwards.

1.4 trillion tokens divided by 70 billion parameters is 20 tokens per parameter. That became the field's rule of thumb.

Compute-optimal training: for each budget, there is a best model size Each curve fixes the compute C ≈ 6ND and trades parameters N against tokens D (Chinchilla-style fit, Epoch AI 2024 re-estimate) 2.0 2.4 2.8 3.2 3.6 100M 1B 10B 100B 1T model size N (parameters), log scale predicted loss 10¹⁹ 10²⁰ 10²¹ 10²² FLOPs 10²³ FLOPs Curves: compute budgets C. Dots: best size for each. Too small a model (left of a dot) wastes compute on data it cannot absorb; too big (right) has too few tokens. Optimal D/N ≈ 20.
Fig. 2 Iso-FLOP curves: each curve holds compute fixed and varies model size, with the remaining budget going to tokens. Each has a minimum; the dashed line through the minima is the compute-optimal frontier. Drawn from the Chinchilla loss formula with Epoch AI's 2024 re-estimated constants, which put the optimum at about 20 tokens per parameter.

A footnote on the third method: in 2024 researchers at Epoch AI tried to replicate it and found that the published fit didn't match the paper's own data well and was inconsistent with the other two methods. Their re-fit (E=1.82E = 1.82, A=482A = 482, B=2085B = 2085, α=0.348\alpha = 0.348, β=0.366\beta = 0.366) agrees with them, at about 20 tokens per parameter. The headline conclusion stands.

Computing a compute-optimal model

With C=6NDC = 6ND and D=20ND = 20N, we get C=120 N2C = 120\,N^2, so

Nopt≈C120,Dopt≈20 NoptN_{\text{opt}} \approx \sqrt{\frac{C}{120}}, \qquad D_{\text{opt}} \approx 20\,N_{\text{opt}}

Worked example. A budget of 102410^{24} FLOPs: Nopt=1024/120=8.3×1021≈9.1×1010N_{\text{opt}} = \sqrt{10^{24}/120} = \sqrt{8.3 \times 10^{21}} \approx 9.1 \times 10^{10}, about 91 billion parameters, trained on 20×91≈1,80020 \times 91 \approx 1{,}800 billion tokens. Check: 6×9.1×1010×1.8×1012≈10246 \times 9.1 \times 10^{10} \times 1.8 \times 10^{12} \approx 10^{24}. ✓

Over-training on purpose

"Compute-optimal" means the lowest loss for a given training budget. But training happens once, and a popular model then answers billions of queries, each costing compute proportional to its size. A smaller model trained far past the Chinchilla point reaches a slightly worse loss per training FLOP, but it's much cheaper to serve. So most open models since 2023 are deliberately over-trained: Llama 3 8B saw about 15 trillion tokens, nearly 1,900 per parameter, and Meta reported that its 8B and 70B models were still improving log-linearly when training stopped.

Training tokens per parameter, as published (log scale) 1 10 100 1,000 10,000 ≈ 20: Chinchilla-optimal GPT-3 (2020) 1.7 Gopher (2021) 1.1 Chinchilla (2022) 20.0 LLaMA 65B (2023) 21.5 Llama 2 70B (2023) 28.6 Llama 3 70B (2024) 214 Llama 3 8B (2024) 1,875 Blue: undertrained by the Chinchilla rule. Green: about compute-optimal. Purple: deliberately “over-trained”: extra training on a small model costs more up front but makes every later use of it cheaper.
Fig. 3 Tokens per parameter for some well-known models. GPT-3 and Gopher used under 2, Chinchilla and LLaMA about 20, and later models far more, trading extra training compute for cheaper inference.

What scaling laws don't tell you

  • Loss is not capability. The loss falls smoothly, but specific skills can appear fairly suddenly (emergent abilities) and benchmark scores relate to loss in task-specific ways. Labs now also fit scaling curves to downstream tasks, with mixed success.
  • The constants depend on everything. Exponents and constants change with the data, the tokenizer, the architecture and the training recipe. A law fitted on one setup doesn't transfer exactly to another. Better data shifts the whole line down.
  • Data is finite. The laws assume fresh tokens. A 2023 study by Muennighoff and colleagues found that repeating data for up to about four epochs is almost as good as new data, after which returns fall off. Estimates suggest public human-written text may become the binding constraint for the largest runs within this decade (Pretraining Large Language Models, Synthetic Data).
  • Not only training compute. Since 2024 a second axis has opened: test-time compute. Reasoning models generate long chains of thought before answering, and their accuracy on hard problems improves predictably with how long they are allowed to think, as well as with training compute.

In code

Fit a power law the way the papers do, by linear regression on logarithms, then find compute-optimal allocations from the Chinchilla formula with both sets of published constants:

import numpy as np

# 1. Fitting a power law: pretend we trained 6 small models and measured their loss
rng = np.random.default_rng(0)
N = np.array([1e6, 3e6, 1e7, 3e7, 1e8, 3e8])                   # model sizes
L = (8.8e13 / N) ** 0.076 * np.exp(rng.normal(0, 0.01, N.size))  # Kaplan's law + 1% noise
slope, intercept = np.polyfit(np.log10(N), np.log10(L), 1)      # straight line in log-log
print(f"fitted exponent {-slope:.3f} (true 0.076)")
predict = lambda n: 10 ** (intercept + slope * np.log10(n))
print(f"predicted loss at 10B params: {predict(1e10):.3f}  (formula: {(8.8e13/1e10)**0.076:.3f})")

# 2. Chinchilla-style allocation: L(N, D) = E + A / N^alpha + B / D^beta
FITS = {"Hoffmann et al. 2022": (1.6934, 406.4, 410.7, 0.3392, 0.2849),
        "Epoch AI re-fit 2024": (1.8172, 482.01, 2085.43, 0.3478, 0.3658)}

def best_split(C, E, A, B, a, b):
    N = np.logspace(7, 13, 6000)            # candidate model sizes
    D = C / (6 * N)                         # tokens we can afford with compute C
    L = E + A / N**a + B / D**b
    i = np.argmin(L)
    return N[i], D[i]

for name, fit in FITS.items():
    N, D = best_split(5.76e23, *fit)        # Chinchilla's (and Gopher's) budget
    print(f"{name}: N = {N/1e9:.0f}B params, D = {D/1e12:.1f}T tokens, D/N = {D/N:.0f}")

# fitted exponent 0.076 (true 0.076)
# predicted loss at 10B params: 1.994  (formula: 1.994)
# Hoffmann et al. 2022: N = 40B params, D = 2.4T tokens, D/N = 59
# Epoch AI re-fit 2024: N = 72B params, D = 1.3T tokens, D/N = 18

The fit from six small models extrapolates 30 times beyond the largest one and lands on the right value, which is the whole point of scaling laws. The re-fitted constants put Chinchilla's own budget at 72 billion parameters and 1.3 trillion tokens, close to the 70 billion and 1.4 trillion DeepMind actually chose. The original constants give a noticeably different answer, which is the inconsistency the replication found.

Common pitfalls

  • Extrapolating too far. A line fitted over two orders of magnitude can bend outside them. Fit over as wide a range as you can and check predictions against a few larger runs.
  • Mixing parameter counts. Kaplan excluded embedding parameters; Chinchilla included them. For small models the difference is large, and it explains part of the two papers' disagreement.
  • Forgetting the schedule. A model evaluated part-way through a long learning-rate schedule looks worse than one trained to the end of a short schedule with the same tokens. Each point on a scaling curve needs its own properly finished run.
  • Treating 20 as a law of nature. It's an empirical optimum for one data mixture, architecture and training setup, and it ignores inference cost. Use it as a starting point.

Watch out A lower loss on a scaling plot does not guarantee a more useful or safer model. Downstream behaviour depends on data quality, post-training and evaluation, which the laws don't capture (Evaluating LLMs and Benchmarks, AI Risks and Safety).

Where it leads

A bit of history

Power-law improvements with data and model size were documented by Joel Hestness and colleagues at Baidu in 2017, across translation, language modelling, image classification and speech. In January 2020 Kaplan, McCandlish and co-authors at OpenAI published the language-model laws above, which shaped GPT-3, and later that year Tom Henighan and colleagues showed similar laws for images, video and maths. In March 2022 Hoffmann and colleagues at DeepMind published Chinchilla and the 20-tokens-per-parameter rule, and the industry shifted towards more data per parameter. From 2023 open models like LLaMA deliberately went far beyond it to make inference cheaper. In 2024 Epoch AI's replication corrected the third Chinchilla method, and OpenAI's o1 reasoning model popularised scaling at test time. Rich Sutton's 2019 essay "The Bitter Lesson", arguing that general methods that exploit growing compute win in the long run, is often cited as the philosophy behind it all.

Try it

  1. Use Nopt=C/120N_{\text{opt}} = \sqrt{C/120} to find the compute-optimal model size and token count for C=1022C = 10^{22} FLOPs.
  2. Using Kaplan's L(N)L(N), how many times larger must a model be to cut the loss in half? Is that realistic?
  3. Change the noise in the fitting code from 1% to 5%, fit again with only the three smallest models, and see how far off the 10B prediction becomes.

Hint for 2: you need 10−0.076k=0.510^{-0.076k} = 0.5, so k=log⁡102/0.076≈4k = \log_{10} 2 / 0.076 \approx 4, a factor of about 10410^4, ten thousand times larger.

Check your understanding

5 quick questions. Pick an answer to see whether you were right and why. Your best score is saved on this device.

  1. Under Kaplan's law, every tenfold increase in parameters multiplies the loss by about 0.84. A 10⁸-parameter model has loss 2.83. What do you predict for 10⁹ parameters?

  2. You have a fixed training budget and want the lowest loss. Following Chinchilla, how should you split it?

  3. Llama 3 8B was trained on about 15 trillion tokens, far beyond the Chinchilla point. Why would a lab do this on purpose?

  4. In L(N, D) = E + A/N^α + B/D^β, what does E represent?

  5. A scaling plot shows a new model has lower loss. What can you NOT conclude from that alone?

Finished this chapter?

Learn more

Hand-picked courses, books, videos and tutorials for going deeper. See all resources →

Article

Epoch AI

Epoch AI · Intermediate · Free

Data and research on trends in AI compute, data, models and hardware.

Video

Deep Dive into LLMs like ChatGPT

Andrej Karpathy · 2025 · Beginner · Free

A 3.5-hour walk through the full stack of how chat models are built: pretraining, tokenization, post-training, RL and reasoning.

Article

Lil'Log

Lilian Weng · Advanced · Free

Deep, carefully referenced survey posts on diffusion, agents, RL, hallucination, attention and more.

Facts checked as of 30 November 2026. Fast-moving details (products, prices, laws) change often. · Source: content/entries/llm/scaling-laws.md