Chapter 9 · Section 9.4 · 65 min

Beyond Chinchilla

Meta trained Llama 3 8B on about 15 trillion tokens. By the rule of §9.3, a compute-optimal 8-billion-parameter model needs about 160 billion, and Meta's announcement said as much. "The Chinchilla-optimal amount of training compute for an 8B parameter model corresponds to ~200B tokens", yet "model performance continues to improve even after the model is trained on two orders of magnitude more data." Roughly 1,900 tokens per parameter, almost a hundred times the Chinchilla ratio. On Chinchilla's own terms, that run spent far more compute than a bigger model would have needed to reach the same loss.

It was not a mistake. Chinchilla answers a narrow question, which model reaches the lowest loss for a fixed training budget. Real models are trained once and then served billions of times, and they are trained on data that is finite, uneven in quality, and eventually used for something other than predicting the next token. This section relaxes Chinchilla's assumptions one at a time. First inference cost, which pushes models smaller and longer. Then finite data, what repeated epochs and surplus parameters are worth, and how to split a budget when the unique data is fixed. Then data quality as a multiplier on compute. And finally, scaling laws for what happens after pretraining, on downstream tasks and in fine-tuning.

Training once, serving forever

A language model's lifetime cost has two parts. Training costs 6NDtr6ND_{\text{tr}} FLOPs for NN parameters and DtrD_{\text{tr}} training tokens (§9.2). Serving costs about 2N2N FLOPs per token processed, the forward pass only (§5.6). If the model will process DinfD_{\text{inf}} tokens over its lifetime, prompts and generated tokens together, the total is

Ctotal(N,Dtr)=6NDtr+2NDinf.C_{\text{total}}(N, D_{\text{tr}}) = 6ND_{\text{tr}} + 2ND_{\text{inf}} .

Training cost depends on both NN and DtrD_{\text{tr}}, but inference cost depends only on NN. A model that will be used heavily should therefore be smaller, with the lost quality bought back with more training tokens. Sardana et al. (2024) turned this into a scaling law. Fix a target quality, a loss ℓ\ell, and minimize the total cost over all (N,Dtr)(N, D_{\text{tr}}) that reach it, using the Chinchilla loss L^(N,D)=E+A/Nα+B/Dβ\hat{\mathcal{L}}(N, D) = E + A/N^\alpha + B/D^\beta of §9.3,

min⁡N,Dtr  6NDtr+2NDinfsubject toL^(N,Dtr)=ℓ.\min_{N, D_{\text{tr}}}\; 6ND_{\text{tr}} + 2ND_{\text{inf}} \quad\text{subject to}\quad \hat{\mathcal{L}}(N, D_{\text{tr}}) = \ell .

In plain words, among all the models good enough for the job, pick the one that is cheapest to build and run.

The iso-loss curve

The constraint can be solved for the training tokens. For a model of size NN, the loss reaches ℓ\ell when B/Dtrβ=ℓ−E−A/NαB/D_{\text{tr}}^\beta = \ell - E - A/N^\alpha, so

Dtr(N)=(Bℓ−E−AN−α)1/β,defined whenN>Nmin⁡=(Aℓ−E)1/α.D_{\text{tr}}(N) = \left(\frac{B}{\ell - E - A N^{-\alpha}}\right)^{1/\beta}, \qquad\text{defined when}\quad N > N_{\min} = \left(\frac{A}{\ell - E}\right)^{1/\alpha} .

In plain words, a smaller model needs more tokens to reach the same loss, and below Nmin⁡N_{\min} it cannot reach it at all, because its size penalty A/NαA/N^\alpha alone already exceeds the allowed excess ℓ−E\ell - E. As NN approaches Nmin⁡N_{\min} from above, the required data explodes.

How much extra training does a smaller model need? The cell takes the compute-optimal model for a 102310^{23}-FLOP budget, with the replication's constants from §9.3, and shrinks it.

Python · cell 1

