Sub topic 3
Translate-train, translate-test and few-shot target data
This chapter assumes you can fine-tune a pretrained transformer for classification, read accuracy and F1, and explain zero-shot transfer. Few-shot means training with a small number of labeled examples in the target language.
Translate-train, translate-test and few-shot target data
Translate-train machine-translates the labeled source training set into each target language, then fine-tunes on those translations. It usually scores highest when translation quality is good, but it costs translation compute and inherits translation errors.
Translate-test machine-translates each target-language input into the source language and runs a source-trained model. It needs only one model, but every prediction depends on translation quality.
Few-shot adds a handful of labeled target-language examples to the source data. It is often the cheapest way to close a gap when a few labels are available.
Unequal data and temperature-based language sampling
Pretraining corpora are skewed. English may have far more text than Swahili. Proportional sampling starves small languages, while uniform sampling overfits them. Temperature-based sampling sets each language weight to (n_i / N)^α, then normalizes. A value of α = 0.3 is a common choice, and smaller α flattens the distribution toward uniform.
def sampling_probs(sizes, alpha=0.3):
total = sum(sizes.values())
weights = {lang: (n / total) ** alpha for lang, n in sizes.items()}
norm = sum(weights.values())
return {lang: round(w / norm, 3) for lang, w in weights.items()}
print(sampling_probs({"en": 1_000_000, "sw": 10_000}))The curse of multilinguality
Adding languages to a fixed-size model helps until capacity runs out. Languages compete for the same parameters, so accuracy on high-resource languages often drops as more languages are added.
Multilingual sentence embeddings and cross-lingual retrieval
Sentence encoders trained on translation or paraphrase pairs map sentences with the same meaning to nearby vectors in any covered language. You can rank French documents by cosine similarity to an English query without a translation step.
Language adapters and parameter-efficient adaptation
A language adapter is a small bottleneck module added to each layer. You train it for one language while the base model stays frozen. Each language then adds a few million parameters instead of a full model copy, and adapters reduce interference between languages.
Multilingual generative models and prompting across languages
Generative models such as mT5 and BLOOM can be prompted in many languages. Test prompts written in the task language and in English, because results differ. Target-language few-shot examples usually help most.
Limitations: tokenization disparity, low-resource gaps and fairness
Shared vocabularies split some scripts into many more tokens. A sentence in a poorly represented language can cost several times more tokens than its English equivalent, which raises inference cost and shrinks the usable context. Report per-language scores rather than one average so gaps stay visible.
Exercise
Exercise
Using the sampling function above with α = 0.3, English has 1,000,000 sentences and Swahili has 10,000. Is Swahili sampled more or less often than under proportional sampling? Roughly what share of batches does it receive?
Show answer
More often. Proportional sampling gives Swahili about 1% of batches (10,000 of 1,010,000). With α = 0.3, it gets roughly 20% of batches, because the flattening raises small-language weights.