Scaling laws: parameters, data and compute
Language-model loss falls as a smooth power law in model size, data and compute. Learn the Kaplan and Chinchilla results, the 6·N·D compute rule, why ~20 tokens per parameter became a rule of thumb, why modern models deliberately overtrain, and what “emergent abilities” really are.
Training a frontier model costs millions of dollars, so labs need to know in advance: how big should the model be, how many tokens should it see, and what loss will we get? Scaling laws answer this. Small pilot runs are fitted with simple power-law curves and extrapolated to the big run — and, remarkably, the predictions hold across many orders of magnitude[1][2].
Loss follows power laws
Kaplan et al. (OpenAI, 2020) trained many transformers and found that test loss depends mainly on three quantities — parameters N (excluding embeddings), dataset size D in tokens, and training compute C — and only weakly on shape details like depth versus width. When one factor is the bottleneck, loss is a straight line on a log-log plot[1]:
- L(N)
- test loss (nats per token) of a model with N parameters trained to convergence on plenty of data
- N
- number of non-embedding parameters
- N_c
- fitted constant, ≈ 8.8 × 10¹³
- D
- number of training tokens
- D_c
- fitted constant, ≈ 5.4 × 10¹³ tokens
- C
- training compute (used optimally)
- C_c
- fitted constant, ≈ 3.1 × 10⁸ PF-days
- ^0.076
- the exponent: how fast loss falls (small = slow, steady gains)
▸Worked example
- C
- total training compute
- 6
- ≈ 2 (forward) + 4 (backward) operations per parameter per token
- N
- number of model parameters
- D
- number of training tokens
- FLOPs
- floating-point operations (a count, not per second)
▸Worked example
Chinchilla: compute-optimal training
Kaplan’s analysis suggested spending most extra compute on bigger models, so models like GPT-3 (175B parameters) were trained on only ~300B tokens[5]. Hoffmann et al. (DeepMind, 2022) re-examined this with over 400 models (70M to 16B+ parameters, 5B to 500B tokens) and reached a different conclusion: parameters and tokens should grow in equal proportion with compute. Their 70B-parameter Chinchilla, trained on 1.4T tokens, used the same compute as the 280B Gopher yet outperformed it on most benchmarks — and is cheaper to run[2].
- L(N, D)
- predicted loss for N parameters trained on D tokens
- E
- irreducible loss: the entropy of natural text itself
- A / N^α
- the part of the loss caused by limited model size
- B / D^β
- the part caused by limited training data
- α
- how fast the model-size penalty shrinks
- β
- how fast the data penalty shrinks
▸Worked example
- N_opt
- compute-optimal number of parameters
- D_opt
- compute-optimal number of training tokens
- ∝
- “is proportional to”
- C^≈0.5
- compute to the power of about 0.5 (≈ square root)
- ⇒
- “therefore”
▸Worked example
| Model | Parameters | Training tokens | Tokens / parameter |
|---|---|---|---|
| GPT-3 (2020) | 175B | 300B | ≈ 1.7 |
| Gopher (2021) | 280B | 300B | ≈ 1.1 |
| Chinchilla (2022) | 70B | 1.4T | 20 |
| Llama 2 7B (2023) | 7B | 2T | ≈ 290 |
| Llama 3 8B (2024) | 8B | 15T+ | ≈ 1,900 |
Why do newer models go far beyond 20 tokens per parameter? Chinchilla minimizes training compute only. But a deployed model is queried billions of times, and inference cost scales with N. A smaller model trained much longer costs more to train than “optimal”, yet is cheaper and faster for every user forever. This deliberate overtraining is now standard for open models meant to run on modest hardware.
Try this
- Fix N and keep increasing D: the loss falls, then flattens toward E + A/N^α — the model is “full”. Do the same with N fixed small and see how much loss is left on the table.
- Look at the isoFLOP curve: for a fixed compute budget, a model that is too small *or* too big gets a worse loss. The minimum is the compute-optimal size.
- Set N = 175B and D = 300B (GPT-3-like), note the loss, then move to the optimum at the same compute. How much loss did GPT-3 leave unclaimed?
- Read the “tokens per parameter” value at the optimum and compare it with the ~20 rule of thumb. The rounded published constants do not reproduce exactly 20 at every budget — a reminder that these are approximate fits.
- What it is
- Number of trainable weights. Sets capacity, memory footprint and per-token compute (training and inference).
- ↑ If you increase it
- Lower achievable loss (A/N^α shrinks); at fixed compute, fewer tokens can be afforded, so beyond the optimum the model is undertrained. Inference gets slower and costlier.
- ↓ If you decrease it
- Cheaper to serve and fine-tune; the loss floor rises, so no amount of data can make a tiny model as good as a large one.
- Typical values
- 1B–8B for on-device/edge, 30B–70B for strong open models, hundreds of billions+ for frontier models.
- What it is
- How many tokens the model is trained on (counting repeats).
- ↑ If you increase it
- Lower loss (B/D^β shrinks) and better use of a fixed model; but high-quality unique data is limited, and repeating data many epochs gives diminishing returns.
- ↓ If you decrease it
- Cheaper training; the model stays undertrained — its capacity is wasted.
- Typical values
- ≈ 20 × N for compute-optimal; 100–2,000 × N for inference-optimized open models.
- What it is
- Total training compute ≈ 6·N·D. Fixed by your GPUs × time × utilization.
- ↑ If you increase it
- Lower best achievable loss; the optimal N and D both grow roughly as √C.
- ↓ If you decrease it
- Higher loss; you must choose a smaller model and/or fewer tokens.
- Typical values
- ~10¹⁸–10²⁰ FLOPs for research-scale runs; ~10²³–10²⁵+ for frontier LLMs.
import numpy as np
E, A, B, alpha, beta = 1.69, 406.4, 410.7, 0.34, 0.28
loss = lambda N, D: E + A / N**alpha + B / D**beta
def optimal(C):
Ns = np.logspace(7, 13, 2000) # 10M .. 10T parameters
Ds = C / (6 * Ns) # spend the whole budget
L = loss(Ns, Ds)
i = L.argmin()
return Ns[i], Ds[i], L[i]
for C in [1e20, 1e22, 5.9e23, 1e25]:
N, D, L = optimal(C)
print(f"C={C:.0e} N={N/1e9:7.1f}B D={D/1e9:9.0f}B "
f"tokens/param={D/N:6.1f} loss={L:.3f}")Emergent abilities — and a caveat
Wei et al. catalogued abilities that seem absent in small models and appear suddenly beyond a certain scale, such as multi-step arithmetic and some reasoning benchmarks[3]. Schaeffer et al. argued that much of this sharpness comes from the metric: exact-match accuracy gives zero credit until every token is right, so smooth underlying progress looks like a jump; with continuous metrics many curves become smooth[4]. The practical takeaway: loss is predictable; specific downstream skills much less so — always evaluate the capability you care about directly.
- Data quality and limits: filtered, deduplicated data shifts the whole curve down; the supply of high-quality human text is finite, which motivates synthetic data and multi-epoch training.
- Test-time compute: letting a model generate longer reasoning, sample several answers, or verify its work can improve accuracy in a way that also scales — a second axis besides pretraining compute.
- Fine-tuning and transfer follow their own (smaller) scaling trends; bigger pretrained models generally need fewer examples to adapt.
▸Go deeper: deriving the optimum
Minimize L(N, D) = E + A/N^α + B/D^β subject to 6ND = C. Substituting D = C/(6N) and setting the derivative to zero gives αA/N^α = βB/D^β, i.e. at the optimum both penalty terms are balanced (weighted by their exponents). Solving:
- N_opt
- loss-minimizing number of parameters for budget C
- D_opt
- loss-minimizing number of tokens for budget C
- C/6
- the compute budget expressed as N·D (since C ≈ 6·N·D)
- G
- a constant built from the fitted A, B, α, β
- G⁻¹
- 1 / G
- α
- model-size exponent (0.34)
- β
- data exponent (0.28)
- A
- model-size coefficient (406.4)
- B
- data coefficient (410.7)
▸Worked example
With α = 0.34 and β = 0.28, N grows as C^0.45 and D as C^0.55 — close to the equal split found by Chinchilla’s other two estimation methods. The idea that error falls predictably as a power law of data and model size predates LLMs; Hestness et al. documented it across translation, language modeling, vision and speech[6].
Quiz
References
- [1]Scaling Laws for Neural Language ModelsPaperKaplan et al.2020arxiv.org
- [2]Training Compute-Optimal Large Language Models (Chinchilla)PaperHoffmann et al.2022arxiv.org
- [3]Emergent Abilities of Large Language ModelsPaperWei et al.2022arxiv.org
- [4]Are Emergent Abilities of Large Language Models a Mirage?PaperSchaeffer et al.2023arxiv.org
- [5]Language Models are Few-Shot Learners (GPT-3)PaperBrown et al.2020arxiv.org
- [6]Deep Learning Scaling is Predictable, EmpiricallyPaperHestness et al.2017arxiv.org