By Sagi Shaier · 14 November 2026 · 7 min read
Scaling laws explained: parameters, data, and compute
How loss falls as language models grow, why that shows up as a straight line on log-log axes, how to fit one in numpy, and why a bigger model is not always the better use of a fixed budget.
A scaling law is a measured relationship that estimates how a model's loss changes as you scale up its parameters, its training data or its training compute. It comes from experiments, not from a proof. You train many models under matched conditions, plot their losses and fit the pattern. With a good fit, a team can estimate a large model's loss from a few small training runs before paying for the large one.
The loss here is the model's error on held-out text, text it never trained on. For a language model it is the average cross-entropy of predicting each next token, so lower is better.
Two questions about scale
Making a language model bigger raises two separate questions. One asks which abilities appear as models get larger, such as arithmetic or following a required format. That one is answered by testing the model on those tasks. The other asks how much the loss improves for each extra unit of parameters, data and compute. Scaling laws answer the second question.
Compute is counted in FLOPs, the number of floating-point operations a training run performs.

What a scaling law is
Three quantities come up again and again:
- Parameter count $N$, the number of trained weights in the model.
- Training tokens $D$, how many tokens the model sees during training.
- Training compute $C$, the total FLOPs of the run.
A scaling law fits the loss as a function of one or more of these. The fit only holds for the setup it was measured on. The architecture, the data, the optimizer and the learning-rate schedule all have to match across the runs. The fit also covers only the range of sizes that was measured.

Loss falls as a power law
In many language-model scaling studies, loss falls like a power law of model size over the measured range, when data and training time are not the limit:
$$L(N) \propto N^{-\alpha}$$
$\propto$ means "proportional to", and $\alpha$ is a small positive exponent fitted from the runs. Writing in the constant $A$ gives $L = A N^{-\alpha}$.
For example, with $\alpha = 0.08$, multiplying the parameter count by 10 multiplies the loss by $10^{-0.08} \approx 0.83$. A model at loss 5.50 with $10^7$ parameters would be at about $5.50 \times 0.83 \approx 4.58$ with $10^8$ parameters, and the next factor of 10 brings it to about 3.81.
On ordinary axes that is a curve that drops fast and then flattens. Take the log of both sides of $L = A N^{-\alpha}$:
$$\log L = \log A - \alpha \log N$$
That is the equation of a straight line in $\log N$, with slope $-\alpha$. On log-log axes, where both axes are on a log scale, a power law shows up as a straight line.

Forecasting a bigger run
The straight line is what makes scaling laws useful. Train a handful of smaller models, fit the line and extend it to a model size you have not trained yet. Across many published studies, simple fitted lines have described loss over large ranges of model size, data and compute. Whether the trend continues indefinitely, or where a new limit appears, is an open question. A forecast is safest close to the range that was measured.

Fitting the line in numpy
The fit takes a few numpy calls. np.log takes the log of every entry in an array. np.polyfit(x, y, 1) fits a straight line, a polynomial of degree 1, through the points and returns its slope and intercept. np.exp turns the forecast log loss back into a loss:
1import numpy as np
2
3params = np.array([1e7, 1e8, 1e9])
4losses = np.array([4.0, 3.4, 2.9])
5slope, intercept = np.polyfit(np.log(params), np.log(losses), 1)
6alpha = -slope
7pred_loss = np.exp(slope * np.log(1e10) + intercept)
8print(f"alpha = {alpha:.3f}")
9print(f"forecast at 1e10 parameters: {pred_loss:.2f}")1alpha = 0.070
2forecast at 1e10 parameters: 2.47Three small runs at $10^7$, $10^8$ and $10^9$ parameters give $\alpha \approx 0.07$. Extending the line forecasts a loss of about 2.47 for a $10^{10}$-parameter model, before anyone trains it.
The forecast is only as good as the match between the runs. The fitted line can mislead you if the small runs used a different data mix, tokenizer, optimizer or schedule than the big run will.

Diminishing returns
A power law keeps lowering the loss, and each further drop costs more. Because $\alpha$ is small, a modest improvement in loss needs a much larger increase in parameters, tokens or compute.
The toy curve below makes that concrete. It uses $L = 1 + C^{-0.1}$, a power law in compute $C$ that levels off toward 1.0. The 1.0 is a floor that more compute does not remove, labeled irreducible loss:
1for C in [1, 1e2, 1e4, 1e6]:
2 loss = 1.0 + C ** -0.1
3 print(f"compute {C:>9,.0f}: loss {loss:.2f}")1compute 1: loss 2.00
2compute 100: loss 1.63
3compute 10,000: loss 1.40
4compute 1,000,000: loss 1.25Every row costs 100 times the compute of the row above. The first factor of 100 lowers the loss by 0.37, the second by 0.23 and the third by 0.15.

