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.
New terms
The methods, side by side:
| Method | What it does | Cost to choose the weights | Evidence (who measured) | Verdict |
|---|---|---|---|---|
| Natural shares | Each pile in proportion to its size | none | baseline everywhere | Small, valuable piles drown |
| Hand weights | Upweight piles believed to be good, cap epochs (The Pile, GPT-3) | none | baseline in DoReMi and RegMix | Hard to beat by much; often what labs still do, with ablations |
| Temperature, UniMax | Flatten the natural shares (multilingual); UniMax caps epochs | none | UniMax beat temperature at every size tested (Chung et al. 2023) | Use UniMax-style caps for many small piles |
| DoReMi | A small proxy trained with Group DRO upweights domains where it lags a reference model | 2 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 Laws | Fit loss as an exponential of the weights on small runs, extrapolate with scaling laws | tens of small runs | 1B on 100B tokens matched the default mix trained 48% longer (authors) | Interpretable; the functional form fits RegMix's data well (refit here) |
| RegMix | Train hundreds of tiny models on random mixtures, regress loss on weights, pick the best predicted mix | 512 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 signals | little extra compute | Aioli beat stratified sampling on 6 of 6 settings at 160M (authors) | Promising; small-scale evidence only |
| Stages and the anneal | Broad data first, best data at the end while the learning rate decays | a few anneal ablations | OLMo 2 7B GSM8K 24.1 to 67.5 after 50B tokens (authors); SmolLM2 maths 3.2 to 22.1 in stage 4 | Standard in every 2025 to 2026 open recipe |
| Replay in CPT | Mix general data back into the new-domain stream | none | 1% 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 tolerance | a few short runs | Domain 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.
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.
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
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.
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.
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.
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.
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).
Fig. 2 · What each pass over the same data is worth
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.
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.
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.
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.
Xie et al. (2023; arXiv 2305.10429, §2 and Algorithm 1):
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.
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:
src/scripts/proxy_mix.py (one file: prep, train, sweep, doremi; the parent's Mixing lab can reuse it unchanged).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.
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.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.
src/recompute.py, and the page check confirms the two agree.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).
sangmichaelxie/doremi at commit 7cde52d, doremi/trainer.py, lines 252 to 259, the update in log space:
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.
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.
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
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.
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
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.
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.
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.
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.
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.
Published, not re-checked here published:
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.
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
NVIDIA/Megatron-LM at 80781ab, megatron/core/datasets/helpers.cpp, build_blending_indices, lines 104 to 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.
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:
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'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.
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.
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.
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.
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.
Fig. 5 · The toy's English loss while it learns German, mean of three seeds
Replay. Measured ranges:
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
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.
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%.
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.
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.
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.
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.
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:
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.
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.
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.
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).
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.
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.
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.
Give the planner your domain pools (unique tokens after filtering and dedup), the stages of the run (tokens per stage) and the weights in each stage. It returns the tokens each domain supplies, its epochs, its effective data under Muennighoff et al.'s repetition law (Reading, section 2), and warnings; then it animates the same tokens in two orders: one static mixture for the whole run, and your stages.
Edit any white cell. Weights in a stage are normalised to sum to 100%; the sum you typed is shown under each stage. A pool left empty means "not published": epochs are not computed for it.
The static mix uses each domain's share of the whole run, so both orders contain exactly the same tokens per domain and the same epochs; only where they fall on the token axis differs. The learning-rate line is a warmup-stable-decay schedule with the decay over the last stage illustrative shape.
Every disclosed domain-adaptation recipe this page could verify (Reading, section 6e summarises them) against its primary source, with the two levers side by side: how much general data each kept in the mix, and how high it re-warmed the learning rate relative to the base model's own peak. Three builders' own mid-training stages and one from-scratch domain model are included as reference points. "Not disclosed" means the source does not say.
Above: each continued-pretraining recipe with both levers disclosed, placed by general share and learning-rate peak relative to its base's peak (log scale). The published ablations sit inside this cloud: Ibrahim et al. used 5 to 25% replay at 1×; e-Llama chose 10% of the peak after an ablation. General share counts natural-language or general data only (code kept for a code base is listed in the notes). Learning-rate ratios are derived from the two peaks each paper states. Research notes with every quote: src/cpt/inputs/recipes_research.md.
Times for pages in this knowledge base are each page's Reading tab, measured 2026-10-24 at 230 words a minute.
Pools, stages and weights to tokens, epochs and effective data; the same tokens in two orders. about 10 min
Eighteen disclosed recipes: general share, learning-rate peak, tokens, forgetting measured. about 10 min
The whole data side at overview depth; its section 7 and Mixing lab summarise this page. 31 min, plus 7
The piles being mixed: sizes, licences and lineage. 31 min, plus 15
Selection inside a domain; quality buckets become domains to mix. 42 min, plus 13
Unique tokens, the pool sizes every epoch count depends on. 34 min, plus 23
The rephrased and textbook data that fills decay stages. 42 min, plus 13
Shards, shuffling, resumption: how a loader realises a mix. 34 min, plus 5
Scaling laws (section 3), stages (section 4), and what the anneal buys (section 5: OLMo 2's split of the anneal into learning rate and data, and the anneal toy, this page's sibling experiment to the replay toy). 24 min, plus 4
WSD schedules and the three meanings of "annealing". 34 min, plus 14
Every stage on one grid, open recipes compared, the Price list with Thomson Reuters' two figures. 26 min, plus 22
LoRA against full fine-tuning, including LoRA-based continued pretraining: learns less, forgets less. 26 min, plus 2
Long-context extension, the other common kind of continued pretraining: RoPE rescaling and its recipes. 40 min, plus 21
Fertility, and why a new language may need new tokens before CPT. 46 min, plus 15
The other way to specialise: a small model trained on a larger one's outputs. 25 min, plus 8
The re-alignment that follows every CPT run. 33 min, plus 4
Dolmino mixes, microanneals and souping, tables transcribed. 29 min
A 500B-token maths CPT of a code model, the code-first curriculum ablation, GRPO. 25 min
Final mix, annealing, the 40B-token data-value test and the 800B-token long-context stage. 31 min
A decay-free schedule via checkpoint merging, the family of schedules that resume without re-warming. 20 min
Table 1 and Appendix D: hand weights with an epoch cap. 30 min
Temperature sampling's flaw and the budget-first fix. 40 min
The repetition law and its fit; sections 3, 6 and 7. 90 min
Group DRO proxies; read Table 1 with this page's baseline note. 45 min
The exponential form and nested scaling laws. 45 min
Mixture search as regression; rank invariance. 45 min
The unified view and the stratified-sampling check. 60 min
A four-stage recipe with per-stage scores. 90 min
Section 4: mid-training data and ablations. 60 min for section 4
The reference empirical study: re-warming, re-decaying and replay match full retraining at 405M and 10B; infinite schedules; every table behind the frontier chart in 6b. 90 min
The predecessor: warmup length, peak and starting checkpoint on Pythia 410M continued on SlimPajama. 25 min
Predicting the critical domain share from small pilots; the coefficients behind the calculator in 6d. 45 min
A Chinchilla-style law with the mixture ratio inside, its three uses, and a cross-domain version for new domains. 45 min
The clearest public new-language recipe: vocabulary extension, replay ratio pilots, forgetting measured at three sizes. 40 min
Half general replay, the 10%-of-peak learning rate chosen by ablation, and merging to set the trade-off. 30 min
A living survey of CPT papers, organised by method, scaling, forgetting and domains (last updated October 2025 when checked). 30 min
Neon: mid-training and RL on laboratory records, the operational-data argument. 10 min
Reference implementation; read doremi/trainer.py 239 to 262 and configs/. 30 min
All proxy runs as CSV, the regression notebook, the 1B mixtures. 30 min
Stage configs with every dataset weight (SmolLM2, SmolLM3). 20 min
build_blending_indices: deterministic weighting in a production loader. 15 min
Built from the old Notion pages "Data mixing" and "Continued Pretraining (CPT)" (both last edited 24 September 2026) and the sources linked inline. Source: the page folder's src/ in the knowledge base repository.