A model three quarters the size costs only 3 percent more to train. Half the size costs 26 percent more and trains on about 100 tokens per parameter. At 30 percent of the size it costs 2.6 times as much, at a fifth 14 times as much, and below about 15 percent of the optimal size the target is unreachable. The curve is flat near the optimum and then turns into a wall. Over-training is cheap in moderation and ruinous in excess.

The optimality condition

Where on this curve is the total cost lowest? Substitute Dtr(N)D_{\text{tr}}(N) into the cost and differentiate with respect to NN. Write g(N)=ℓ−E−AN−αg(N) = \ell - E - AN^{-\alpha}, so Dtr=(B/g)1/βD_{\text{tr}} = (B/g)^{1/\beta} and gg equals the data penalty BDtr−βB D_{\text{tr}}^{-\beta}. By the chain rule,

dDtrdN=−1β Dtr g′(N)g(N)=−1β Dtr αAN−α−1g(N),soNdDtrdN=−αβ Dtr AN−αBDtr−β.\frac{dD_{\text{tr}}}{dN} = -\frac{1}{\beta}\,D_{\text{tr}}\,\frac{g'(N)}{g(N)} = -\frac{1}{\beta}\,D_{\text{tr}}\,\frac{\alpha A N^{-\alpha - 1}}{g(N)}, \qquad\text{so}\qquad N\frac{dD_{\text{tr}}}{dN} = -\frac{\alpha}{\beta}\,D_{\text{tr}}\,\frac{AN^{-\alpha}}{BD_{\text{tr}}^{-\beta}} .

Setting the derivative of 6NDtr(N)+2NDinf6ND_{\text{tr}}(N) + 2ND_{\text{inf}} to zero gives 6Dtr+6N dDtr/dN+2Dinf=06D_{\text{tr}} + 6N\,dD_{\text{tr}}/dN + 2D_{\text{inf}} = 0, and substituting,

AN−αBDtr−β=βα(1+Dinf3Dtr).\frac{AN^{-\alpha}}{BD_{\text{tr}}^{-\beta}} = \frac{\beta}{\alpha}\left(1 + \frac{D_{\text{inf}}}{3D_{\text{tr}}}\right) .

In plain words, without inference (Dinf=0D_{\text{inf}} = 0) this is Chinchilla's balance condition from §9.3, size penalty over data penalty equals β/α\beta/\alpha. With inference, the optimum tolerates a larger size penalty and a smaller data penalty, a smaller model trained longer, by the factor 1+Dinf/(3Dtr)1 + D_{\text{inf}}/(3D_{\text{tr}}). If the model will serve as many tokens as it was trained on, the factor is 4/34/3. If it serves a hundred times more, the factor is about 34.

There is no closed-form solution, because DtrD_{\text{tr}} appears on both sides. Sardana et al. solve it numerically, and so will you.

Interview

The cheapest model for a target loss and an inference load

Implement inference_optimal(target, D_inf, E, A, B, alpha, beta) returning (N, D_tr, total), the model size and training tokens that reach loss target with the lowest 6NDtr+2NDinf6ND_{\text{tr}} + 2ND_{\text{inf}}, and that lowest total. Search over NN between Nmin⁡N_{\min} (exclusive) and 104Nmin⁡10^4 N_{\min}, for example with scipy.optimize.minimize_scalar on log⁡10N\log_{10}N with bounds, using the iso-loss curve for Dtr(N)D_{\text{tr}}(N). With D_inf = 0 your answer must match Chinchilla's closed form, and your solution must satisfy the optimality condition above.

Hidden tests, hints, and AI help, from $1.99 a month.

What the numbers say

Sardana et al. give three examples, which your solution reproduces. A team planning a 13-billion-parameter Chinchilla-optimal model that expects 2 trillion tokens of inference should instead train a 7-billion-parameter model on about twice the data, saving about 1.7×10221.7\times10^{22} FLOPs, 17 percent of the total. For a 7B-quality model with only 101110^{11} inference tokens the optimum barely moves, to 6B on 1.18 times the data. And for a 30B-quality model serving 101310^{13} tokens, the cheapest option is a 13.6B model on 2.84 times the data, with total FLOPs 28 percent lower.

FLOPs understate the case for small models. Generating tokens one at a time is limited by memory bandwidth, not arithmetic (§6.5), so each inference FLOP is far more expensive than a training FLOP. Sardana et al.'s cost model assumes 50 percent utilization for training and prompt processing, but about 1 percent for generation. In dollars, the optimum moves to even smaller, longer-trained models than in FLOPs. The widget lets you scale the cost of an inference FLOP to see this.

If a model will serve many tokens, how small should it be, and how long should you train it?
Every point on these curves reaches the same loss as the compute-optimal model for the reference budget. Smaller models need more training tokens but cost less per served token. The total cost picks the winner.
Loading interactive figure…

Over-training in practice

This reasoning explains the shape of nearly every open model family since 2023. The LLaMA paper said it directly. Chinchilla's objective "disregards the inference budget", and "given a target level of performance, the preferred model is not the fastest to train but the fastest at inference" (Touvron et al. 2023). LLaMA's 7B and 13B models trained on 1 trillion tokens, about 150 and 77 per parameter, and the authors noted that "the performance of a 7B model continues to improve even after 1T tokens". Llama 2 trained every size on 2 trillion. Llama 3 trained its 8B and 70B models on about 15 trillion, and its paper notes that "we also train our smaller models for much longer than is compute-optimal".

Python · cell 2

By the replication's fit (on MassiveText, so these are illustrations, not claims about Meta's data), Llama 3 8B spent several times the compute a compute-optimal model would need for the same loss. In exchange every token it serves costs a fraction of what the larger model would charge. For a model downloaded and run by millions of people, that trade is easily worth it.

