All courses

Reading pretraining loss curves

Interpret a typical curve: a fast initial drop, then slow power-law-like decline, with training and validation loss nearly equal. Explain why near-single-epoch training rarely overfits.

Builds on: The LLM training loop, Loss per token and perplexity

▶ Watch this lesson Start the whole course

What the animation says

Where the curve starts

Here is a pretraining loss curve, logged every step. It starts near eleven, crashes to about four within a few thousand steps, then creeps down for weeks. Why near eleven? At the start the logits are near zero, so the model spreads its guess evenly over all fifty thousand tokens. A uniform guess has loss equal to the log of the vocabulary size: about ten point eight nats. So what does the model learn during that first crash?

Cheap patterns first, rare forever

The answer: cheap, frequent structure. Which tokens are common, and which tokens usually follow which. That touches nearly every token, so it's worth many nats. After that, every gain needs a rarer pattern: a name, an idiom, a fact that shows up once in a million tokens. Rare patterns help few tokens, so each extra nat costs far more data. That steady diminishing return is what makes the long, slow tail.

The power-law tail

The tail follows a power law: a floor, plus an excess that shrinks as steps grow. On log-log axes, the excess against steps is a straight line, with a small slope, often about minus zero point one. So every ten times more steps multiplies the excess by about zero point seven nine. Say the floor is one point eight, and at ten thousand steps the loss is three. The excess is one point two. What's the loss at a hundred thousand steps?

Reading numbers off a run

Two point seven five three. The excess fell from one point two to about zero point nine five. Another ten times, a million steps: the excess is about zero point seven six, so the loss is two point five five seven. The first ten times bought a quarter of a nat. The next bought only about zero point two. In perplexity, that's about twenty, then sixteen, then thirteen. Ten times more training for each step down, and each step gets smaller.

When is training loss measured?

Now the second surprise: validation loss sits right on top of training loss, the whole run. Where's the textbook overfitting picture, with validation rising while training keeps falling? Look at one step of a single pass. A fresh batch arrives that the model has never seen. The step runs a forward pass, a backward pass, then a weight update. Drag the loss tag onto the stage where the logged training loss is computed.

No repeats, no gap

The loss comes from the forward pass, before the update ever touches those weights. So each batch is unseen when it's scored. Training loss is already a held-out measurement, just noisier, from one batch. Overfitting means fitting quirks of specific examples, then scoring better on those same examples. That requires seeing an example again after training on it. In a single pass nothing repeats, so there's no gap. A gap can open only from epoch two.

What is a loss curve actually telling you?

Your pretraining run logs $\mathcal L$ every step. It starts near 11 nats, crashes to about 4 within a few thousand steps, then creeps down for weeks. Validation loss sits right on top of training loss the whole time. Why that shape? And why do you never see the textbook overfitting picture, where validation loss rises while training loss keeps falling?

Cheap patterns first, rare patterns forever

At initialization the logits are near zero, so the model predicts almost uniformly and $\mathcal L \approx \ln V$. The first steps learn cheap, frequent structure: which tokens are common and which tokens usually follow which. That structure affects nearly every token and is worth many nats. Each later gain needs rarer patterns that affect few tokens, so every extra nat costs far more data. That steady diminishing return gives the slow power-law tail.

The power-law tail

$$\mathcal L(s) \approx \mathcal L_\infty + a\,s^{-\alpha}$$ $s$: training steps (or tokens seen). $\mathcal L_\infty$: the floor the curve approaches. $a>0$: a scale constant. $\alpha>0$: a small exponent, often around 0.1. Taking logs gives $\log(\mathcal L-\mathcal L_\infty)=\log a-\alpha\log s$. That is a straight line on log-log axes with slope $-\alpha$. Each 10× in $s$ multiplies the excess above the floor by $10^{-\alpha}$.

Why training loss equals validation loss

In a single pass, the batch at step $s$ is fresh. Its loss is computed in the forward pass *before* the update that uses it, so the batch is independent of $\theta_s$: $$\mathbb E[\mathcal L_{\text{batch}}(\theta_s)] = \text{loss of }\theta_s\text{ on new data} \approx \mathcal L_{\text{val}}(\theta_s)$$ Training loss is therefore already a held-out measurement, just a noisier one because it comes from one batch. Overfitting means fitting quirks of specific training examples and then scoring better on those same examples. That requires seeing an example again after training on it. With no repeats there is no gap. A gap can open only once data repeats, from epoch 2 onward.

Reading numbers off a run

Take $V=50{,}257$. At step 0, $\mathcal L\approx\ln 50{,}257\approx10.8$. Suppose $\mathcal L_\infty=1.8$, $\alpha=0.1$, and the loss at 10k steps is 3.0, so the excess is 1.2. Each 10× multiplies the excess by $10^{-0.1}\approx0.794$: - 100k steps: $1.8+0.953=2.753$ - 1M steps: $1.8+0.757=2.557$ The gains shrink from 0.247 to 0.196 nats. Perplexity goes $20.1\to15.7\to12.9$.

Remember

The loss starts at $\ln V$ and drops fast as the model learns common structure. It then declines like a power law, with each 10× more training buying a shrinking gain. In single-pass training, every batch is unseen when its loss is computed, so training loss *is* a held-out estimate. The train and validation curves only separate once data repeats.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.