Multilingual Pre-training and Data Balancing › Extending the Sampler Beyond One Exponent

Michael BrenndoerferNovember 26, 202610 min read
Language AI HandbookAll chapters
Part 26 of 67Multilingual Language Models and Cross-Lingual Transfer
Chapter 185Multilingual Pre-training and Data Balancing › Extending the Sampler Beyond One Exponent
Reading section 4 of 11 · Extending the Sampler Beyond One Exponent · 10 minSection 4 of 11 · 10 min

Section 4 of 11 · 10 min read

Reading settings

Definitions

Choose how many terms have tooltips.

Article links

Make inline references clickable

Notes & comments

The exponent sets a baseline mixture. Use a multiplier to express a language priority, a cap to limit its share, and a stated sampling unit to make the result interpretable.

When reproducing a mixture, check whether the paper reports source multipliers, maximum shares, or a unit conversion. An exponent gives a complete recipe only once you know its input shares and subsequent transformations.

Per-language multipliers

The natural generalization is

qi=si piα∑jsj pjα,q_i = \frac{s_i \, p_i^{\alpha}}{\sum_j s_j \, p_j^{\alpha}},

Here si≥0s_i \geq 0 is a hand-set or learned multiplier for language ii. At least one language must have positive weighted mass so the denominator is nonzero. Use a multiplier when you want to express a priority for one language independently of natural share.

The multiplier sis_i is the place where everything the exponent cannot represent enters. It can upweight a language for product reasons or downweight a language whose corpus is known to be noisy. Setting si=0s_i=0 excludes language ii from the mixture as long as some other language contributes positive mass. It can also encode a data-quality judgment: if one language's corpus has passed a stricter filter, it may deserve a higher multiplier than a language whose corpus is dirtier at the same natural share.

BLOOM provides a separate example of intentional data composition. Its authors report ROOTS as a mixture of natural-language and programming-language data. Use their published composition to read the source mix. BigScience (2024), section 3

Caps and water-filling

A common share cap limits how much mixture mass any language can receive. No language may exceed cc, and the excess is redistributed to uncapped languages in proportion to their current weights. This is a water-filling procedure, applied iteratively because redistribution can push another language over the cap.

In this water-filling procedure, increase a common scale factor λ\lambda. Languages with larger base weights reach the shared cap first. Fix capped shares at cc and scale the free weights to use the remaining mass.

With positive input weights and a feasible common cap cc such that Lc≥1Lc\geq 1 for LL languages, choose the normalizer λ\lambda so that the resulting shares sum to one. Fix any share that would exceed cc and redistribute the remaining mass among the free languages:

qi=min⁡{c,λ piα}with∑iqi=1.q_i = \min\{c,\lambda \, p_i^{\alpha}\} \quad\text{with}\quad \sum_i q_i = 1 .

A common cap flattens the largest shares. A repetition cap has a different purpose: it takes the size of each language's corpus into account.

A common share cap can reduce head shares and increase tail shares. To limit expected draws relative to a small corpus, set a bound on that language’s effective epochs. Check that the sum of all available share bounds is at least one before using them.

The unit of sampling: documents or tokens?

You can define pip_i over documents, tokens, or characters. The document and token distributions differ when mean tokens per document vary across represented languages. Fertility and document length can offset each other. Suppose one corpus averages 50 words per document at two tokens per word and another averages 100 words at one token per word. Both average 100 tokens per document, so their document and token shares agree.

The ambiguity is easy to miss because most mixture descriptions say "share" without specifying the unit. Two papers can report the same α\alpha and produce different effective mixtures because one computed pip_i over documents and the other over tokens. When you reproduce a mixture, the first thing to check is which denominator the original used.

Suppose Yoruba needs 2.6 tokens per word and English needs 1.0. With fixed-length sequence packing and comparable compute per token, a Yoruba word consumes about 2.6 times the token budget of an English word. The average cost per document also depends on document length. For example, with 60 words in the average Yoruba document and 120 in the average English document, the ratio is 2.6×60/120=1.32.6 \times 60/120=1.3.

To estimate token share from document sampling, multiply each document share by mean tokens per document and normalize. Measure mean tokenized length directly, or multiply the corpus-level ratio of total tokens to total words by mean words per document for the same set of documents. If you average per-document fertility first, this identity can fail when fertility and length covary.

Batch composition

Suppose the B=512B=512 sequences in a batch are drawn independently and each draw has probability qiq_i of selecting language ii. The expected count is BqiBq_i and the probability of at least one appearance is 1−(1−qi)B1-(1-q_i)^B. At qi=10−3q_i=10^{-3}, the expected count is about 0.51 and the language appears in roughly 40% of batches. At qi=10−4q_i=10^{-4}, it appears in roughly 5% of batches.

These probabilities help you interpret the training signal:

  • At qi=1/Bq_i=1/B, the expected count is one, yet at B=512B=512 about 37% of batches still omit the language. Use this as a coverage check. To study gradient variance, also measure what gradients the selected examples contribute.
  • Language-homogeneous micro-batches can make it easier to measure per-language gradients. At fixed parameters, regrouping the same weighted examples gives the same mathematical gradient sum when each example uses the same stochastic draws and its forward computation and loss are independent of its batch companions. Batch normalization or a loss that compares examples within a micro-batch can change that sum.