Two cautions come with the extreme ratios. First, the Chinchilla fit was made on runs near 20 tokens per parameter, and extrapolating it to 1,000 or 10,000 is risky. Sardana et al. trained 47 models at up to 10,000 tokens per parameter and found that loss keeps falling, with no plateau, but more slowly than the fit predicts. Fitted only on typical ratios, the Chinchilla form "overestimates the impact of additional training data" as runs move to extreme ratios. Second, if you plan to over-train, fit your scaling law in the over-trained regime. Gadre et al. (2024) did exactly that. With the token multiplier M=D/NM = D/N, they found that at a fixed MM the loss still follows a power law in compute, L(C,M)=E+(aMη+bM−η) C−η\mathcal{L}(C, M) = E + (aM^{\eta} + bM^{-\eta})\,C^{-\eta}, with the same exponent for every MM. That let them predict a 1.4-billion-parameter model trained on 900 billion tokens, 32 times over-trained, from runs that used 300 times less compute.

Core

The price of a smaller model

Implement overtraining_overhead(k, C, E, A, B, alpha, beta). Take the compute-optimal model for budget C, with size N0N_0 and loss ℓ0\ell_0. Return the ratio of the training compute a model of size kN0kN_0 needs to reach ℓ0\ell_0 to the original budget C, or float("inf") if it cannot reach ℓ0\ell_0. This curve is the over-training "tax" printed by the first cell of this section.

Hidden tests, hints, and AI help, from $1.99 a month.

When the data runs out

Chinchilla assumes every training token is new. For the largest models that assumption is breaking. A compute-optimal model at 102610^{26} FLOPs wants about 20 trillion tokens, and an over-trained one far more, while the stock of high-quality public text is finite. Villalobos et al. (2024) project that, at current trends, models will be trained on datasets roughly as large as the whole stock of public human text sometime between 2026 and 2032. The natural response is to repeat data. How much is a second, fourth, or sixteenth epoch worth?

