Sub topic 7
Measuring Transfer: XNLI, XTREME and Per-Language Reporting
This chapter assumes that you understand Transformer encoders, masked language modeling, fine-tuning, and basic metrics such as accuracy and F1. The focus here is not how to train a multilingual model. It is how to measure whether knowledge transfers from a training language to other languages.
What a cross-lingual evaluation measures
A cross-lingual experiment separates the language used for fine-tuning from the language used for testing.
For example, fine-tune XLM-R on English natural language inference data. Then evaluate the same model on English, German, and Swahili test sets without updating its weights. Performance on German and Swahili estimates zero-shot transfer.
The English result is a source-language baseline. The other results are target-language results. A lower target score can come from several causes:
- The model learned English-specific shortcuts.
- The languages differ in grammar, vocabulary, or writing system.
- The target language had little pretraining data.
- Tokenization represents target text inefficiently.
- The benchmark translations or labels contain noise.
A single average hides these differences. Always report every language result.
XNLI: a focused transfer benchmark
XNLI tests cross-lingual natural language inference. Each example contains a premise and a hypothesis. The model predicts one of three labels:
- Entailment: the premise supports the hypothesis.
- Contradiction: the premise conflicts with the hypothesis.
- Neutral: the premise does not determine the hypothesis.
XNLI provides comparable evaluation data across multiple languages. A common setup fine-tunes on English training data and evaluates on the English and translated test sets.
Accuracy is often used because the three classes are intended to be balanced. Still, inspect the class distribution and report macro F1 when the distribution is uneven.
| Result | Meaning |
|---|---|
| English accuracy | Source-language performance |
| German accuracy | Zero-shot transfer to German |
| Swahili accuracy | Zero-shot transfer to Swahili |
| Target average | Mean across selected target languages |
| Transfer gap | Source score minus target score |
The transfer gap is useful, but it is not a complete diagnosis. A small gap may reflect strong transfer, similar data conditions, or an easy test set.
XTREME: broader multilingual evaluation
XNLI measures one task. XTREME evaluates multilingual transfer across several task types, including sentence classification, named entity recognition, question answering, structured prediction, and cross-lingual retrieval.
This breadth matters because transfer can succeed for one task and fail for another. A model may align sentence meanings well but struggle with token-level entity boundaries. Benchmark scores are therefore task-specific. Do not compare an F1 score from named entity recognition directly with an accuracy score from classification.
When using XTREME or a related benchmark:
- Record the exact benchmark version and task.
- Report the language set.
- Keep preprocessing and label mappings fixed.
- Report results by language before computing an aggregate.
- State whether the model used zero-shot, few-shot, or translated data.
Per-language reporting
Use a macro average when each language should contribute equally:
average = (score for language 1 + ... + score for language n) / n
A macro average is different from a micro average, which pools all examples first. Micro averages favor languages with more test examples. Macro averages make low-resource languages visible.
from statistics import mean
scores = {
"en": 0.84,
"de": 0.76,
"sw": 0.61,
}
source_score = scores["en"]
target_scores = [score for lang, score in scores.items() if lang != "en"]
print("macro target average:", round(mean(target_scores), 3))
print("English-to-target gap:", round(source_score - mean(target_scores), 3))
for language, score in scores.items():
print(f"{language}: {score:.3f}")Also report variation, such as the minimum and maximum target score. A model with an average of 0.75 may have balanced performance, or it may score 0.90 on one language and 0.60 on another.
A reliable evaluation workflow
Keep the evaluation conditions identical across languages where possible. Use the same model checkpoint, maximum sequence length, decoding or classification procedure, and metric implementation. Otherwise, score differences may reflect the experiment rather than language transfer.
Exercise
A model scores 0.82 on English, 0.74 on German, and 0.50 on Swahili. What should you report besides the overall average?
Show answer
Report each language score, the macro target average of 0.62, the English-to-target gap of 0.20, and the large language-specific difference between German and Swahili.