Compare predicted coverage with loader logs. For example, a quota of one sequence per language in every eligible batch gives presence probability one for those languages, while independent sampling would give probabilities below one for smaller shares.

If a language’s loss changes abruptly, check the delivered exposure over the same steps. Inspect other changes, including the sampled documents and learning-rate schedule, before linking the pattern to a scarce language.

Per-batch frequency is a different view of the same mixture. The next cell computes the probability that a language appears at least once in a batch of 512 sequences, and the figure shows how that probability changes with the exponent for a head language and two tail languages.

PythonIn [5]
CollapseExpand
import numpy as np

batch_p = tilt_p
batch_langs = ["English", "Swahili", "Yoruba"]
batch_idx = [0, 5, 7]
batch_alphas = np.linspace(0.0, 1.0, 51)
batch_q = np.power(batch_p[None, :], batch_alphas[:, None])
batch_q = batch_q / batch_q.sum(axis=1, keepdims=True)
batch_size = 512
batch_inclusion = 1.0 - np.power(1.0 - batch_q[:, batch_idx], batch_size)
VisualizationOut [6]
CollapseExpand
Line chart of batch presence probability against alpha for three languages.
Probability that a language appears at least once in a batch of 512 sequences as the sampling exponent varies. Under independent sequence draws at natural shares, Yoruba appears in about 92% of batches; lower exponents move its probability closer to one.

Staging and annealing

A staged sampler can vary the language mixture over training. Compare a fixed baseline with a staged schedule at the same total token budget. The two schedules below specify how to construct a comparison.

  • Broad then sharp: start with a smaller α\alpha and later raise it. The early mix is flatter on the original positive shares.
  • Proportional then boost: start at α=1\alpha=1 and later increase tail-language weights, for example by lowering α\alpha.

A gradual decrease in α\alpha also moves the mixture toward a flatter distribution. Choose a schedule to test and record the delivered shares before and after the change.

Compare the schedule with a fixed-mixture control. Evaluate both under corpus weighting and under a weighting chosen for the deployment or product.

If the aggregate scores disagree, inspect per-language changes and their evaluation weights. The two reported scores can disagree even when evaluated on the same predictions. Use a separate sample of traffic to assess deployment generalization.

Quality and mixture interact multiplicatively

Upsampling multiplies whatever is in the corpus, including its defects. Three interactions matter most:

If you sample a language twelve times as often and sample uniformly within it, mislabeled examples from that language also appear twelve times as often in expectation. A 2% mislabel rate within the language stays at 2%. The increase is in the mislabeled examples' share of the overall mixture. Their contribution to the gradient also depends on the gradients of those examples.

  • Language identification errors. Caswell et al. found that many examples in some lower-resource web-crawl language buckets were written in a different language. With the same within-language sampler, sampling the bucket twelve times as often also multiplies the expected count of mislabeled draws in that bucket by twelve.
  • Quality thresholds. CCNet uses per-language language models and splits documents into three within-language perplexity groups. Those groups rank relative perplexity for a given language. Check per-language retention if you use a global threshold. Wenzek et al. (2020), section 3.4
  • Deduplication thresholds. Run a duplicate audit at the scale of each language, using both raw and surviving document counts. Look for templates that still dominate the retained material.

Reweighting a fixed bucket with uniform within-language draws increases exposure to each kept item, including defects. Pair the effective-epochs check with a sample-based quality audit for the languages whose draws increase.

All three are covered in more depth in Quality Filtering and Deduplication. The reason to raise them here is that a mixture decision is partly a data-cleaning decision: the more you upweight a language, the higher the quality bar it needs to clear.

A practical implication: before increasing a language's multiplier or lowering α\alpha globally, run the quality metrics for the languages that will gain the most. If their mislabeled rate or duplicate rate is high, fix that first. Otherwise you are paying to amplify noise.

Learned mixtures

Hand-tuned α\alpha and sis_i are the baseline. DoReMi uses a small proxy model and group DRO to learn domain weights using excess loss. Ye et al. fit loss as a function of domain-mixture proportions and optimize the resulting curve. Their experiments concern domain mixing. A per-language multiplier can express preferences a single exponent cannot, such as giving distinct shares to languages with the same natural share. Xie et al. (2023) · Ye et al. (2024 preprint)

A proxy gives you a way to search for weights under a stated objective. Compare the candidates with a baseline under that objective before testing them at target scale.

Validate learned weights at the scale of the intended model. If the objective weights one language lightly, verify that the selected mixture still meets its evaluation targets or minimum-coverage requirements.

A small proxy can prioritize a different mixture from the final model. To check transfer, compare the learned mixture against a baseline in a shorter target-scale run and report which languages gain or lose.

Choose objective weights to reflect which outcomes matter. A language-uniform average, a worst-language criterion, and a corpus-weighted average assign different importance to the same per-language scores. You can also impose minimum language shares.

Comments

Add to the conversation

A question, a correction, or an example from your own work.

No comments yet. Be the first to share your thoughts!

Newsletter

Stay up to date

Get new articles, book updates, and notes on AI and technology.

Unsubscribe at any time. Privacy policy