QuiddityML

By · 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.

Question one, which abilities appear as models get larger (arithmetic, format following, multi-step questions), is answered by capability evaluation. Question two, how much loss each extra unit of compute buys, is a plot of test loss against training compute in FLOP from 10^18 to 10^24, with four measured points and a dashed forecast for the full run. Scaling laws measure what lower loss costs.

What a scaling law is

Three quantities come up again and again:

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.

Each dot is one trained model, with test loss falling from about 4.7 to 2.4 as parameters grow from 10^7 to 10^10 on a log scale, and a fitted line through them, since a scaling law comes from experiment, not from a proof. The fit needs parameter count, training tokens and training compute, matched architecture, data, optimizer and schedule, and a stated measured range.

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.

The same four runs on two sets of axes, with alpha = 0.08: on linear axes the test loss falls from 5.5 to about 3.2 along a curve as parameters grow to 10e9, and on log-log axes the same points sit on a straight line, since a straight line on log-log axes is a power law.

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.

Test loss against parameters on a log scale: a solid line fitted through four runs from 10^7 to 10^10 (the observed range), then a dashed extrapolation out to 10^11. The line is useful because it stays smooth across the sizes actually trained.

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.47

Three 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.

Validation loss against parameters on log-log axes: runs at 10^7, 10^8 and 10^9 measure 4.0, 3.4 and 2.9, and the extrapolated line forecasts 2.47 for the full run at 10^10. The small runs have to match on data mix, tokenizer, optimizer and schedule, or the fitted line can mislead you.

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.25

Every 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.

Test loss against compute on a log scale falls from 2.00 at 10^0 to 1.63 at 10^2, 1.40 at 10^4 and 1.25 at 10^6, toward an irreducible loss of 1.0. Each 100x more compute buys a smaller drop: 0.37, then 0.23, then 0.15. The loss keeps falling and the bill grows faster.

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+10

The 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.

A fixed training compute budget can go to a bigger model (more parameters) or to more training tokens, so the question is how to split it, with architecture, sequence length and optimizer as other choices. Size versus data, at a fixed cost.

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.

Same training budget: too much size is a huge model (parameters 4 units) with not enough tokens (1 unit), compute 4 x 1 = 4 units, while better balance is a smaller model (1 unit) with many more tokens (4 units), compute 1 x 4 = 4 units. Parameters need enough data to pay off.

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.

Final loss against model size at a fixed training compute is a U-shaped valley: too small underfits, too large is undertrained, and the best split sits at the bottom. Every point is the same FLOP budget with a different model size and token count, so compute-optimal means the lowest loss at the same cost.

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.

What the law predicts: test loss falls smoothly and predictably from 4.0 to about 2.5 as models grow from 10^7 to 10^11 parameters. What you care about: task accuracy stays on the chance line and then jumps near 10^10, which is not predictable from the loss alone. Lower loss means better held-out prediction on average, and it does not name which abilities appear.

Common mistakes

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.