Muennighoff et al. (2023) trained over 400 models, up to 9 billion parameters and 900 billion tokens, for up to 1,500 epochs, and found a clean answer. Write UDU_D for the number of unique tokens and RDR_D for the number of repetitions, epochs minus one. Repeated tokens are worth less than new ones, with a value that decays exponentially in the number of repetitions, so the effective data is

D′=UD+UDRD∗(1−e−RD/RD∗),RD∗≈15.4.D' = U_D + U_D R_D^{\ast}\left(1 - e^{-R_D/R_D^{\ast}}\right), \qquad R_D^\ast \approx 15.4 .

In plain words, the first pass counts in full. Each further pass is worth a little less than the previous one, and the total value of all repetitions together can never exceed RD∗R_D^\ast more copies of the unique data. Fitted to their runs, RD∗=15.39R_D^\ast = 15.39.

Two limits check the formula. With no repetition, RD=0R_D = 0 and D′=UDD' = U_D. For small RDR_D, 1−e−x≈x1 - e^{-x} \approx x, so D′≈UD(1+RD)D' \approx U_D(1 + R_D), the full value of every epoch. As RD→∞R_D \to \infty, D′→UD(1+RD∗)≈16.4 UDD' \to U_D(1 + R_D^\ast) \approx 16.4\,U_D, the most any amount of repetition can be worth.

Where does an exponential come from? The paper's own derivation is short and worth knowing, because an interviewer may ask you to produce the formula rather than recite it.

∂ Effective data from a geometric series

Assume that each pass over a token teaches the model a fixed fraction of what the previous pass taught, so a repeat is worth 1−δ1 - \delta times the pass before it, for some 0≤δ≤10 \le \delta \le 1. With UDU_D unique tokens seen once and then RDR_D more times, the effective data is a geometric series,

D′=UD+(1−δ)UD+(1−δ)2UD+⋯+(1−δ)RDUD=UD+UD (1−δ)(1−(1−δ)RD)δ.D' = U_D + (1-\delta)U_D + (1-\delta)^2 U_D + \dots + (1-\delta)^{R_D}U_D = U_D + U_D\,\frac{(1-\delta)\big(1 - (1-\delta)^{R_D}\big)}{\delta} .

As RD→∞R_D \to \infty the bracket tends to 1 and D′→UD+UD(1−δ)/δD' \to U_D + U_D(1-\delta)/\delta. Name that ceiling, RD∗=(1−δ)/δR_D^\ast = (1-\delta)/\delta. For small δ\delta, 1−δ≈e−δ1 - \delta \approx e^{-\delta} and δ≈1/RD∗\delta \approx 1/R_D^\ast, so (1−δ)RD≈e−RD/RD∗(1-\delta)^{R_D} \approx e^{-R_D/R_D^\ast} and (1−δ)/δ=RD∗(1-\delta)/\delta = R_D^\ast exactly. Substituting both,

D′=UD+UDRD∗(1−e−RD/RD∗).D' = U_D + U_D R_D^\ast\left(1 - e^{-R_D/R_D^\ast}\right) .

The series also works for a fractional number of repeats, which is why the formula accepts any RD≥0R_D \ge 0. A check by hand. With δ=0.25\delta = 0.25 (RD∗=3R_D^\ast = 3) and five epochs (RD=4R_D = 4), the exact series gives 1+0.75(1−0.754)/0.25=3.051 + 0.75(1 - 0.75^4)/0.25 = 3.05 epochs' worth, and the exponential form gives 1+3(1−e−4/3)=3.211 + 3(1 - e^{-4/3}) = 3.21. The approximation is loose at this large δ\delta. At the fitted δ≈1/16.4≈0.06\delta \approx 1/16.4 \approx 0.06 the two forms agree to within 2 percent over the first sixteen epochs.

In plain words, RD∗R_D^\ast is the decay time of a token's value, counted in passes. After RD∗R_D^\ast repetitions, the next pass is worth e−1≈37e^{-1} \approx 37 percent of fresh data, and the total can never pass 1+RD∗1 + R_D^\ast unique epochs.

