Multilingual Pre-training and Data Balancing › A Toy Model of Transfer-Interference
Language AI HandbookAll chapters Sampling shares do not tell you what happens to accuracy. To see the trade-off, we need a model with shared capacity. The smallest one that exhibits interference is a single linear map trained on data from several languages whose optimal maps differ slightly.
The toy is deliberately minimal. It strips away tokenization, optimization, and architecture, and keeps only the part of the problem that produces interference: multiple languages with different optima sharing one set of weights. If the trade-off appears here, it is not an artifact of scale or training instability; it is a property of sharing.
Let language have optimum (we drop the shared component because it cancels out of the risk expression below), and let inputs satisfy . A model must choose one weight vector for all languages. Under mixture , the population objective is
The identity raw second moment gives each language an isotropic squared-distance penalty. If all languages share an invertible second moment , the normal equations cancel and the weighted mean still holds. For different per-language moments , the equation becomes .
A shared fit must compromise when the participating languages have distinct unique optima. With singular moments, the minimizing sets can intersect. If one language constrains only the first coordinate and another only the second, the shared vector can satisfy both. For the identity case used in this toy, set the gradient to zero:
The result is worth pausing on. The model does not learn a compromise that is equally bad for everyone; it learns the mixture-weighted average of the optima. Languages whose optima are close to that average are well served. Languages whose optima are far from it are poorly served, and the farther they are, the worse the quadratic penalty. This is why interference is not uniform: it falls hardest on the languages that are most different from the weighted consensus.
The model learns the mixture-weighted average of the per-language optima. Its risk on language is therefore
Here is a common noise floor. The toy assumes known optima and fits one shared point, so it omits estimation error from finite samples and any positive transfer between languages.
With the other languages kept in fixed relative proportions, the shared optimum follows the segment from their weighted centroid toward the target language’s optimum as its share rises. The target’s squared-distance loss decreases if those points differ and stays constant if they coincide. If several relative shares change simultaneously, check how the shared point actually moves.
A fuller model could add a term for estimation error that declines with exposure. An interior optimum then depends on the shape of that term and the interference loss. For example, for one share variable between zero and one, adding to gives an interior minimum.
PythonIn [21]Expand
n_lang = len(languages)
dim = 8
# Synthetic scale factors for the language-specific deviations.
distance = np.array([0.4, 0.5, 0.6, 0.9, 0.8, 1.4, 1.6, 1.5])
delta = rng.normal(0, 1, (n_lang, dim)) * distance[:, None]
sigma2 = 0.25
def interference_risk(p, alpha, delta, sigma2):
"""Per-language risk when a shared linear model is trained on mixture q."""
q = temperature_mixture(p, alpha)
w_star = q @ delta
return ((delta - w_star) ** 2).sum(axis=1) + sigma2
alpha_grid = np.linspace(0.0, 1.0, 51)
R = np.array([interference_risk(p, a, delta, sigma2) for a in alpha_grid])
macro = R.mean(axis=1) # every language weighted equally
micro = R @ p # weighted by natural corpus shareThe distance vector scales the random deviations in the fixture. The scales are synthetic. The realized distances from the shared optimum depend on the random directions and the mixture. The common noise floor shifts every risk by the same amount.
The macro average weights each language equally. The micro average in this fixture weights by natural corpus share. Use an independently measured user distribution if you want an average-user metric. The next printout gives the grid minimum for each of the two plotted objectives.
PythonIn [22]Expand
print(f"alpha minimising micro average: {alpha_grid[np.argmin(micro)]:.2f}")
print(f"alpha minimising macro average: {alpha_grid[np.argmin(macro)]:.2f}")
print(
f"risk at alpha=1.0 -> micro {micro[np.argmin(np.abs(alpha_grid - 1.0))]:.3f}, "
f"macro {macro[np.argmin(np.abs(alpha_grid - 1.0))]:.3f}"
)
print(
f"risk at alpha=0.3 -> micro {micro[np.argmin(np.abs(alpha_grid - 0.3))]:.3f}, "
f"macro {macro[np.argmin(np.abs(alpha_grid - 0.3))]:.3f}"
)
print(f"risk at alpha=0.0 -> micro {micro[0]:.3f}, macro {macro[0]:.3f}")
alpha03_index = np.argmin(np.abs(alpha_grid - 0.3))
for objective, risks in (("Micro", micro), ("Macro", macro)):
minimum = risks.min()
excess = risks[alpha03_index] - minimum
print(
f"{objective} excess at alpha=0.3: {excess:.3f} ({excess / minimum:.1%})"
)ConsoleOut [22]Expand
alpha minimising micro average: 1.00 alpha minimising macro average: 0.00 risk at alpha=1.0 -> micro 1.729, macro 7.252 risk at alpha=0.3 -> micro 1.873, macro 6.896 risk at alpha=0.0 -> micro 2.246, macro 6.735 Micro excess at alpha=0.3: 0.144 (8.3%) Macro excess at alpha=0.3: 0.161 (2.4%)
Weighted least squares minimizes the risk measured with its own weights. Here gives a micro-risk minimizer because the fit uses natural corpus shares. Setting gives a macro-risk minimizer because the fit gives every language equal weight.
In this seeded fixture, the intermediate exponents on the grid have higher micro risk than the micro minimum and higher macro risk than the macro minimum. The general least-squares result allows ties. If the two weighted means coincide, both objectives can share a minimizer.
At in this fixture, the micro risk exceeds its own minimum at by 0.144 MSE, about 8.3%. The macro risk exceeds its own minimum at by 0.161 MSE, about 2.4%. The percentages divide each excess by that objective’s own minimum.
Figure @fig-per-language-risk shows why the compromise is not a simple "everyone moves together."
VisualizationOut [23]Expand

As decreases from 1 to 0, English and Chinese risk rise throughout the sweep. Spanish risk first falls and then rises, with a grid minimum at . The shared fit can pass closer to a language's optimum at an intermediate mixture. Welsh and Yoruba each end with lower risk than they started with, despite a brief rise near . Report per-language validation results alongside the aggregate so you can spot these different responses.
The aggregate view is Figure @fig-macro-micro.
VisualizationOut [24]Expand

On this fixture’s grid, as increases from 0 to 1, corpus-weighted risk falls from 2.25 to 1.73 and language-uniform risk rises from 6.73 to 7.25. At , the objectives are about 1.87 and 6.90, respectively. Compare movements along each curve to judge the effect of a mixture change.
The two controls in this fixture are the synthetic deviation scales and the common noise floor. For a transfer experiment, compare whether access to a donor language improves held-out outcomes in the target language.
Compare real sweeps against their own controls. With three different optima, a language’s share can rise while a redistribution of the other weights moves the shared point away from that language. Log the other shares before attributing a tail regression to data quality or tokenization.
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!