Data Mixtures

Dive into Deep Learning · §20.4

Data Mixtures
domain weights · temperature and repetition · proxy regression · DoReMi · annealing · transfer

Every Candidate Mixture Costs a Pretraining Run

The problem

Olmo 3’s pretraining mixture, from its dataset card:

source share
web (Common Crawl) 76%
scientific PDFs 14%
code 7%
mathematics web pages 2.6%

Nobody derives these numbers, and nobody can afford to try every candidate at full scale.

Domain weights are hyperparameters. Fit them on small proxy runs.

By the End of This Deck You Can

Goals

  • compare losses across domains in bits per byte;
  • compute what temperature sampling repeats and what repeats are worth;
  • fit a regression from weights to loss and know its noise floor;
  • choose a mixture for a fixed target, and say what DoReMi optimizes instead;
  • judge whether a proxy’s choice transfers.

Running example: 65 runs of a 4.6M-parameter GPT, 2^{24} tokens each, on web text (FineWeb-Edu), Python (CodeParrot, permissive licences) and mathematics (FineMath).

Mixing Comes After Choosing and Before Cutting

Where this fits

step section
get text Document Extraction from Web Crawls
choose text Quality Filtering
Deduplication and Decontamination
mix text Data Mixtures
Synthetic and Rephrased Data
cut text Tokenizers at Scale
  • Here: how often each kind of text is read.
  • Skips: mid-training stages of released models.

Per Token, Code Looks Easiest; per Byte, It Is Hardest

Comparable losses

The uniform mixture, one proxy:

web code math
bytes per token 4.56 2.42 3.00
bits per token 8.73 5.13 6.63
bits per byte 1.92 2.12 2.21

