Data mixing, curricula and continued-pretraining ratios

Reading: 45 min, plus 23 in closed details. How much of each kind of data a language model trains on, how often it may repeat, in what order, and how much general data a continued-pretraining run keeps. Child of Topic: data-curation-and-datasets; it also holds everything the former Continued Pretraining (CPT) page taught. Data as of October 2026.

The idea in one screen

A pretraining run is one token budget split across piles of text: the weight of each pile fixes how many times it is read, the order fixes what the model sees while the learning rate decays, and continued pretraining is the same split made later on a finished model, with general data replayed beside the new domain so the model does not forget.

The figure on the right draws the three decisions on two real recipes; the rest of the page takes them one at a time.

You need: the Pretraining page for scaling laws (section 3), stages (section 4) and what the anneal buys (section 5, with the anneal toy and OLMo 2's split of its gain into learning rate and data); the warmup-stable-decay schedule and the three meanings of "annealing" are on Optimisers and learning-rate schedulers; the piles themselves on Pretraining corpora.

Three decisions, drawn on two real recipes. Left: SmolLM3's 11.14T-token run from its released stage configs (shares grouped by this page; learning rate drawn as its warmup-stable-decay shape). Right: DeepSeekMath's 500B-token continued pretraining of a 7B code model, its mix as the paper states it.
  1. Weights (sections 1 to 4): English web is 70% of stage 1; each share times the budget, over the pile's size, is how many times the pile is read.
  2. Order (section 5): in the decay stage, while the learning rate falls to zero, code rises to 23% and maths to 12.5%.
  3. Continued pretraining (section 6): 56% new maths web text, and the other 44% is code, arXiv, AlgebraicStack and Common Crawl text, data close to what the base already knew.

New terms

domain
any group of documents treated as one pile: a source, a type, a quality bucket, a language, an embedding cluster
mixture weight wi
the share of training tokens drawn from domain i; the weights sum to 1
epochs
how many times a domain is read: wi·D / Ui
effective tokens D′
the fresh data that repeated data is worth
proxy model
a small, short run trained to learn something about mixtures that transfers to the big one
excess loss
a proxy's loss minus a reference model's, clipped at 0: what is learnable but not yet learned
rank invariance
the bet that mixtures rank the same by loss at small and large scale
decay stage (mid-training, anneal)
the final stage, where the learning rate falls and the mix shifts to the best data
continued pretraining (CPT)
more next-token training of a finished base model on new data
replay
general data mixed back into a CPT stream to limit forgetting
critical mixture ratio (CMR)
the largest domain share whose general loss stays within a tolerance

The methods, side by side:

MethodWhat it doesCost to choose the weightsEvidence (who measured)Verdict
Natural sharesEach pile in proportion to its sizenonebaseline everywhereSmall, valuable piles drown
Hand weightsUpweight piles believed to be good, cap epochs (The Pile, GPT-3)nonebaseline in DoReMi and RegMixHard to beat by much; often what labs still do, with ablations
Temperature, UniMaxFlatten the natural shares (multilingual); UniMax caps epochsnoneUniMax beat temperature at every size tested (Chung et al. 2023)Use UniMax-style caps for many small piles
DoReMiA small proxy trained with Group DRO upweights domains where it lags a reference model2 small runs (8% of the big run in the paper)+6.5 points on 5 one-shot tasks at 8B (authors); worse than plain stratified sampling in 3 of 6 settings at 160M (Aioli, third party)Useful, sensitive; check against simple baselines
Data Mixing LawsFit loss as an exponential of the weights on small runs, extrapolate with scaling lawstens of small runs1B on 100B tokens matched the default mix trained 48% longer (authors)Interpretable; the functional form fits RegMix's data well (refit here)
RegMixTrain hundreds of tiny models on random mixtures, regress loss on weights, pick the best predicted mix512 runs of 1M parameters (2% of one 1B run, authors)Rank of mixtures transfers 1M to 1B at ρ 0.97 (authors; reproduced here from their released runs)The current default for offline search
Online methods (ODM, Skill-It, Aioli)Change the weights during the real run from training signalslittle extra computeAioli beat stratified sampling on 6 of 6 settings at 160M (authors)Promising; small-scale evidence only
Stages and the annealBroad data first, best data at the end while the learning rate decaysa few anneal ablationsOLMo 2 7B GSM8K 24.1 to 67.5 after 50B tokens (authors); SmolLM2 maths 3.2 to 22.1 in stage 4Standard in every 2025 to 2026 open recipe
Replay in CPTMix general data back into the new-domain streamnone1% replay removed 52% of the forgetting at 405M, 25% removed 89% (Ibrahim et al.)Always keep some; it is nearly free
CMR law (CPT)Fit general and domain loss against the domain share on short runs, take the largest share that keeps general loss within a tolerancea few short runsDomain shares 29.8% to 47.8% from 460M to 3.1B on finance (authors)The principled way to set the replay ratio

Running examples. The Pile's 22 domains, because DoReMi, RegMix and the papers that check them all ran on it, so one set of real sizes, weights and results connects sections 1 to 3. A five-domain proxy experiment built from the topic's running-example samples (web from DCLM-baseline, Wikipedia, code from Stack-Edu, maths from FineMath, papers from peS2o) runs DoReMi in section 3. And for continued pretraining, a small model trained here on English and continued on German, with and without replay, in section 6.

Labels: published a paper's or a config's own number, with its table; derived computed here from published inputs, formula shown (in src/recompute.py and src/cpt/recompute_cpt.py); measured run on this page's machine (Apple M1 Pro); illustrative made-up inputs that teach a mechanism.

1. Domains, weights and epochs

A domain is whatever grouping you choose, and every method below optimises weights over the groups you give it: a source (Wikipedia, GitHub), a type (maths web pages), a quality bucket (Nemotron-CC's "high"), a language, or a cluster of embeddings (CLIMB clusters documents instead of trusting source labels). With a budget of D tokens, domain i supplies wi·D of them; if it holds Ui unique tokens, it is read wi·D / Ui times. Upweighting a small domain is the same act as repeating it.

epochsi = wi · D / Ui
wi
weight of domain i (share of training tokens)
D
total training tokens
Ui
unique tokens available in domain i

The Pile (EleutherAI, 2020) is the clearest published example of hand weights: its Table 1 lists every component's raw size, weight and epochs. Its authors "attempted to upweight academic texts the most" and smaller sets, "strictly disallowed any data more than 3 epochs and avoided having any data with more than 2 epochs" (The Pile, Table 1 and Appendix D.1) published.

Fig. 1 · The Pile's hand weights, pile by pile

  1. Twenty-two piles at their raw size. Each column is one component of The Pile, its height its raw size from Table 1: Pile-CC 227.12 GiB at the back left, Enron Emails 0.88 GiB at the front right, 825.18 GiB in all. The front row, the eleven smallest piles, holds 54.2 GiB, 6.6% of the total derived.
  2. The weights draw one stream. Dots flow from each pile into the training stream in front, which is laid out by weight: Pile-CC 18.11%, PubMed Central 14.40%, Books3 12.07%, down to Enron Emails 0.14%. The eleven smallest piles get 9.34% of the stream, more than their 6.6% of the bytes.
  3. Weight × budget ÷ size = epochs. The stream is 1,254.20 GiB, so each pile is read wi · 1,254.20 / Ui times, drawn as one more layer per pass: Pile-CC and Github once, Books3, FreeLaw, OpenSubtitles and BookCorpus2 1.5 times, the other fourteen twice, Gutenberg 2.5 times.
  4. Close on Wikipedia. 1.53% of 1,254.20 GiB is 19.19 GiB, taken from a pile of 6.38 GiB: 3.0 passes, the most of any pile and The Pile's own cap. Upweighting Wikipedia and repeating it are one decision.
  5. Natural shares, for comparison. Weight every pile by its size instead and each is read 1,254.20 / 825.18 = 1.52 times: Pile-CC takes 27.5% of the stream and Wikipedia 0.77% derived. The hand weights moved budget from the web pile to repeated small piles, which is what every method below also decides.
Table 1 as bars: weight, raw size and epochs of all 22 rows

Small academic sets get large weights and up to 3 epochs; the web pile gets about one. The Pile, Table 1 (arXiv 2101.00027v1), all 22 rows. Sizes are bytes (GiB), not tokens; bytes per token differ by domain, so byte weights are close to but not equal to token weights. Checks in recompute.py: raw sizes sum to 825.18 GiB, effective sizes (raw × epochs) to 1,254.20 GiB, and each weight equals its effective size over 1,254.20 within rounding derived. The † components (Books3 and four others) were taken with minimal processing; Books3 is no longer distributed for copyright reasons, which is why RegMix uses 17 of the 22.

Flattening the natural shares: temperature sampling and UniMax

Taking each domain in proportion to its size (its natural share pi) lets the largest pile dominate. Multilingual models fixed this with temperature sampling: raise every share to the power 1/τ and renormalise; τ = 1 keeps natural shares, large τ approaches uniform.

qi = pi1/τ / Σj pj1/τ
pi
natural share of domain i (its size over the total)
τ
temperature: mBERT 1.43, XLM 2.00, XLM-R and mT5 3.33 (UniMax paper, Table 1); some papers write α = 1/τ, so mT5's "α = 0.3"

Temperature fixes the shares without looking at the budget, so a long run reads the smallest domains many times. UniMax (Chung et al. 2023) starts from the budget: go through the domains from smallest to largest, give each an equal share of what is left unless that exceeds N epochs of it, in which case give it exactly N epochs (UniMax, Algorithm 1). With N = 1 nothing repeats. On mT5-style models up to XXL, UniMax beat τ = 1 and τ = 3.33 on TyDi QA and WMT21 at every scale; in the N ablation N = 1 was best "but the effect is small" (Table 2) published.

Predict, then move the slider to 3.33: at The Pile's own budget and τ = 3.33, how many times does Wikipedia (6.38 GiB) get read?
The same arithmetic, runnable (Python, no packages, with its real output)
temperature shareUniMax shareThe Pile's hand weight

Raising τ moves budget from the web pile to repeated small piles; UniMax caps the repeats. Shares from The Pile's raw sizes (bytes stand in for tokens) derived; epochs at the right of each bar. The default budget, 1,254 GiB, is The Pile's own effective size, so the grey bars are its hand weights at the same budget.

2. How many times can a domain repeat?

Upweighting a scarce domain means reading it again, and the second reading teaches less than the first. Muennighoff et al. trained over 400 models from 10M to 9B parameters for up to 1,500 epochs on C4 and fitted a data-constrained Chinchilla law: replace the token count by an effective count D′ in which each repetition is worth a little less than the one before, decaying exponentially (Muennighoff et al. 2023, §3 and Appendix A).

D′ = UD + UD · RD* · (1 − e−RD/RD*)
UD
unique tokens
RD
repetitions, that is epochs − 1
RD*
fitted "half-life" constant: 15.387756 (Appendix A), so about 16 epochs
D′
effective tokens: the fresh data that would be worth as much

Fig. 2 · What each pass over the same data is worth

  1. One pass. One slab: U unique tokens read once are worth exactly U. In this figure a slab's height is what that pass is worth, in units of U, from the formula above.
  2. Two and four passes: nearly free. The second pass is worth 0.97 U, the fourth still 0.85 U, so four passes are worth 3.73 U, 93% of their face value derived.
  3. Eight and sixteen: two-thirds. Eight passes are worth 6.62 U (83%), sixteen 10.58 U (66%); the sixteenth slab is worth 0.39 U, each one thinner than the last.
  4. Thirty-two and sixty-four: the ceiling. 14.34 U (45%) and 16.13 U (25%); the sixty-fourth pass adds 0.017 U. The glass plate is the ceiling, 1 + RD* = 16.39 U, which no number of passes reaches.
  5. Where real recipes sit. Close on the first columns: The Pile capped at 3 passes, DeepSeekMath read its maths corpus about 2.3 times, OLMo 2's anneal and SmolLM2's code stop at about 4. Every one stays in the nearly free range.

Four epochs are worth 3.73 fresh epochs, 93% of face value; sixteen are worth 10.6, 66%; past about 40 epochs each extra one is worth under 8% of a fresh epoch (the slope of D′ is e−R/R*, 0.079 at R = 39) derived. The paper's measurement agrees: an 8.7B model trained four epochs over 44B unique tokens ended "with only 0.5% higher validation loss" than one epoch over 178B, and "differences in downstream performance are insignificant for up to around 4 epochs" (§6; downstream in §7, Figure 6) published.

Predict: you can double a 50B-token maths set's weight, which takes it from 2 to 4 epochs. How much more effective maths data do you get?

Where real recipes sit. The Pile capped at 3 epochs. OLMo 2's mid-training mixes repeat their small sources up to 4 times (section 5). DeepSeekMath's continued pretraining read its 120.2B-token maths corpus about 2.3 times (56% of 500B; the DeepSeekMath paper page derives it). SmolLM2 limited code to 10% in stage 1 "to ensure approximately 4 epochs over 11T tokens" (§4.2). The Token-budget planner computes epochs and D′ for any mix.

Correction to the old page and to a common reading of T5
The old root said a corpus can be repeated "a few dozen times at most". That came from T5's Table 9, where a truncated C4 repeated 64 times cost almost nothing; it was a 220M model trained 235 tokens, small enough not to memorise. At larger scale the measured limit is about 4 epochs nearly free and about 16 useful; the parent page's section 7 says the same.
What the repetition law does not cover

RD* was fitted on C4 and OSCAR web text with GPT-2-style models; high-quality maths or code may decay at a different rate, and the fit says nothing about memorisation or benchmark contamination, which grow with repetition. The paper also found, in its 84B-token experiments, that perplexity filtering helped while deduplication did not help downstream (§7), a result the Deduplication page discusses.

Four epochs are nearly free; past sixteen, almost nothing is added. Curve: D′/UD from the formula above with RD* = 15.387756 derived. Dashed: what the same tokens would be worth if fresh. The ceiling, 1 + RD* = 16.39 unique-data equivalents, is never exceeded however long you train.

3. Choosing weights with small proxy models

The only direct test of a mixture is to train the real model on it, and that is the run you cannot afford twice. Every method here trains proxy models (small, short runs) and transfers something from them: weights read off one proxy (DoReMi), or a fitted function from mixture to loss (mixing laws, RegMix). Each assumes the transfer holds; the evidence for that assumption is what to read.

3a. DoReMi: reweight towards the domains where a proxy lags a reference

Xie et al. (2023; arXiv 2305.10429, §2 and Algorithm 1):

  1. Reference model. Train a small model (280M in the paper) on reference weights, usually the natural shares. Its loss on a token estimates how learnable that token is at this scale.
  2. Proxy with Group DRO. Train a second small model from scratch. Every step: take a batch with an equal number of examples from each domain; compute the excess loss per token, clipped at 0; average it per domain (λi); multiply each domain weight by eη·λi, renormalise, and mix in a little uniform (smoothing c); update the proxy on the loss weighted by these domain weights. Group DRO (distributionally robust optimisation over groups, Sagawa et al. 2020) names this minimax game: the weights chase the worst domain, the model tries to fix it.
  3. Big model. Average the domain weights over all proxy steps and train the large model on that mixture.
αt = (1 − c) · normalise(αt−1 · eη·λt) + c/k,   result = (1/T) Σt αt
λt[i]
mean over domain i's tokens in the batch of max(proxy loss − reference loss, 0)
η, c
step size 1 and smoothing 10−3 "in all our experiments" (§2)
k
number of domains

Why the excess and not the plain loss: a domain that stays hard for the reference too (very high entropy, like noisy web text) has low excess, and so does a domain the proxy has already learned (low entropy, like boilerplate code); weight flows to domains that are learnable but not yet learned.

The update, run on real data. This page ran Algorithm 1 exactly on the five running-example domains: a 0.79M-parameter reference trained 4,000 steps on the pools' natural shares, then the Group DRO proxy for 4,000 steps against it, on the Apple M1 Pro GPU measured, one seed.

Predict: which domain does DoReMi move weight away from on these five?

The weights swing from domain to domain; the running average, DoReMi's answer, converges slowly. Thin lines: α at each logged step; dashed: the running average; the strip below: excess loss per domain. It opens on the whole run; drag the scrubber or press play to replay it step by step.

Early on every domain has an excess of about 2.3 to 2.7 nats (an untrained proxy against a trained reference), so η = 1 multiplies weights by up to e2.7 per step and they swing to one domain at a time: a single step's α reached 0.998 on code and 0.994 on maths, and code or maths held the largest weight at 93% of the logged steps. The running average was still moving when the run stopped: maths 0.59 at step 200, 0.47 at 2,000, 0.385 at the end. In the last 10% of steps the excess was 0.58 to 0.62 nats on all five domains: the minimax game equalised the excess, as it promises. The before and after:

The experiment's setup, the proxy's own loss, and what was not run (pools, model, run, the dropped sweep)
  • Script: src/scripts/proxy_mix.py (one file: prep, train, sweep, doremi; the parent's Mixing lab can reuse it unchanged).
  • Domains and pools: web (DCLM-baseline), Wikipedia, code (Stack-v2-Edu from the Comma v0.1 training set), maths (FineMath 4+), papers (peS2o), the same sources and revisions as the topic's samples, streamed to about 100M characters each and tokenized with GPT-2's tokenizer: training tokens, 5% of documents held out. Code tokenizes worst (most tokens per character), so it has the biggest pool in tokens.
  • Models: a pre-norm GPT, 4 layers, width 128, 4 heads, context 256, tied embeddings: 0.79M non-embedding parameters, the size class RegMix used.
  • Run: Algorithm 1 exactly (η = 1, c = 10−3, per-token excess clipped at 0, uniform batches of 6 sequences per domain). Reference: 4,000 steps of 30 × 256 tokens on the pools' natural shares (30.7M tokens). Proxy: 4,000 steps with Group DRO against it. Apple M1 Pro GPU (MPS), .

The proxy itself ended with a held-out loss 0.35 to 0.39 nats worse than the reference on every domain, including code and maths, which it weighted most. A likely reason (not tested here): when α concentrates on one domain, each step's gradient comes mostly from 6 of the 30 sequences, a noisier, effectively smaller batch. DoReMi never uses the proxy as a model, only its weights. With a 280M reference trained 200k steps, as in the paper, the balance can differ; this is one small run, one seed, 4,000 steps.

Not run here, and why
A RegMix-style sweep (48 tiny proxies on random mixtures of these five domains plus anchors) and a rank check at a larger size were designed (proxy_mix.py sweep) and dropped on 2026-10-15 as hours of GPU time that would re-measure what is published: RegMix's 1M-to-1B rank correlation of 97.12 (Table 2; 98.76 for the exponential law refitted in 3c), and DoReMi's own transfer from 280M to 8B (+6.5 points) and at matched sizes (Figure 5). For the same reason no main model was trained on the averaged weights, so DoReMi's actual claim, that such a model beats the natural-share reference, is not run here. The CPU smoke test that came first (60 steps; about 6,400 tokens per second on 4 CPU threads against about 14,700 on the GPU) is recorded in data/smoke.json.
The same update on toy losses, with a before/after main model (illustrative)

One run of the update on five made-up loss curves, step by step: the proxy's loss against the reference's, the clipped excess, the multiplicative update, the renormalised and smoothed weights, and their running average. Then the same "main model" trained on the reference weights and on DoReMi's, same token budget.

What is real here and what is not
The update rule is the paper's, ported line for line (η = 1, c = 10−3, average of αt over the run). The losses are illustrative: each domain's loss is a made-up power law Ei + Ai·(ni + 1)−ai in the tokens it has effectively seen, with an optional share of web tokens counting for every domain (web is diverse, so it transfers), plus seeded noise. The "web" curve has a high floor E (hard for everyone), "code" a low floor and a steep curve (learned fast), maths and papers sit in between. The same code runs in src/recompute.py, and the page check confirms the two agree.
Reference weights
Transfer from web to other domains
trained on the reference weightstrained on DoReMi's weights (colour per domain)

In this toy (natural-like reference, transfer on) web loses most weight, from 0.40 to about 0.29; code (easy, learned fast) also loses, from 0.15 to about 0.11; wiki, maths and papers gain. That is the paper's own hypothesis about which domains can be downweighted (the lowest- and highest-entropy ones), reproduced by construction of the toy's curves, not as evidence. With a uniform reference and transfer off, identical curve shapes put the average close to the reference. Three lessons: DoReMi's answer is an average over a noisy trajectory (the README: "we expect the domain weights during training to be somewhat noisy and the averaged domain weights to be mostly smooth"); it depends on the reference (iterated DoReMi re-trains the reference on the last answer until weights change by less than 10−3, which took 3 rounds on the GLaM dataset); and it optimises worst-case excess loss, not average loss, so it can make a domain worse in exchange for others, as the before/after bars show for web and code.

Reference weights (natural shares of the pools) against DoReMi's averaged weights, web 0.026, code 0.379, maths 0.385, and held-out losses measured.

What the paper found published: on The Pile, weights from a 280M proxy put 60.6% on Pile-CC (from 11.2%) and cut ArXiv, PubMed Central and StackExchange to under 2% each (Table 1). An 8B model trained on them gained 6.5 points of average one-shot accuracy on five generative tasks (TriviaQA, Natural Questions, WebQuestions, SQuAD v2, LAMBADA) and reached the baseline's final accuracy at 75k of 200k steps, "2.6x faster" (§3.2). Finding the weights cost 8% of the 8B run's FLOPs (§3). With proxy and main model the same size (280M to 1B) the gain was about 2 points and 4 times faster on average (Figure 5); a 1B proxy did worse than a 280M one for the 8B model, which the authors attribute to the Group DRO optimiser (Figure 6).

The "Pile baseline" is not The Pile's mix
DoReMi's baseline weights, which RegMix also calls "Human", give Wikipedia 9.19% and Pile-CC 11.21%; The Pile's own Table 1 gives 1.53% and 18.11%. The paper says only that they are "computed from the default Pile dataset". The repository's README explains: "nopack counts the number of examples in each domain after padding each document to the context window length", so a short Wikipedia article counts as much as a long PubMed paper. The rank correlation between the two weightings over 22 domains is 0.90 derived; the paper's 256k-vocabulary baseline is not reproduced exactly by either 50k-vocabulary config in the repo (Wikipedia 8.94% nopack, 6.49% pack). So "DoReMi beats The Pile's weights" means it beats a document-count weighting, not the epochs The Pile's authors chose. The repo's own 120M round-1 run gives Pile-CC 13.8% instead of the paper's 60.6%: the weights depend strongly on proxy size, tokenizer and reference.
The official code, and two details the paper does not state

sangmichaelxie/doremi at commit 7cde52d, doremi/trainer.py, lines 252 to 259, the update in log space:

curr_domain_scores = torch.clip(scores[domain_mask][perdomain_scores_mask], min=0).mean() # 252: clip, then mean per domain ... log_new_train_domain_weights = torch.log(train_domain_weights) + self.args.reweight_eta * self.model.perdomain_scores # 257 log_new_train_domain_weights = log_new_train_domain_weights - torch.logsumexp(log_new_train_domain_weights, dim=0) # 258 train_domain_weights = (1-self.args.reweight_eps) * torch.exp(log_new_train_domain_weights) + self.args.reweight_eps / len(log_new_train_domain_weights) # 259

A domain absent from a batch keeps its previous score (line 254). The README calls --reweight_eps the "update rate" with default 1, while the code uses reweight_eta as the step size and reweight_eps as the smoothing; the run script passes eta 1.0 and eps 1e-3 (scripts/runs/run_pile_doremi120M.sh, lines 70 to 71), matching the paper.

The Pile's own Table 1 (bytes)DoReMi's "baseline"DoReMi 280M (paper)DoReMi 120M, repo round 1

Three published "Pile" weightings disagree, and DoReMi's weights depend on the proxy. DoReMi Table 1 (arXiv 2305.10429v4) and the repository's configs/*.json at 7cde52d published; The Pile Table 1 published.

3b. Data Mixing Laws: fit loss as a function of the weights

Ye et al. (2024; arXiv 2403.16952) trained small models on many mixtures and found that, at fixed model size and tokens, the validation loss on each domain i follows

Li(r) = ci + ki · exp( Σj tij rj )
rj
weight of training domain j
ci, ki, tij
fitted constants; tij < 0 means training on j lowers loss on i

They chose this form over three alternatives by fit quality (§3.2), then nested it with scaling laws in training steps and model size: fit the mixing law on small, short runs, extrapolate each run's loss along its own scaling curve, and predict a large model's loss for any mixture. Optimising RedPajama's mixture this way for a 1B model trained on 100B tokens reached the performance of the default mixture trained 48% longer (abstract) published.

3c. RegMix: many tiny runs and a regression

Liu et al. (2024; arXiv 2407.01492) skip the functional form and treat mixture search as ordinary regression:

Fig. 3 · RegMix on its released runs

  1. Sample 512 mixtures. Sample 512 mixtures over The Pile's 17 available domains from a Dirichlet distribution whose concentration is the natural token distribution times a random scale from 0.1 to 5.0, so both extreme and near-uniform mixtures appear and no tiny domain gets an impossible share (§3.1). Four of the released training mixtures, each as 17 bars on a plinth (Pile-CC in blue): runs 1, 3, 6 and 8.
  2. Train a tiny model on each. Train a 1M-parameter model (non-embedding) on 1B tokens of each. The columns behind are those four runs' Pile-CC validation losses: 5.17, 5.51, 5.92 and 5.32.
  3. Fit a regression. Fit a regression from the 17 weights to a target, the Pile-CC validation loss: linear, or LightGBM (gradient-boosted trees). The plate in front is the exponential law fitted on all 512 runs (3b's form, refitted here); each bar is how much more a domain's weight lowers the loss than GitHub's, the domain that helps it least: Pile-CC 8.32, Enron Emails 5.01, PhilPapers 3.58 derived.
  4. Score 100,000 mixtures, keep the best. Score 100,000 random mixtures with the regression, average the best 128, and train the big model on that mixture. The mixture RegMix trained at 1B (its released config): Pile-CC 87.0%, Ubuntu IRC 6.4%, PubMed Abstracts 2.4%, Wikipedia 1.6%, HackerNews 1.2%, the other twelve domains 1.4% together.
  5. The big run. At 1B parameters and 25B tokens it scored 47.3 average over 14 tasks, against 45.1 for "Human", 46.8 for DoReMi's weights and 46.8 for Pile-CC alone (Table 4): a small lead, from a mixture that is mostly web text.

The bet is rank invariance: the order of mixtures by loss is the same at 1M and at 1B. Table 2 tests it on unseen mixtures: Spearman ρ between predicted and true loss of 98.45 (1M), 98.64 (60M) and 97.12 (1B on 25B tokens) for LightGBM, 90.08, 89.26 and 88.01 for linear published. RegMix released every run (512 training runs plus 256 unseen at 1M, 256 at 60M and 64 at 1B), so the bet can be checked here: fit a mixing law to the 1M runs in your browser and test it on the 1B runs.

The refit against Table 2, from the released runs

Refit with scripts/regmix_fit.py on the released CSVs (sail-sg/regmix at dd9d1c3, data/), same 512 training runs and the notebook's LightGBM settings; LightGBM , CPU, seconds measured. Linear and LightGBM land within 0.7 points of Table 2 (exact numbers depend on the solver and the early-stopping split). The paper's 1M MSE (0.13 linear, 0.04 LightGBM) does not reproduce: the refit gives 0.024 and 0.003, so the paper's MSE is on some other scale it does not state. The Data Mixing Laws form, which RegMix did not try, ranks the 1B runs better than either (ρ 98.76) with 19 parameters.

At 1B parameters and 25B tokens, the RegMix mixture scored 47.3 average over 14 tasks against 45.1 for "Human" (the document-count weights above) and 46.8 for DoReMi's weights, using 3.5e18 FLOPs to find its mixture against DoReMi's 3.7e19, about 10% published (Table 4). The same table has a column worth more attention than it gets: training on Pile-CC alone also scored 46.8, tying DoReMi with zero search cost, and was best on 5 of 14 tasks. RegMix's own mixture is 87% Pile-CC. Its Figure 5 reads the same way: across 64 1B runs, low web-text (Pile-CC) loss correlated with downstream scores more than low Wikipedia loss.

Predict: a linear regression of loss on mixture weights is used to pick the best mixture directly (its minimum). Where does that minimum land?
What each fit recommends, and which domains move the target

Each fitted model scores 20,000 random mixtures drawn as in RegMix's notebook (Dirichlet with the natural token shares as concentration) and averages the best 128; compare with the mixtures actually trained at 1B in RegMix's Table 4. The controls are the fitter's above.

For the GitHub validation loss as target, the exponential law says GitHub itself matters most, by far (exponent −58.5 relative to the domain that helps least, against −8.6 for the next): code is learned from code. Switch the model to linear and the top coefficient becomes Enron Emails, a domain with 0.2% of the tokens: few runs gave it any weight, so its coefficient is poorly determined, and with weights that sum to 1 a linear coefficient is only meaningful relative to the others. Read fitted coefficients as a fit, not as causes. For Pile-CC (RegMix's target) the exponential law also puts Pile-CC first, which is why the recommended mixture is mostly web text.

Test on

A law fitted on 1M-parameter runs ranks 1B runs almost perfectly. Each dot is one unseen mixture: predicted loss from the 1M fit against true loss at the test size; a rising cloud is what transfers. Try: drag the training runs from 512 to 32; the linear fit loses rank quality fast, the exponential law much less. RegMix's runs are published; fits computed here, in the browser.

3d. The check: do these methods beat simple baselines?

Aioli (Chen, Hu et al. 2024; arXiv 2411.05735) re-ran the methods side by side on 160M models over six subsets of SlimPajama against stratified sampling (equal weight per group): "no existing method consistently outperforms a simple stratified sampling baseline in terms of average test perplexity".

Most methods lose to equal weights in some settings; DoReMi loses by up to 6.9 perplexity. Aioli Table 2: difference in average test perplexity from stratified (negative is better) published, third party for the methods it re-runs. GS: grid search; DML: Data Mixing Laws; A: ArXiv, B: Books, GH: GitHub, SE: StackExchange, W: Wikipedia, CC: CommonCrawl. Methods could use up to 10 extra runs. Aioli itself estimates the mixing law's parameters online during the run and adjusts the weights; it beat stratified on 6 of 6, by 0.27 perplexity on average (abstract). All at 160M parameters and 5K to 40K steps: small-scale evidence.

Aioli's diagnosis: every method implicitly assumes a mixing law (a relationship between proportions and loss) and fits its parameters badly; DoReMi's two large failures (GitHub/C4 +5.3, CommonCrawl/GitHub/Wikipedia +6.9) are where that assumption broke.

Other methods, each with its authors' evidence (AutoScale, ODM, Skill-It, DoGE, CLIMB)

Published, not re-checked here published:

  • AutoScale (arXiv 2407.20177): "data mixtures that perform well at smaller scales may not retain their advantage at larger scales"; predicts how the optimal composition shifts with budget; 28% faster perplexity reduction than baselines on GPT-2 Large.
  • ODM, online data mixing (Albalak et al. 2023): a multi-armed bandit (EXP3) picks domains during training with loss as the reward; reached the next best method's final perplexity with 19% fewer iterations.
  • Skill-It (Chen et al. 2023): skills learned in an order; samples prerequisite skills first.
  • DoGE (Fan et al. 2023): bi-level optimisation of weights by gradient alignment with a target; beat baselines on SlimPajama in its own tests, but beat stratified in only 1 of 6 Aioli settings.
  • CLIMB (NVIDIA, arXiv 2504.13161): embeds and clusters a crawl into 20 groups instead of trusting source labels, then searches mixtures with proxies and a predictor; a 1B model on 400B tokens of the result beat Llama-3.2-1B by 2.0%, and the released ClimbMix is 400B tokens.

Named in the old page and not verified here, so not described: MDE, UtiliMax/MEDU, RegMix-D, "Data Mixing Agent". They may exist; this page found no primary source it could check by its date.

4. Offline or online, and how a loader hits the weights

Offline mixing fixes the weights before training and writes (or indexes) one shuffled stream. The Pile did it literally: it drew documents at random, "weighted by the number of documents in each dataset times the number of epochs desired", and interleaved the output into 30 files (appendix on construction). Reproducible and simple; the weights cannot change. Online mixing keeps one stream per domain and lets the training loop choose the domain of every sample from the current weights. Stages need it (the weights change at a step boundary), and so do the methods that adapt during the run: DoReMi's proxy, ODM, Aioli. The cost is engineering: per-domain shards, a sampler whose state is saved with each checkpoint so a restart resumes the same sequence, and a log of the weights actually used (Storage and loading covers shards, shuffling and resumption).

Hitting the weights exactly. Sampling a domain at random for each sample matches the weights only on average; over a short window the achieved shares wander. Megatron-LM's blended dataset is deterministic: for sample n it computes, for every dataset, the error wi·n − (samples taken from i so far), and takes the next sample from the dataset with the largest error.

Fig. 4 · Random draws drift from the target; the blend is never more than one sample off

  1. Offline: mix once, write one stream. Three pools, web, code and maths, are drawn into a single shuffled stream before training, as The Pile wrote its 30 files. Simple and reproducible; the weights inside it can no longer change.
  2. Online: one stream per domain, chosen per sample. The pools stay separate and the loader picks the domain of every sample from the current weights, here 0.6, 0.3 and 0.1 illustrative. A stage boundary or an adaptive method can change them mid-run.
  3. Random draws, samples 1 to 20. Each sample's domain is drawn at random with those probabilities (a fixed seed). After 20 samples the counts are web 14, code 6, maths 0, against targets of 12, 6 and 2: maths has not appeared at all.
  4. Random draws, samples 21 to 60. After 60: 39, 19 and 2 against 36, 18 and 6. The largest gap between a domain's count and its target reached 4.8 samples during the run; the weights hold only on average.
  5. Megatron's blend, samples 1 to 20. The same 60 slots, now filled by the rule in Megatron-LM's code, ported line for line: each sample goes to the domain whose count lags wi·n most. After 20: 12, 6 and 2, exactly the targets.
  6. The blend, samples 21 to 60. After 60: 36, 18 and 6. The gap never exceeded 0.8 of a sample, and the order is fully determined by the weights, so a restart reproduces it.
The blend rule in Megatron-LM's code

NVIDIA/Megatron-LM at 80781ab, megatron/core/datasets/helpers.cpp, build_blending_indices, lines 104 to 128:

for (int64_t sample_idx = 0; sample_idx < size; ++sample_idx) { // 104 auto sample_idx_double = std::max(static_cast<double>(sample_idx), 1.0); // 108 int64_t max_error_index = 0; double max_error = weights_ptr[0] * sample_idx_double - static_cast<double>(current_samples[0]); for (int64_t dataset_idx = 1; dataset_idx < num_datasets; ++dataset_idx) { // 112 double error = weights_ptr[dataset_idx] * sample_idx_double - static_cast<double>(current_samples[dataset_idx]); if (error > max_error) { max_error = error; max_error_index = dataset_idx; } } dataset_index_ptr[sample_idx] = static_cast<int16_t>(max_error_index); // 124 dataset_sample_index_ptr[sample_idx] = current_samples[max_error_index]; current_samples[max_error_index] += 1; // 128 }

Hugging Face datasets offers the random version as interleave_datasets(..., probabilities=[...], seed=..., stopping_strategy=...): "first_exhausted" stops when the smallest stream ends (undersampling), "all_exhausted" restarts finished streams until every one has been seen once (oversampling, so small domains repeat). Which one you pick silently changes the epochs of the small domains.

5. Curricula, stages and mid-training

A curriculum is an order over the data. In current pretraining it is coarse: a few stages, each a block of steps with its own mixture, ending in a decay stage (mid-training, the anneal) where the learning rate falls to zero while the mix shifts to the best data: maths, code, instruction-like and question-answer text, often synthetic. "Annealing" has three meanings in this literature (the learning-rate decay, this final data stage, and a cheap experiment that anneals a checkpoint on a candidate dataset); Optimisers and learning-rate schedulers separates them. The Pretraining page owns the training side (its section 4 animates GPT-3, OLMo 2 and SmolLM3 stages on their token axes; its section 5 has OLMo 2's Table 11 split of the anneal's gain into learning-rate decay and data, and the anneal toy). This section is the data side: what goes into each stage.

English web falls from 70% to 50% while code goes from 12.5% to 23% and maths from 2.7% to 12.5%, and the decay stage adds instruction-style maths (OpenMathInstruct-2, OpenMathReasoning) and code reasoning sets. SmolLM2 (Allal et al. 2025, §4 and Table 3) has the same shape, with scores per stage published:

Predict: in SmolLM2's Table 3, which category gains most in the decay stage (stage 3 to stage 4)?

SmolLM3's decay stage halves the share of English web and quadruples maths. huggingface/smollm at 438be18, text/pretraining/smollm3/stage1_8T.yaml, stage2_8T_9T.yaml, stage3_9T_11T.yaml: 41, 46 and 56 sources with their dataset_weights, grouped by this page into English web (FineWeb-Edu, DCLM), multilingual (FineWeb-2 languages), code (Stack-Edu, pull requests, notebooks, issues, Kaggle), maths (FineMath, InfiWebMath, MegaMath, OpenMath data) and other (papers, Wikipedia, StackExchange, Cosmopedia, reasoning sets) derived. Token boundaries from steps × 2,359,296 tokens per step (data parallel 192 × micro-batch 3 × 4,096) derived: the decay stage starts at step 4,198,001, the same step as lr_decay_starting_step. The decay stage's raw weights sum to 1.0056; loaders normalise.

SmolLM2 1.7B on 11T tokens, warmup-stable-decay schedule with the decay over the last 10%. Stage mixes from the text of §4.2 to §4.5; stage 3's exact shares are given only in a figure, so they are not transcribed. Stage-4 maths 14% is derived from the stated 58% web, 24% code and 4% Cosmopedia.

OLMo 2: the anneal repeats its small sources

OLMo 2's pretraining mix is 3.90T tokens, 95% DCLM-Baseline web text (Table 4). Its mid-training "Dolmino" mixes come in 50B, 100B and 300B sizes; Table 13 gives each source's share and how much of the source pool it uses, where "400 indicates a 4x repeat" published. The anneal is half filtered web (DCLM's fastText top 7% that FineWeb-Edu scores at least 2), and the small, high-value sources (FLAN instructions, StackExchange Q&A, Wikipedia, maths) are pushed to 2 to 4 epochs as the anneal grows: StackExchange, Wikipedia and the maths mix reach "400" source percent in the 300B mix, within the 4-epoch range section 2 found nearly free.

OLMo 2, Tables 4 and 13, as transcribed on the OLMo 2 paper page. "Implied" = mix % × budget / pool, which reproduces the source % to within rounding derived. The 7B shipped with three 50B anneals averaged; the 13B and 32B with three 100B and one 300B (paper §4).

Why stages work is a hypothesis, not a proven mechanism: scarce high-quality tokens are not diluted across trillions of others, and what the model sees while the learning rate is small is what it keeps. Two measured facts bound it: OLMo 2's ablation (Pretraining, section 5) shows most of the anneal's knowledge gain is the learning-rate decay while all of its maths gain is the data, and Llama 3's shows the data effect shrinking at 405B. The Token-budget planner takes domain pools, a budget and stages, computes tokens, epochs and effective data per domain, and animates the same budget with and without a decay stage.

Other published stage recipes (Llama 3, MiniCPM, DeepSeekMath, Olmo 3)
  • Llama 3 (arXiv 2407.21783, §3.1.3 and §3.4.3): final mix roughly 50% general knowledge, 25% maths and reasoning, 17% code, 8% multilingual; annealing over the last 40M tokens to zero learning rate at 128K context while upsampling very high quality sources; annealing on GSM8K and MATH training data lifted the 8B's validation scores by 24.0% and 6.4% with "negligible" gains at 405B. A dataset's value is judged by annealing a half-trained 8B for 40B tokens with 30% of the candidate data. The Llama 3 paper page has the details.
  • MiniCPM (arXiv 2404.06395, §4 and §6): introduced the warmup-stable-decay schedule and mixed high-quality and SFT data into the decay phase only; the 2.4B annealed with SFT data mixed in beat the same model with SFT alone after the same SFT.
  • DeepSeekMath: at 1.3B, 400B tokens of code then 150B of maths beat 400B general then 150B maths on GSM8K and MATH, one run per setting; the paper page has the numbers and the caveats. It is one of the few published curriculum ablations at the stage level.
  • Olmo 3 (Ai2, 2025): a 100B-token "Dolmino Mix" stage 2 of mostly synthetic maths, code, question-answer and thinking data after the 5.93T-token Dolma 3 Mix (dataset cards; the Ai2 OLMo section of Other notable providers).

6. Continued pretraining: the same split, made later

Continued pretraining (CPT, also "continual pretraining") resumes next-token training of an existing base model on new data: a domain (finance, medicine, law, code, maths), a new language, fresher data, or longer documents. It keeps the objective and trains every parameter; what changes is the data, and the data decision is the domain share: how much of the stream is the new domain, the rest being general data replayed so the model does not forget.

Pretraining

From random weights, on trillions of tokens of broad text (Pretraining).

Mid-training, the anneal

The base-model builder's last stage: same objective, learning rate decaying, the best data up-weighted (OLMo 2: 50B tokens; section 5 here, and Pretraining, section 5).

Continued pretraining

Someone else's finished base, billions to hundreds of billions of new tokens, all parameters, same objective (DeepSeekMath: 500B tokens on a 7B base, paper page).

Fine-tuning (SFT, LoRA)

Demonstrations or preference pairs, millions of tokens; teaches format and behaviour more than knowledge (PEFT, Alignment).

Mid-training and CPT are the same machinery; the difference is who runs it. The base-model builder anneals its own run on curated data; an adapter takes a released checkpoint (usually without its optimizer state or its data) and pushes it towards a domain. Long-context extension is CPT too: the standard 128K recipes are continued pretraining on upsampled long documents with a rescaled rotary base (Positional Encodings). The training topic compares all the stages on one grid.

When it is worth it. CPT is for a large knowledge gap: a body of text the base model has barely seen, measured in billions of tokens. Fine-tuning, including LoRA, does not inject bulk knowledge well: Biderman et al. found LoRA "learns less and forgets less" than full training when continuing to pretrain on code and maths (PEFT, Against full fine-tuning). When the gap is a few documents that change often, retrieval or a fine-tune is cheaper and easier to keep current; skip CPT. A domain-specific financial-services LLM Khalid worked on followed the usual shape: select a base model by benchmark screening; continue pretraining on a mix of domain and general text; post-train; evaluate on three axes (domain, general, safety) with a private in-house benchmark. Every step of that shape is below.

English loss (general, old)German loss (domain, new)the other runs, for comparisonretrained from scratch on both

Without replay English collapses at once; a quarter of English in each batch keeps most of it. Loss in bits per character on 128 held-out passages of each language; lines are the mean of seeds 1 to 3 and the band their range. Pretraining: 5,000 steps of 32 × 96 characters, cosine from 3e-3 to 3e-4. Each CPT run: 1,500 steps from that checkpoint with a fresh AdamW state, warmup over 1% of steps, cosine to 10% of its peak. "Retrained from scratch on both" is the same model trained 6,500 steps on the union with the same German share. All nine runs per seed are in the toy block of 6b.

6a. Forgetting, watched

Training on a shifted distribution degrades what the model knew (catastrophic forgetting, a name from the 1980s): the loss on the old data rises while the loss on the new data falls. The animation is a real experiment run for this page: a small character-level model (815,616 parameters) pretrained on six English books, then continued on six German ones (the strong shift Ibrahim et al. studied at 405M, Pile to German Common Crawl). Same base, same German data, three seeds; the only difference between the runs is whether a quarter of each batch is English replayed from pretraining measured.

Predict: with no replay, when does the English loss rise most?

Fig. 5 · The toy's English loss while it learns German, mean of three seeds

  1. The base model.
  2. After 50 CPT steps.
  3. After 100.
  4. After 200.
  5. After 400.
  6. After 700.
  7. After 1,000.
  8. End of the run.
  9. The three runs side by side.
  • Forgetting is fast. Without replay, English loss jumps within the first 50 steps (? bits per character, from ?) and keeps rising while German improves. By the end, asked to continue the English words "it was a", the no-replay model carries on in German. Ibrahim et al.'s 405M model lost the same way at scale: Pile loss went from 2.17 to 3.56 after 200B German tokens, a 64% rise derived (Table 2).
  • A little replay removes most of it, at almost no cost to the domain. In the toy, 25% replay removes ?% of the English loss rise, for ? bits of German loss. In Ibrahim's strong shift, 1% replay removed 52% of the Pile loss rise, 5% removed 71% and 25% removed 89%, while German loss moved from 1.11 to 1.12, 1.12 and 1.16 derived: (3.56 − replay loss) / (3.56 − 2.17).
  • Replay plus re-warming matches retraining. The paper's headline: with re-warming, re-decaying and replay, the continued model reaches the average loss of a model retrained on all the data, for "substantially less compute" (Figure 1): 405M on German at 25% replay scores 2.33 (Pile) and 1.16 (German) against the union model's 2.26 and 1.25, average 1.75 both, after 200B tokens of training instead of 500B, 40% derived, given that the base already exists.

6b. The two levers: replay and the re-warmed peak

Replay. Measured ranges:

  • Even 1 to 5% helps a lot. Meditron kept 1% general text, Llemma 2% (plus 3% code), SaulLM about 2%. Ibrahim et al.'s lowest setting, 1%, "significantly reduces forgetting" on both shifts, and 0.5% already removed 63% of the Pile loss rise on the weak shift derived (Table 2). The D-CPT Law runs show the same at 1.8B: training on chemistry alone raised general loss 21.2%; with 6 to 10% general data the rise was 1.6 to 4.4% derived from Table 5.
  • 10 to 30% when the shift is strong or general ability is precious. Ibrahim et al. chose 25% for English to German and 5% for the weak shift; DeepSeek-Coder-V2 kept 30% natural language over 6T tokens of code CPT (as Ibrahim et al. note in their §2; row in CPT recipes compared).
  • Domain-heavy, half and half, when domain depth is the goal. Dialpad's DACP mixed 25B tokens of business-call transcripts with 25B tokens sampled from FineWeb-Edu, 1:1, for Llama 3.1 8B and Mistral 7B v0.3 (DACP, 2025).
  • Too much replay costs adaptation. At 50%, Ibrahim's German loss rose from 1.11 to 1.22, "relatively significantly worse".

Choose replay data close to the original pretraining distribution: the closer it is, the more of the old ability it protects. Ibrahim et al. replayed the Pile itself, the base model's own data; open-weight labs rarely release their mix, so FineWeb-Edu and DCLM-baseline are the usual stand-ins, and their own domain weights (section 1) become part of your CPT mix.

Fig. 6 · The two levers on the toy: nine CPT runs, mean of three seeds

  1. Nine runs from one base. The English base (English 1.85 bits per character; German 5.71, a language it has never seen) is continued on German nine ways: the peak learning rate at 1×, 0.33× or 0.1× of pretraining's (rows, back to front), crossed with 0, 5 or 25% English replay (columns) measured.
  2. No replay, full peak. English loss ends 3.12 bits per character above the base: the tall corner column, the toy's version of catastrophic forgetting.
  3. Lower the peak, still no replay. 2.66 at 0.33× and 2.17 at 0.1×: a tenth of the peak removes only 30% of the rise, and costs German, as step 5 shows.
  4. Add replay. English flows back into the stream: 5% replay cuts the rise to 0.69, 0.59 and 0.65 across the three peaks, 25% to 0.22, 0.18 and 0.20, removing 78 to 94% of it.
  5. The price in German. The English columns fade and the orange columns beside them are German loss above the best German run (2.005, no replay at the full peak), on the same scale: 25% replay at the full peak costs 0.05; the 0.1× peak without replay costs 0.19.
  6. The best corner. 25% replay at the full peak removes 92.8% of the rise for 0.05 bits of German: English 2.07 and German 2.06, against 1.86 and 2.15 for the same model retrained from scratch on both languages, from 1,500 steps on top of an existing base instead of 6,500 from scratch.

The learning-rate peak. A released base has usually finished with its learning rate decayed near a small minimum. Continuing at that minimum adapts too slowly; re-warming to a high peak adapts well but makes the old-data loss spike first. Ibrahim et al.'s rule of thumb: re-warm to the order of the original peak and re-decay to the order of the original minimum; "decreasing the schedule's maximum learning rate can help reduce forgetting, whereas increasing it can improve adaptation" (§2). Gupta et al. found the same on Pythia 410M continued on SlimPajama, and that the length of the warmup barely matters (Gupta et al. 2023). Use both levers together: replay and a re-warmed, re-decayed schedule.

Tap or hover a point.

Replay buys back old-data loss almost for free; the learning-rate peak only slides along the trade. Follow the replay line from 0% to 50%: the Pile loss falls steeply while German barely moves until 25%.

Corrections

The old page said re-warming "drives most forgetting". In Ibrahim et al.'s own numbers it does not, under a real shift: the 405M model trained on German at a constant learning rate equal to the old minimum, never re-warmed, still raised its Pile loss from 2.17 to 3.22; re-warming to the old peak raised it to 3.56. So re-warming added 0.34 of the 1.39 rise, 24%, and the data shift the other 76% derived (Table 12; on the weak shift, 0.02 of 0.27, 7%). What is true is narrower: re-warming alone raises the loss even with no shift at all ("every model that re-increases its learning rate ... sees an increase in loss", §7.1, on Pile continued with Pile). The toy separates the two the same way: compare "No replay, peak 0.1×" with "No replay" in 6a.

The old page also gave "an order of magnitude lower peak than pretraining" as a common heuristic. It is common practice, but not what the two controlled studies tested. eBay's e-Llama paper names two paradigms in the literature, "use the same LR_max as for the original pretraining ... or ... a smaller value, typically around 10% of the original", and chose 10% after an ablation (e-Llama, §4). Ibrahim et al. and Gupta et al. tried 0.5×, 1× and 2× the original peak; the closest thing to 0.1× in their tables is the never-re-warmed constant run at the old minimum (least forgetting, worst adaptation: German 1.21 against 1.11). Disclosed recipes span 1× (Code Llama, Meditron) to about 1/150 (DACP), with Llemma and Swallow at one third and ChipNeMo at 1/60 (CPT recipes compared). ChipNeMo's own ablation shows the risk at the top: at 3e-4 instead of 5e-6, MMLU fell from 44.6 to 26.6 (ChipNeMo). A sensible place to start pilots, not a law.

The replay toy: nine runs, three seeds each (setup, the grid, curves and samples per seed)

Ibrahim et al. ran each configuration once, at 405M and 10B parameters. This page ran the same two levers on a model small enough to train on a laptop, three times each, so the effects can be told from noise: when an English base model is continued on German, how much English does it lose, and how do replay and the re-warmed peak change that? Read down the first column (no replay): lowering the peak cuts the English rise but costs German. Read along a row: 5% replay already removes most of the rise at any peak.

Toy defaults reproduce Ibrahim et al.'s qualitative result independently (a different model, data and scale); the toy's numbers are not comparable to the paper's, which are in nats per token. The paper ran each configuration once ("we did not run our experiments over multiple seeds", §8); the toy ran three, and its bands are narrow next to the effects.

Each cell: final English loss rise over the base (bits per character, lower is better) and German loss after CPT, means of three seeds. Colour: the English rise. Tap a cell.

English lossGerman lossretrained from scratch on both (final)no replay at the same peak

Code: src/cpt/toy/train.py (PyTorch, CPU, two threads; about 30 minutes per seed; character-level GPT, 5,000 English pretraining steps, then nine 1,500-step CPT runs on German, peak 1, 0.33 or 0.1 × crossed with replay 0, 5 or 25%, plus a from-scratch run on the union; seeds 1 to 3). Raw runs in src/cpt/toy/runs/, packed by src/cpt/recompute_cpt.py; the books are Project Gutenberg texts listed in src/README.md. Resetting AdamW at the start of CPT copies what an adapter of a released checkpoint must do; Ibrahim et al. found keeping or dropping optimizer states ends at similar loss after 40B tokens (Figure 13). Toy scale throughout: a character-level model on twelve books is not a 405M model on the Pile, and German here shares English's alphabet; the direction of each effect is what transfers, not its size.

6c. Schedules that resume without re-warming

Re-warming is needed because a cosine schedule ends low. Ibrahim et al. propose "infinite" schedules instead: warm up, cool down once to a constant learning rate, stay constant across every later dataset, and decay quickly only when a model is to be released (§7.2). The checkpoint to continue from is the one before the final decay, so no re-warm is needed. This is the warmup-stable-decay (WSD) family; the WSM paper page replaces the final decay with checkpoint merging. DeepSeek did this for DeepSeek-Coder-V2: it continued DeepSeek-V2 from a checkpoint before the learning-rate decay (as Ibrahim et al. describe it, §2).

The evidence is thinner than for replay: infinite schedules matched cosine at 405M on 300B tokens of SlimPajama from scratch, and across three 100B splits of the same data showed "negligible forgetting across dataset boundaries" (Figure 10), but the authors list as limitations that these runs had no distribution shift and only one size (§8).

An infinite schedule leaves a constant-rate checkpoint to continue from, so there is nothing to re-warm. Shapes from Ibrahim et al.'s Equations 1 to 4 with their 405M settings (Table 14): peak 3e-4, minimum 3e-5, constant 1.65e-4 for the infinite schedule, warmup 1%. Two datasets of equal size on the same token axis; the cooldown and anneal lengths are illustrative.

6d. Choosing the ratio: the CMR and D-CPT laws

Grid-searching the domain share at full scale is expensive. Two 2024 papers fit scaling laws on small pilot runs and predict it instead. A "10 to 50% general data" rule of thumb also circulates without a source; treat it as folklore and fit the curve.

The CMR scaling law (Gu et al., EMNLP 2024 Findings). Llama-shaped models of 460M to 3.1B, pretrained on 200B general tokens, then continued for 20B tokens (10,000 steps × 512 × 4,096 = 20.97B derived) on finance or arXiv papers mixed with general text at a constant learning rate of 3e-5. The definitions, read from the paper:

  • a mixture ratio R (the domain share) is feasible if, by the end of training, general loss is no more than a tolerance ε above the base model's (ε = 0.05, "based on empirical results by observation") and domain loss has fallen;
  • the Critical Mixture Ratio is the largest feasible R: below it the domain data is under-used, above it general loss rises past the tolerance;
  • final domain and general losses follow L(R) = α·Rs + β in the ratio, and their changes follow power laws in tokens; the CMR itself is fitted as RCMR = α₄·Ts₄ + β₃ (Equation 8). Fit on a few short runs, solve, and spend the full budget there.
Predict: you move from a 1.6B to a 3.1B base for the same finance CPT. Per the CMR fits, should the general-data share go up or down?

The domain share you can afford grows with model size and with training tokens. Coefficients from Table 5 (finance). Defaults reproduce the paper's four CMRs (29.8%, 34.9%, 41.4%, 47.8% at 20B) independently from the coefficients; past 20B the curves are extrapolation. One unit conversion is ours: the paper sets T = 100 for its 20B tokens, so one unit is 0.2B, and its Figure 5 caption's "T=250, which is equivalent to ... 500B tokens" should read 50B derived; the slider uses 0.2B per unit.

Correction to the old page
The old page reported the four predicted CMRs (29.8%, 34.9%, 41.4%, 47.8% for 460M, 940M, 1.6B and 3.1B on finance) "expressed as the general-data share". They are the domain-data share: §3 defines the mixture ratio as "the mixture ratio of the domain-specific data". Larger models tolerate more domain data, and a domain closer to the general data tolerates more (academic papers 36.7% against finance 29.8% at 460M). The parent page carries the same correction.
The D-CPT law, and why its "optimal" share (92%) disagrees with CMR's (30 to 48%)

The D-CPT Law (Que et al., NeurIPS 2024) adds the mixture ratio r to a Chinchilla-style law: L(N, D, r) = E + A/Nα + B·rη/Dβ + C/(r + ε)γ, fitted on Qwen1.5 0.5B, 1.8B and 4B, 0.1B to 26B tokens and six domains, and used three ways: the best domain share under a cap on general-loss damage, the best share when the domain corpus is limited (its "explicit domain-corpus-size" use), and how to split compute between model and data. Its worked example: chemistry, 1.8B, 10B tokens, general loss allowed to rise at most 3% from 2.8602.

A looser cap on general damage buys a larger domain share. Measured general loss at each domain share from Table 5, as a rise over 2.8602; the crossing is interpolated between neighbouring measurements. At the paper's 3% it falls at a domain share of 0.9245, matching the law's prediction of 0.924 independently (the law's predicted general loss there, 2.9458, against a measured 2.9445). Outside 1.6% to 4.3% the table has no points to interpolate.

Why the two "optimal" shares disagree (about 30 to 48% domain in CMR, 92% in D-CPT): they answer different questions. CMR caps the general-loss rise at an absolute 0.05 nats and requires it to be heading down by the end; D-CPT caps it at a relative 3% (about 0.086 here); and the domains, base models, budgets and learning rates differ (CMR: a constant 3e-5 over 20B tokens; D-CPT: 10B tokens on Qwen1.5). Neither ratio transfers to your run; the method does: run a few short pilots at different ratios, fit, pick the ratio, then commit the budget.

A domain that teaches general skills can exceed both. DeepSeekMath continued DeepSeek-Coder-Base-v1.5 7B for 500B tokens at 56% DeepSeekMath Corpus, 20% GitHub code, 10% arXiv, 10% Common Crawl natural language and 4% AlgebraicStack, so 44% of the stream was not new maths web text published. Its 56% domain share is above every CMR the finance fits predict (at most 47.8%, at 3.1B), and its general benchmarks still rose (MMLU 49.1% to 54.9% against the released Coder model, on its paper page): CMR's tolerance is defined on general loss, at its scales and for its domains, and maths or code can raise general scores rather than cost them.

6e. What labs did

Fourteen disclosed continued-pretraining recipes, checked against their sources, are on the CPT recipes compared tab: almost all replay (median general share 10%), their learning-rate peaks vary a hundredfold, and only half measure forgetting.

Re-run post-training afterwards. Continue the base model, not the chat model, then post-train again (or at least SFT). Continued pretraining of an instruction-tuned model erodes instruction following: Llama 3 8B Instruct continued on 1B tokens of news dropped up to 10 points on the instruction-following set and 3 points on average; adding the "instruction residual" (instruct weights minus base weights) back onto a continued base recovered it without new instruction data (Jindal et al. 2024, §4.1). Every recipe in the recipes tab re-runs post-training after CPT.

Other findings: order, model scale, tokenizer extension, alternatives to replay
  • Order and staging. The old page said a brief warm-up phase on general data before the domain mix stabilises training, and that staged curricula (general-heavy, then domain-heavy) beat static mixes "in several studies". This page could not find those studies unconfirmed. What is measured is narrower: Llama-3-SynE (Llama 3 8B, about 100B tokens) found an easy-to-difficult curriculum over its scientific data beat random sampling and the reverse order (§4.2), and used two stages (92.5B tokens at Chinese:English 2:8, then 7.5B at Chinese:English:synthetic 1:7:2). And Ibrahim et al. found that ingesting domains one after another, re-warming for each, did worse than one mixture, "of limited practical use" (Appendix A.1).
  • Model scale. The evidence that larger models forget less is mixed. Yıldız et al. found "smaller models are particularly sensitive to continual pretraining, showing the most significant rates of both learning and forgetting" (arXiv 2402.17400); the CMR study found larger models tolerate a larger domain share (29.8% at 460M to 47.8% at 3.1B). But in Ibrahim et al.'s weak shift the relative rise in Pile loss was about the same at both sizes: 12.4% at 405M and 13.1% at 10B with no replay, 2.8% and 2.3% with 5% replay derived (Table 4). Recipes that trained several sizes the same way lean towards the claim: Swallow's English average fell 5.0, 4.8 and 2.3 points at 7B, 13B and 70B ("the performance drop tends to be smaller as the model size increases", Table 4); ChipNeMo's MMLU moved −1.1, −2.0 and +0.8.
  • Tokenizer extension. For a new language or a domain the tokenizer splits badly (high fertility: many tokens per word), extend the vocabulary, train the new embeddings first in a brief embedding-only phase, then run full CPT. Chinese-LLaMA added 20,000 Chinese tokens to LLaMA's 32,000 (49,953 after merging) and, for 7B, trained only the new embeddings and output layer before the main stage (§2.2); Swallow added 11,176 Japanese subwords and cut the tokens needed for Japanese text by 56.2%; ChipNeMo added about 9K chip-design tokens, initialised from the mean of their old sub-tokens; the toy here avoided the question by writing German umlauts as two letters. Fertility and its cost are on Tokenizers.
  • Parameter-level alternatives to replay help when replay tokens are unaffordable or the original data is unknown, but replay plus the schedule remains the default answer. Elastic weight consolidation (EWC) penalises moving weights that mattered for the old data (Kirkpatrick et al. 2017). LoRA-based CPT forgets less because it learns less (PEFT). Merging: in Ibrahim et al.'s preliminary test, TIES-merging separately trained models scored below continued pretraining with replay on every comparison (10B weak shift, English average 41.94 against 47.68; Appendix A.2, Table 6), and merging a continued model back into its base "does not increase performance". Later recipes report the opposite at scale: Thomson Reuters merged its continued model with the pre-CPT checkpoint and "an appropriate merge coefficient can recover most of the general capability lost during continual pre-training" (report, §3.3), and eBay merged e-Llama with its base to set the trade-off. Treat merging as a lever worth a pilot, not a settled answer.
What it costs: two documented pipelines (Thomson Reuters, Periodic's Neon; reported figures)

Practitioners almost never publish a budget next to a recipe, which is why these two are worth more than their technical content. Their dollar figures, with what each includes, sit on the training topic's Price list; this block keeps the shape.

Thomson Reuters continued Qwen3.5-397B-A17B into Thomson-1.0, a legal, tax and news model: 200B curated tokens selected from a 19T-token pool with DatologyAI (1.05% kept derived), then DPO alignment against an open-source constitution and GSPO for context compaction and document caching (The Batch; technical report). The report's mid-training mix is "three roughly equal parts: curated proprietary documents, synthetic data generated from those documents, and curated general-capability replay data", so about a third is replay derived; the learning rate was chosen per scale by pilot sweeps; the continued model was merged with the pre-CPT checkpoint, then aligned with DPO and GSPO. Against its base it measured general average 76.7 against 73.5, with coding (39.9 against 43.9) and factuality (73.7 against 76.2) down (§3.3, Table 1). LawNext quotes Thomson Reuters saying CPT used its proprietary content "exclusively", which the report's replay third contradicts; the report is the technical source. Unusually, it continued an instruction-tuned, value-realigned checkpoint rather than a base model, and relied on the merge and the later DPO to restore behaviour: the customise-an-open-base path stated end to end (select hard from a much larger pool, keep some replay, then re-align).

Corrections

The old page said Thomson Reuters mid-trained the model "for a reported $40M in three months", with a 35B open-weights sibling "released alongside". The $40M covers talent and compute over about two years; the CTO put the final training run at $450,000, about 89 times less derived (LawNext, 24 Aug 2026); The Batch's "three months" is the outlier among the sources. The 35B sibling, on Qwen3.6-35B, will be released for academic and non-commercial use. Both corrections were made on the parent page first (checks of 2 October 2026), and both figures remain reported, not audited.

Periodic's Neon makes the same argument with a different corpus. Mid-training plus reinforcement learning of Kimi K2.6 on real laboratory records took it from 2.7% to 55.3% on FrontierXRD (134 lab samples), ahead of GPT-6 Astra and Claude Fable 5.1 on a hard scientific-analysis evaluation at lower cost per analysis reported; it is deployed in labs analysing superconductor and magnet experiments, and the final run used 1,300 H200 GPUs (Periodic, 15 September 2026). The transferable part is the structural claim: domain training on proprietary operational data, the records an organisation generates anyway rather than a corpus assembled for the purpose, establishes a Pareto-optimal cost-performance frontier against general frontier models. Most organisations sizing a domain-adaptation project already hold that data and do not think of it as a corpus.

7. Checklist for a CPT run

  1. Define target and guard metrics before training: domain evaluations, general evaluations and safety. Evaluate the base model on all of them first; that is the line forgetting is measured against.
  2. Pilot runs to pick the mixture ratio (CMR- or D-CPT-style: a few short runs, fit, predict) and the peak learning rate. Start the pilots well below the pretraining peak and include one near it, since the published sweeps (0.5× to 2×) trade adaptation against forgetting; use a WSD-style schedule if more stages will follow.
  3. Replay source as close to the original pretraining data as you can get; deduplicate the domain data against your evaluations; compute each source's epochs (section 1).
  4. Monitor both loss families during training, general and domain. Forgetting shows early: in the toy and in Ibrahim's runs the general loss jumps in the first few percent of steps, and "relative differences between [replay fractions] appear very early" (§2).
  5. Post-train afterwards, and compare against a no-CPT baseline fine-tuned the same way, to prove CPT was worth it.

Filtering and deduplication of the replay and domain data are on the Topic: data-curation-and-datasets children; the re-alignment step on Alignment: SFT, RLHF, DPO Family, RLVR.

Depth: common mistakes and interview rehearsal

Common mistakes (12, mixing and CPT)
Setting weights without computing epochs
A 10% weight on a 20B-token domain in a 2T-token run is 10 epochs. Compute w·D/U for every domain before training; above about 4, expect diminishing value, above about 16 near zero (section 2).
Copying a published mixture or mixture ratio
Weights depend on the domain definitions, the tokenizer, the model size and the budget: DoReMi's Pile weights changed from 60.6% Pile-CC (280M proxy, 256k vocabulary) to 13.8% (120M, 50k vocabulary), and AutoScale shows optima shifting with scale. In CPT, CMR's 30 to 48% and D-CPT's 92% domain share are both "optimal" under different tolerances, domains and budgets. Use a published mix as a starting point and fit your own on pilots.
Comparing against a strawman baseline
"Beats the Pile's default weights" meant beating a document-count weighting (section 3a), and "Pile-CC only" tied DoReMi in RegMix's own Table 4. Always include stratified sampling, natural shares and the single best domain among your baselines.
Optimising the loss of one domain and calling it quality
RegMix optimised Pile-CC validation loss because it correlated best with its downstream tasks; on other tasks (code, maths) a different target would win. Choose the target from the evaluation you care about, and check the correlation on your own runs.
Crediting the anneal's data for the learning-rate decay
A decay stage changes the data and the learning rate at once. OLMo 2's ablation found most of the knowledge gain came from the decay alone; only the maths gain was the data (Pretraining, section 5). Run the decay on the unchanged mix as a control.
Letting the loader change the epochs
Interleaving with an "all exhausted" strategy repeats small streams; restarting without the sampler's state replays or skips data. Log achieved token counts per domain, not just the configured weights.
Testing a mixture on a single seed
Small proxy runs are noisy: Aioli's differences are tenths of a perplexity point. Several seeds per mixture, or many mixtures and a regression (RegMix's answer), before trusting a ranking.
Continuing the chat model instead of the base
Instruction following erodes within a billion tokens (Jindal et al.: up to 10 points). Continue the base, then post-train, or add the instruction residual back.
No general evaluation until the end of a CPT run
Forgetting happens in the first percent of steps. Track a general held-out loss from step zero, next to the domain loss.
Blaming the learning rate for all the forgetting
Under a strong shift most of the damage is the data: Ibrahim's never-re-warmed run still lost 76% as much. Lowering the peak trades adaptation for retention; replay is the lever that is nearly free.
Comparing losses across tokenizers or scales
Loss per token depends on the tokenizer, and a 0.2 rise means different things at 405M and 10B. Compare relative changes against the same model's base, on the same validation set.
Reading a headline budget as a run cost
Thomson Reuters' $40M is a two-year programme including staff; the final run was $450K. Say which one you compare.
Interview rehearsal (6 questions)
Why not just train on the natural shares of your corpus?
Size is not value: the biggest pile (web) drowns small high-value ones (code, maths, encyclopedic). But upweighting a small pile repeats it, so the choice is a trade between value per token and repeats; compute epochs and use a cap (UniMax) or a fitted method.
Explain DoReMi in three sentences.
Train a small reference model on default weights. Train a small proxy with Group DRO: each step, upweight domains (multiplicatively) by the proxy's excess loss over the reference, clipped at zero, and weight the proxy's loss by them. Average the weights over the run and train the big model on that mixture.
What is the rank-invariance assumption and how would you test it?
That the order of mixtures by loss is the same for tiny and large models. Train a handful of large runs on mixtures the regression ranks differently and compute the Spearman correlation between predicted and true order (RegMix: 0.97 from 1M to 1B on its data; check yours).
You have 50B tokens of excellent maths and a 4T-token run. How do you use them?
Mostly in the decay stage, where they can be a large share of a short run; up to about 4 epochs costs little, so a 200B-token anneal could take 50% maths at 2 epochs or 25% at 1. Keep a small share in the stable phase if the model must not lose maths early. Validate with an anneal ablation and a decay-only control.
How do you pick the replay ratio for a legal-domain continued pretraining?
Run 3 or 4 short CPT runs at different domain shares, fit general and domain loss against share and tokens (CMR law), and take the largest share keeping general loss within your tolerance; replay data as close as possible to the base model's pretraining mix. Refit if the base model or the budget changes.
System design: plan the data mixture for a 3T-token pretraining run from six sources, with a fixed budget of 2% of the run's compute for mixture search.
Inventory: unique tokens per source after dedup and decontamination, with the tokenizer of the run. Constraints: max epochs per source (4 for anything that matters), minimum shares the product needs (code, languages). Search: RegMix-style, a few hundred proxy runs of about 1M non-embedding parameters on random Dirichlet mixtures inside the constraints, targets chosen by correlation with the eval suite; fit a nonlinear regressor and the exponential law, compare their recommendations; confirm the top 2 or 3 with a few 1B-scale runs (rank check). Stages: stable phase on the searched mix, a decay over the last 5 to 10% with the best sources upweighted to their epoch caps, chosen by anneal ablations from a mid-run checkpoint. Loader: per-source shards, deterministic blending, sampler state in checkpoints, per-source token logs. Risks: rank flips at scale, contamination through upweighted small sources, and the anneal hiding a weak base mix.

Sources linked inline; tables transcribed from arXiv HTML versions and repositories at the commits named, read 2026-10-14 (mixing) and 2026-10-03 (continued pretraining). Derived numbers are recomputed in src/recompute.py and src/cpt/recompute_cpt.py; the embedded data is src/data/mx2_data.json and parts/26_js_cpt_data.js.