The headline numbers are worth memorizing. "Training with up to 4 epochs of repeated data yields negligible changes to loss compared to having unique data." Meaningful gains continue up to about 16 epochs, and by about 40 epochs, in the words of the paper's first figure, "repeating is worthless". Beyond that, "the value of adding compute eventually decays to zero."

Python · cell 3

Four epochs keep 93 percent of the value of fresh data. Sixteen epochs keep 66 percent on average, and by a hundred epochs the average token is worth about a sixth of a new one, while the ceiling of 16.4 times the unique data never moves. The marginal value falls faster. The pass after RDR_D repetitions adds about e−RD/RD∗e^{-R_D/R_D^\ast} of a fresh epoch, the derivative of D′/UDD'/U_D with respect to RDR_D. That is 82 percent for the fourth pass, 38 percent for the sixteenth, and under 2 percent for the sixty-fourth.

Core

Effective tokens with repetition

Implement effective_data(unique_tokens, total_tokens, R_star=15.387756) returning Muennighoff et al.'s effective data D′D' when total_tokens are drawn by cycling through unique_tokens unique ones. The number of repetitions is RD=total/unique−1R_D = \text{total}/\text{unique} - 1, which need not be an integer. If total_tokens is less than unique_tokens, nothing repeats and D′D' is just total_tokens. Then implement repeated_loss(N, unique_tokens, total_tokens, E, A, B, alpha, beta), the Chinchilla loss with D′D' in place of DD. It should work on scalars.

Hidden tests, hints, and AI help, from $1.99 a month.

Excess parameters, and the full law

Repetition is half the story. With a fixed set of UDU_D unique tokens, you can also spend more compute on a bigger model, and that runs into diminishing returns too, because extra parameters keep learning the same features from the same data. Muennighoff et al. treat model size the way they treat data. Let UNU_N be the compute-optimal size for the unique data, the Chinchilla NoptN_{\text{opt}} whose matching DoptD_{\text{opt}} equals UDU_D (or NN itself, if the model is smaller than that). Parameters beyond UNU_N count as repetitions, RN=max⁡(N/UN−1,0)R_N = \max(N/U_N - 1, 0), and are worth

N′=UN+UNRN∗(1−e−RN/RN∗),RN∗≈5.3.N' = U_N + U_N R_N^\ast\left(1 - e^{-R_N/R_N^\ast}\right), \qquad R_N^\ast \approx 5.3 .

The full data-constrained law is Chinchilla's with both substitutions,

L^(N,D; UD)=E+AN′ α+BD′ β.\hat{\mathcal{L}}(N, D;\, U_D) = E + \frac{A}{N'^{\,\alpha}} + \frac{B}{D'^{\,\beta}} .

In plain words, a model is charged for its size and its data as before, except that repeated tokens and surplus parameters are discounted, each with its own decay time. With no repetition and a model no bigger than UNU_N, it is exactly the Chinchilla law of §9.3.

The fit came in two stages. First the Chinchilla constants, on single-epoch runs on C4, their training data, with α\alpha and β\beta tied because Hoffmann et al. had found equal scaling on C4. That gave E=1.87E = 1.87, A=520.8A = 520.8, B=1487.7B = 1487.7, and α=β=0.353\alpha = \beta = 0.353. Then, holding those fixed, RN∗=5.31R_N^\ast = 5.31 and RD∗=15.39R_D^\ast = 15.39 from 182 runs between 7 million and 9 billion parameters and 1 to 500 epochs. With α=β\alpha = \beta the optimum of §9.3 has Nopt/Dopt=G2=(A/B)1/αN_{\text{opt}}/D_{\text{opt}} = G^2 = (A/B)^{1/\alpha}, so UN=0.051 UDU_N = 0.051\,U_D, about 19.6 tokens per parameter.

