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
- Builds on
- 33 concepts →
- Quiz
- 5 questions ↓
Read first
Pretraining Large Language ModelsThis leads to
—The full path from zero — 33 concepts before this one
- What Is AI?
- Vectors
- Derivatives and Slopes
- Probability Basics
- Python for AI
- How Machines Learn
- Partial Derivatives and Gradients
- Matrices and Matrix Multiplication
- The Chain Rule
- Dot Product, Norms and Similarity
- Tokenization
- Supervised, Unsupervised and Reinforcement Learning
- Gradient Descent
- Language Modeling and Next-Token Prediction
- Supervised Learning
- Linear Regression
- The Perceptron
- Logistic Regression
- Neural Networks
- Recurrent Neural Networks
- Backpropagation
- Activation Functions
- Vanishing and Exploding Gradients
- Normalization Layers: BatchNorm and LayerNorm
- LSTMs and GRUs
- Residual Connections
- Sequence-to-Sequence Models
- Attention
- Self-Attention and Multi-Head Attention
- Positional Encodings
- The Transformer
- GPT and Decoder-Only Models
- Pretraining Large Language Models
- 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.
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 , 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:
- : the number of model parameters (Kaplan counted only non-embedding parameters).
- : the number of training tokens.
- : the training compute in FLOPs, approximately (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
and are fitted constants (they set where the line sits), and the small exponents set its slope. Read the first law as: every tenfold increase in parameters multiplies the loss by , a 16% reduction, again and again. For data, each tenfold increase multiplies the loss by about 0.80.
Worked example. A model with non-embedding parameters: , and nats per token. At parameters, .
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 . 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 to and to : equal scaling. The third fitted a formula for the loss as a function of both and :
Read it as three terms. is the irreducible loss, the entropy of text itself: even a perfect model can't predict the next word of human writing with certainty. is the penalty for a finite model, and the penalty for finite data. Both shrink as you scale, but 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.
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 (, , , , ) agrees with them, at about 20 tokens per parameter. The headline conclusion stands.
Computing a compute-optimal model
With and , we get , so
Worked example. A budget of FLOPs: , about 91 billion parameters, trained on billion tokens. Check: . ✓
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.
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
- Pretraining Large Language Models is where these budgets are spent; Distributed Training and AI Hardware: GPUs, TPUs and Accelerators are what they buy.
- Mixture of Experts changes the arithmetic: more parameters per FLOP, with their own scaling laws.
- Knowledge Distillation and Small Models and over-training are the two main routes to strong small models.
- Reasoning Models and Test-Time Compute add test-time compute as a second scaling axis.
- The Energy Cost of AI and AI Regulation and Governance discuss what ever-larger training runs mean outside the lab; some regulations use training compute thresholds.
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
- Use to find the compute-optimal model size and token count for FLOPs.
- Using Kaplan's , how many times larger must a model be to cut the loss in half? Is that realistic?
- 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 , so , a factor of about , ten thousand times larger.
Learn more
Hand-picked courses, books, videos and tutorials for going deeper. See all resources →
Scaling Laws for Neural Language Models
Showed that loss falls as a smooth power law in model size, data and compute.
Training Compute-Optimal Large Language Models
Chinchilla: for a fixed compute budget, train smaller models on much more data.
Epoch AI
Data and research on trends in AI compute, data, models and hardware.
Stanford CS336: Language Modeling from Scratch
Build every part of an LLM yourself, from tokenizer to training, scaling and alignment.
Deep Dive into LLMs like ChatGPT
A 3.5-hour walk through the full stack of how chat models are built: pretraining, tokenization, post-training, RL and reasoning.
Lil'Log
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