Splitting a fixed compute budget
Say you have a fixed training compute budget. You can spend it on a bigger model, on more training tokens, or on a different balance of the two. For a dense transformer with $N$ parameters trained on $D$ tokens, a standard rough estimate is:
$$C \approx 6ND$$
Once $C$ is fixed, the product $ND$ is fixed too. Doubling the parameter count halves the number of tokens the budget can pay for. The code below spends the same $1.2 \times 10^{21}$ FLOPs on four model sizes:
1C = 1.2e21 # fixed training compute budget in FLOPs
2
3for N in [1e9, 3e9, 1e10, 3e10]:
4 D = C / (6 * N)
5 print(f"N = {N:.0e} parameters: D = {D:.1e} tokens, {D / N:.1f} tokens per parameter")
6
7N_opt = (C / (6 * 20)) ** 0.5
8print(f"20 tokens per parameter: N = {N_opt:.1e}, D = {20 * N_opt:.1e}")1N = 1e+09 parameters: D = 2.0e+11 tokens, 200.0 tokens per parameter
2N = 3e+09 parameters: D = 6.7e+10 tokens, 22.2 tokens per parameter
3N = 1e+10 parameters: D = 2.0e+10 tokens, 2.0 tokens per parameter
4N = 3e+10 parameters: D = 6.7e+09 tokens, 0.2 tokens per parameter
520 tokens per parameter: N = 3.2e+09, D = 6.3e+10The same budget gives a 30-billion-parameter model less than one token per parameter, and a 1-billion-parameter model 200. Other choices also change what a budget buys, such as the architecture, the sequence length and the optimizer.

An early answer leaned hard toward size: spend most of the budget on a bigger model and train it on comparatively little data. For a while, several of the largest dense language models grew their parameter counts much faster than their token counts.
The Chinchilla result
The Chinchilla scaling study changed that view. A very large model can be undertrained, meaning its parameters see too few tokens to learn from. At a fixed budget, a smaller model trained on many more tokens can reach a lower loss and score better on benchmarks. Across the sizes that study fitted, the best split came out near 20 training tokens per parameter, so parameters and tokens grew at roughly the same rate as the budget grew. In the code above, that rule puts a $1.2 \times 10^{21}$ FLOP budget at about 3.2 billion parameters and 63 billion tokens.
The 20 is an empirical number for the architectures, data and training schedule of that study, not a constant that carries over to every model. The part that carries over is that at a fixed budget, parameter count and token count have to move together.

The iso-compute valley
One clear way to see the balance is to fix one FLOP budget, train models of several sizes that all spend exactly that budget, and plot final loss against model size. The curve has a valley. Too few parameters and the model underfits, because it is too small to capture the patterns in the data. Too many parameters and it is undertrained, because each parameter sees too little data for the budget. The compute-optimal model sits near the bottom of the valley, where model size and training tokens are balanced.

Loss is only a proxy
Scaling laws predict loss, and loss is a proxy. A lower next-token loss means the model predicts held-out text better on average. It does not say which specific abilities the model will have. A scaling law can tell you how good the loss is likely to be at a given size. It cannot tell you whether a particular arithmetic, formatting or instruction-following skill will show up at that size, which is why those skills are tested separately.

Common mistakes
- Fitting on linear axes. A power law is a curve on ordinary axes. Fit the straight line on log-log axes, as
np.polyfit(np.log(params), np.log(losses), 1)does. - Mixing setups in one fit. Runs with different data, tokenizers, optimizers or schedules do not belong on the same line.
- Extrapolating far past the measured range. The further the forecast goes beyond the largest run, the less the fit has to back it.
- Treating 20 tokens per parameter as a law of nature. It is a measured ratio from one study's setup.
- Reading a loss forecast as a skill forecast. A lower loss does not say which task the model will be able to do.
Related concepts
How do LLMs work? covers pretraining and where the $C \approx 6ND$ estimate comes from. Emergent abilities in LLMs covers the other side of scale, tasks that sit near chance and then jump. Perplexity explained shows how the loss in these plots turns into perplexity.
QuiddityML teaches scaling laws and compute as one concept in the Intro to NLP track. The exercises on it include picking the line of code that computes a power-law loss and filling in the np.polyfit call that recovers $\alpha$ from measured runs. Another puts an iso-compute analysis in order, from fixing the budget to picking the split at the bottom of the valley.