Because RN∗<RD∗R_N^\ast < R_D^\ast, surplus parameters lose their value about three times faster than surplus epochs. The paper's conclusion follows. When data is the constraint, "the data-constrained efficient frontier suggests allocating most additional compute to more epochs rather than more parameters", where Chinchilla would scale both equally.

Spending a budget when the data is fixed

Here is the interview version. You have 25 billion unique tokens and 9.3×10219.3\times10^{21} FLOPs. Ignoring the data limit, Chinchilla (with the C4 constants) says 8.9 billion parameters on 174 billion tokens, seven epochs. The cell finds the size that minimizes the data-constrained law on the same budget, D=C/(6N)D = C/(6N), and then keeps adding compute with the data held fixed. It uses its own names for the C4 constants, so the earlier cells keep theirs.

Python · cell 4

At 9.3×10219.3\times10^{21} FLOPs the law prefers a 6.8-billion-parameter model on nine epochs, about a quarter smaller than Chinchilla's choice. Muennighoff et al. trained that comparison for real. Their frontier picked 6.3 billion parameters on 242 billion tokens, and "despite having 27% fewer parameters, this model achieves better loss and downstream performance" than the 8.7-billion-parameter Chinchilla allocation. Notice how small the predicted gain is, about 0.002 nats. The valley is flat, as it was in §9.3, and the case for the smaller model is as much about cheaper inference as about loss.

The rest of the table shows what fixed data does to a growing budget. From 102210^{22} to 102410^{24} FLOPs the optimal model grows about eightfold while its epochs grow about thirteenfold, so the extra compute goes mostly into repetition, as the paper says. And it buys very little. The last factor of ten lowers the loss by under 0.01 nats, because both discounted terms are near their ceilings, D′≤16.4 UDD' \le 16.4\,U_D and N′≤6.3 UNN' \le 6.3\,U_N. With 25 billion tokens, a budget much beyond 102310^{23} FLOPs is better spent finding more data. The same logic at the extreme is in the paper's 100-million-token experiments, where the best loss came from about 20 to 60 times more parameters and epochs than the single-epoch optimum, roughly 7,000 times more compute, for a loss more than 50 percent lower than one epoch gives.

Interview

The compute-optimal model when unique data is fixed

Using Muennighoff et al.'s law with the constants in the setup, implement dc_loss(N, D, U), the predicted loss of a model with N parameters trained on D tokens drawn from U unique tokens, and data_constrained_optimum(C, U) returning (N, D) that minimize it subject to 6ND=C6ND = C. Follow the definitions exactly. The unique tokens used are UD=min⁡(D,U)U_D = \min(D, U) and RD=D/UD−1R_D = D/U_D - 1. The base size is UN=min⁡(Nopt(UD),N)U_N = \min(N_{\text{opt}}(U_D), N) with Nopt(UD)=G2UDN_{\text{opt}}(U_D) = G^2 U_D (the setup's G already uses α=β\alpha = \beta), and RN=N/UN−1R_N = N/U_N - 1. Search over log⁡10N\log_{10}N in [6,13][6, 13] with minimize_scalar and a tight xatol.

Hidden tests, hints, and AI help, from $1.99 a month.

Where the formula breaks

The law is a fit, and its authors list its limits. It cannot predict harm. By construction more epochs or parameters can only plateau, never make the loss worse, yet in their runs models trained on too many repetitions did get worse, and some loss curves "diverge if too many epochs are used". They removed such runs as outliers before fitting, and some runs showed double descent, the loss rising and then falling again as epochs grew. Treat the formula as an upper bound on what repetition buys. The largest budgets in the cell above, at 70 to 120 epochs, are exactly where that caution applies.

It also assumes the whole dataset is repeated evenly. Repeating a small part of it many times is far worse. Hernandez et al. (2022) found that repeating 0.1 percent of the data a hundred times made an 800-million-parameter model perform like one half its size (§8.3). In a mixture, each domain has its own epoch count, ei=wiD/Nie_i = w_iD/N_i (§8.4). Applying the effective-data formula domain by domain, so that no domain passes a few epochs, is a reasonable heuristic, not a result from the paper.