\textrm{bpb} = \frac{\sum \textrm{NLL (nats)}}{\ln 2 \cdot \#\textrm{UTF-8 bytes}}

Bits per byte do not depend on the tokenizer. Hold fixed: tokenizer, model, tokens, schedule, evaluation sets, data order.

Temperature Sampling Repeats the Smallest Sources Most

Many sources

p_i \propto n_i^{\alpha}; epochs e_i = p_i D / n_i \propto n_i^{\alpha - 1}.

Ten languages, 10^{10} documents drawn:

language documents share, \alpha = 1 share, \alpha = 0.3 epochs, \alpha = 0.3
English 25.9B 0.915 0.345 0.13
Hindi 22M 0.0008 0.042 18.7
Swahili 1.2M 0.00004 0.017 143

\alpha = 0.7 (multilingual BERT), 0.3 (XLM-R, mT5). Sampling does not create data; it chooses what is repeated.

Repeats Are Almost Free up to Four Epochs, Then Saturate

Repetition

U unique tokens, E epochs, R = E - 1 repeats:

D' = U + U R^* \bigl(1 - e^{-R/R^*}\bigr), \qquad R^* \approx 15.4

epochs D' / (UE)
4 0.93
4.8 0.91
\infty D' \to 16.4\, U

Small R: D' \approx UE. Large R: further epochs add nothing (Muennighoff et al.’s fit).

Check: Swahili Read 143 Times. Worth How Many Fresh Copies?

Check

Use D' = U + U R^* (1 - e^{-R/R^*}) with R^* = 15.4 and R = 142.

Answer. e^{-142/15.4} \approx 10^{-4}, so D' \approx 16.4\,U: about 11% of 143 fresh copies. Most of Swahili’s share at \alpha = 0.3 is wasted; UniMax caps the epochs per language instead.

RegMix: Sample Mixtures, Train Proxies, Fit, Minimize

The method

runs mixtures purpose
15 training 6 Dirichlet(1), 6 Dirichlet(0.3), 3 corners fit
4 held out Dirichlet(1), another seed judge the fit
9 pure, 7 uniform one domain; seeds matrix; noise
3 × 3 seeds uniform, selected, DoReMi arms
2 × 3 seeds anneal on math, then back to uniform annealing
9 + 4 half the rate; 4× the steps checks
  • Peak learning rate chosen once on uniform: 2 \times 10^{-3} (interior of four values), never per mixture.
  • Targets fixed first: t_{\textrm{avg}} = (\tfrac13, \tfrac13, \tfrac13), t_{\textrm{dep}} = (0.7, 0.15, 0.15) over (web, code, math).

Each Proxy Is Best on Its Own Domain

Why mixing is a choice

Bits per byte of the pure-domain proxies:

trained on web code math
web 2.05 5.23 3.31
code 2.57 2.02 3.06
math 2.15 3.46 2.24

Off-diagonal costs are large and asymmetric. FineMath is English prose about mathematics: on web text its proxy is much nearer the web proxy than the code proxy is.

Early Rankings Predict Late Ones in 105 Pairs

Do curves cross?

For every pair of the 15 training mixtures, compare the t_{\textrm{dep}} loss at 25% of the run and at its end.

pairs
all pairs 105
order swaps 10
swaps beyond 2\sqrt2 seed SDs at both points 0

At this scale a short run ranks mixtures as a full one does. Whether a small model ranks them as a large one does is another question.

A Correct Least-Squares Fit Reaches σ√(1 + p/n)

The noise floor

No predictor beats \sigma, the noise of the held-out run itself. Least squares, n runs, p parameters, correct model:

\mathbb{E}\bigl[(\hat y - y)^2\bigr] = \sigma^2 \bigl(1 + \mathbf{x}^\top (\mathbf{X}^\top \mathbf{X})^{-1} \mathbf{x}\bigr)

Average over the design: \operatorname{tr} of the hat matrix is p, so \sigma^2 (1 + p/n).

  • Floor with p = 3: about 0.01 bits per byte; a yardstick, not a bound.
  • \sigma rests on four seeds of the uniform mixture, so it is rough.
  • Simulation: 4.79e-4 against 4.78e-4 predicted.

On Held-Out Mixtures, Every Regression Misses the Floor on Code

Three regressions

Mixing law: b_i(\mathbf w) = c_i + k_i \exp\bigl(\sum_j t_{ij} w_j\bigr).

held-out RMSE (bpb) web code math
ridge 0.03 0.06 0.07
gradient boosting 0.01 0.03 0.05
mixing law 0.003 0.12 0.04
floor 0.01 0.01 0.01

The law fails on code, whose loss drops steeply near zero code weight. More runs lower the floor, not the bias.

A 70%-Web Target Selects About One Third Web

Choosing

Minimize the fitted t_{\textrm{dep}} loss inside the hull of the training mixtures:

regression (web, code, math)
mixing law (fixed in advance) (0.34, 0.31, 0.35)
ridge (0.10, 0.80, 0.10), a corner
gradient boosting (0.24, 0.55, 0.22)

200 bootstrap refits: web 0.25 to 0.38, code 0.24 to 0.43.

In the fitted law, web loss barely moves with web weight; code and math fall with theirs. The runs fix a neighbourhood, not a point.

Check: Why Does Ridge Always Choose a Corner?

Check

Ridge predicts each b_i as linear in \mathbf w. The choice minimizes \sum_i t_i b_i(\mathbf w) over the hull of the training mixtures.

Answer. A sum of linear functions is linear, and a linear function on a polytope is minimized at a vertex. Ridge can never select an interior mixture; the mixing law’s exponentials can.

DoReMi Maximizes the Worst Excess Loss, Not Your Target

A different objective

\min_\theta \max_{\boldsymbol\alpha \in \Delta} \sum_i \alpha_i (\ell_i(\theta) - \ell_{\textrm{ref},i}); excess g_i clipped at 0 per token.

\alpha_{t+1,i} = \frac{\alpha_{t,i}\, e^{\eta g_{t,i}}}{\sum_j \alpha_{t,j}\, e^{\eta g_{t,j}}}

web code math
weight at step 65 0.03 0.75 0.22
weight at step 129 0.15 0.25 0.60
average over 256 steps 0.17 0.47 0.36

Three Arms: One Method, Two Targets, Two Verdicts

Arms

Three seeds each, paired with uniform; real only if all three differences share a sign and the mean exceeds 2\sigma_{\textrm{seed}} (about 0.01).

arm minus uniform t_{\textrm{dep}} t_{\textrm{avg}} code
regression’s choice about −0.007 about −0.008 0.00
DoReMi about +0.015 about −0.025 −0.10

DoReMi lowers code loss and raises web loss: worse on the web-heavy target, at the edge of the noise; better on the average.

Annealing Reads the Best Data While the Learning Rate Falls

Annealing

  • Stable-then-decay: peak rate for 80% of the steps, decay in the last 20%.
  • SmolLM2’s last 10% of 11T tokens: 14% math, 24% code, held back until then.
  • Our anneal arm decays on (0.1, 0.1, 0.8): math −0.04 bpb, web +0.02, code +0.07 against uniform, all 3 seeds.
  • Back to uniform for the last 10% of the steps: two thirds of the math gain remain.

Benchmark gains may be recency. Check held-out loss of the domain, then train on and see whether the gain survives.

Olmo 3 Runs the Same Method With Larger Proxies

A released mixture

source pool (tokens) mix (tokens) epochs
Common Crawl 8.14T 4.51T 0.55
code (Stack-Edu) 137B 409B 3.0
arXiv 21.4B 50.9B 2.4
FineMath 3+ 34.1B 151B 4.4
  • Weights from a swarm of 30M-parameter proxies, 3B tokens each, Dirichlet mixtures, one regression per task.
  • Then 100B tokens of mid-training on the best data plus task data.

Check: Nine Tenths of the Proxy Is Its Embedding Table

Check

4.2M of the 4.6M parameters are embeddings; it sees about 4 tokens per parameter, against about 20 for compute-optimal training. What can its ranking of mixtures tell you about a 1B model?

Answer. A hypothesis, not a measurement. It has learned which tokens follow which, not long-range structure; a larger model may value code and math differently. RegMix checked its choice against 64 mixtures trained at the large size.

Four Times Larger: Rank Correlation 0.70, the Choice Moves to Web

Transfer

A test at half the T2 tokens: 20.3M parameters, 2^{26} tokens, 46 minutes on four RTX 4090s. The full T2 campaign (2^{27} tokens) has not been run.

4.6M proxy 20.3M proxy
peak learning rate 2 \times 10^{-3} 10^{-3}
selected for t_{\textrm{dep}} (0.34, 0.31, 0.35) (0.44, 0.27, 0.30)
selected minus uniform within noise about −0.01, all 3 seeds
DoReMi weights (0.17, 0.47, 0.36) (0.29, 0.30, 0.41)

Rank correlation of 22 shared mixtures: 0.70.

Recap

Recap

  • Compare domains in bits per byte; code is 5.1 bits per token but 2.1 per byte.
  • Temperature \alpha = 0.3 reads Swahili 143 times, worth 11% of fresh data.
  • Early rankings predict late ones: 0 of 105 pairs cross beyond the noise.
  • Floor of a correct fit about 0.01 bpb; best regression 0.03, mixing law 0.07 (code).
  • Web-heavy target selects about one third web; DoReMi moves weight to code.
  • At 4× the size: rank correlation 0.70, the choice moves to web and wins.

Next: making unique tokens for domains that are too small.