And RD∗R_D^\ast belongs to a model and a recipe, not to the data. Kim et al. (2025) found that when data is the constraint, much stronger regularization pays (a weight decay about 30 times the usual value), together with ensembles of independently trained models. Combined with epoching and larger models, their best recipe was worth 5.17 times as much data as the standard one. Prabhudesai et al. (2025) fitted the same law to masked diffusion language models, which predict randomly masked tokens in any order rather than left to right, and found RD∗R_D^\ast near 500 against about 32 for autoregressive models trained the same way. In their runs repeated data stayed nearly as good as fresh for up to about 100 epochs, against about 4. An objective that sees each sequence in many orders extracts more from every repetition.

Stretching unique data further

Muennighoff et al. also tested two ways to stretch a fixed supply of text. Filling up to half of the training data with code caused no measurable harm on natural-language tasks, which in their accounting doubles the effective tokens available. And filtering by perplexity helped, while deduplication alone did not, mainly on noisy data. Beyond that lie synthetic data, rephrasing, and distillation from a larger model, all discussed in §8.4, where the risks of training on model outputs are also covered.

Data quality as a compute multiplier

Every law in this chapter treats a token as a token. But the constants of a scaling law are properties of the data. Better data shifts the whole curve down, so the same loss, or the same downstream accuracy, is reached with less compute. A useful way to think about a better data pipeline is as a compute multiplier, the factor of compute it saves at a fixed quality. Filtering web text with model-based quality classifiers, as FineWeb-Edu and DCLM do (§8.2), is among the largest such multipliers reported for language models.

Quality also changes the optimal allocation. DeepSeek's scaling study (DeepSeek-AI 2024) fit compute-optimal exponents on three datasets and found a=0.450a = 0.450 on an early version of its data, 0.5240.524 on its improved data, and 0.5780.578 on OpenWebText2, concluding that the higher the quality of the data, the more of a growing budget should go to the model rather than to more tokens.

And quality interacts with quantity. Filtering harder leaves fewer unique tokens, which then have to be repeated. The cell compares two hypothetical pipelines for a 7-billion-parameter model trained on 4 trillion tokens. One keeps 4 trillion unique tokens, the other keeps the best quarter, assumed (for illustration only) to be worth twice as much per token, and repeats it four times.

Python · cell 5

Under these assumptions, four epochs of the filtered quarter beat one pass over everything, because repetition at four epochs costs only 7 percent while quality doubled the value. Sixteen epochs of an even smaller set give back about half of that gain. Real quality multipliers have to be measured, not assumed, and they need not stay constant as data repeats, but this is the shape of the decision every pretraining team faces.

There is even evidence that good data selection can beat power-law scaling altogether. Sorscher et al. (2022) showed theoretically, and in vision experiments, that pruning a dataset with a good enough measure of example difficulty can make error fall exponentially rather than as a power law in the amount of data kept. Finding such a measure at the scale of web text remains open.

Scaling laws after pretraining

Pretraining loss is a means, not an end. What matters is how well the model does downstream, after fine-tuning, on the tasks people care about. Scaling laws exist here too, though they are less mature.

Downstream accuracy from loss. Gadre et al. (2024) related the average top-1 error of a model over 17 downstream tasks to its loss, with Err(L)=ϵ−k e−γL\text{Err}(\mathcal{L}) = \epsilon - k\,e^{-\gamma\mathcal{L}}, and predicted it with 20 times less compute than the runs being predicted. Because e−γL=PPL⁡−γe^{-\gamma\mathcal{L}} = \operatorname{PPL}^{-\gamma}, this is a power law in perplexity. §9.6 builds a two-step predictor of this kind, the method Llama 3 used.

Pretraining as a data multiplier for fine-tuning. Hernandez et al. (2021) asked how much a pretrained model's knowledge is worth in fine-tuning data. They defined the effective data transferred DTD_T, the amount of extra fine-tuning data a model trained from scratch would need to match the pretrained model, and found

DT=k DFα Nβ,D_T = k\,D_F^{\alpha}\,N^{\beta},

where DFD_F is the fine-tuning data and DTD_T is measured in the same units, characters of text in their experiments, and NN the non-embedding parameters (here α\alpha and β\beta are this paper's exponents, not Chinchilla's). For transfer from English text to Python code they fit k=1.9×104k = 1.9\times10^{4}, α=0.18\alpha = 0.18, and β=0.38\beta = 0.38. In plain words, in the low-data regime pretraining "effectively multiplies the fine-tuning dataset", and since β≈2α\beta \approx 2\alpha, a tenfold larger model is worth about a hundredfold more fine-tuning data. In their Figure 1, for a 40-million-parameter model fine-tuned on 300,000 characters of Python, the effective data transferred was about a thousand times the fine-tuning set.

Warm-up

How much is pretraining worth in fine-tuning data?

Using Hernandez et al.'s text-to-Python fit (k=1.9×104k = 1.9\times10^{4}, α=0.18\alpha = 0.18, β=0.38\beta = 0.38), implement transfer_multiplier(D_F, N) returning (DF+DT)/DF(D_F + D_T)/D_F, the factor by which pretraining multiplies the fine-tuning data. Then implement size_equivalent(factor) returning how many times more fine-tuning data is worth the same as multiplying NN by factor, in the low-data regime where DT≫DFD_T \gg D_F.

Hidden tests, hints, and AI help, from $1.99 a month.

Scaling laws for fine-tuning itself. Zhang et al. (2024) fine-tuned models from 1 to 16 billion parameters on translation and summarization, with full fine-tuning, prompt tuning, and LoRA (§14.5), and found a multiplicative joint law, L^(X,Df)=A X−αDf−β+E\hat{\mathcal{L}}(X, D_f) = A\,X^{-\alpha}D_f^{-\beta} + E, where DfD_f is the fine-tuning data and XX is whichever factor is scaled (model size, pretraining data, or the number of tunable parameters). Their findings are practical. Fine-tuning "benefits more from LLM model scaling than pretraining data scaling", scaling the number of parameter-efficient tuning parameters, such as the LoRA rank, "is generally ineffective", and the best fine-tuning method "is highly task- and finetuning data-dependent".

What changes, and what does not

assumption in Chinchillawhat replaces itconsequence
only training compute countslifetime cost 6NDtr+2NDinf6ND_{\text{tr}} + 2ND_{\text{inf}}smaller models, many more tokens per parameter (Sardana 2024)
fits made near 20 tokens per parameterfits in the over-trained regime (Gadre 2024)extrapolations to 1,000 tokens per parameter are optimistic
every token is neweffective data D′D' with RD∗≈15.4R_D^\ast \approx 15.4, effective parameters N′N' with RN∗≈5.3R_N^\ast \approx 5.3 (Muennighoff 2023)up to 4 epochs are nearly free, beyond 16 returns fade, and extra compute goes mostly to epochs
every token is equalquality as a compute multiplierbetter data shifts the curve and the allocation (DeepSeek 2024)
loss is the goaldownstream and fine-tuning lawspretraining multiplies fine-tuning data (Hernandez 2021)

In PyTorch

The inference-aware optimum with autograd doing the work. We optimize log⁡N\log N by gradient descent on the total cost, with DtrD_{\text{tr}} computed from the iso-loss curve inside the graph, and check the optimality condition at the end.

🔥 In PyTorchfor a machine with PyTorch

Read more

Watch next

🎬 Scaling Data-Constrained Language Models · Sasha RushA clear 25-minute explanation of the repeated-data scaling law, the effective-data formula, and its practical advice.
🎬 Niklas Muennighoff - Scaling Data-Constrained Language Models · CohereThe first author on the same paper, with more detail on the experiments and the code and filtering results.