- Introduced by
- Devlin et al. (mBERT); Conneau et al. (XLM-R)
- Year
- 2019–2020
- Type
- Pre-trained cross-lingual language model
- Family
- Deep learning / NLP / CV
What does it do?
A multilingual transformer is a pre-trained language model built on the transformer architecture and trained jointly on text from dozens to over one hundred languages.
Models such as mBERT and XLM-RoBERTa learn representations shared across languages, so a model fine-tuned on labelled data in one language can often be applied to others, such as French, German, Arabic, or Chinese, without language-specific labels. Performance on a given target language depends on how well that language is covered in pre-training.
The intuition behind the method
One way to picture a multilingual transformer is as a single encoder trained on text from many languages at once, so its internal representations are shaped by all of them rather than by one. When the model is later fine-tuned for a task such as sentiment classification in one language, the learned task behaviour sits on a representation space that already places some meanings from other languages nearby. That is why a classifier trained on English examples can sometimes handle German input reasonably well. The alignment is not produced by explicit translation rules; it emerges from joint pre-training with a shared vocabulary, and its strength varies by language and by how much each language appears in the pre-training corpus.
History
Multilingual BERT (mBERT) was released by Google in 2018 alongside the original BERT model. It was pre-trained on Wikipedia text from 104 languages. XLM-RoBERTa (Conneau et al., 2020) extended multilingual pre-training to 100 languages using 2.5 TB of Common Crawl data, and reported strong cross-lingual results on understanding benchmarks.
When to use it
Choose a multilingual transformer when your input contains several languages, when labelled data exists for some languages but not others, or when one deployed model must serve multilingual input. It suits cross-lingual transfer on tasks such as classification, token-level tagging (NER), and question answering, where a source-language training set can be reused for target languages. Do not choose it when the task involves a single high-resource language with ample labelled data; a monolingual model trained on that language is usually the stronger option. Also avoid it when memory or latency budgets are tight, since large multilingual checkpoints are resource-intensive.
Limitations and considerations
- Capacity sharing: per-language accuracy often falls below that of a monolingual model trained on the same language, because one set of parameters must represent many languages. This is commonly called the multilingual curse.
- Large checkpoints, with parameter counts in the hundreds of millions to billions, need substantial GPU memory for both fine-tuning and inference.
- Languages that are rare in the pre-training corpus receive weaker representations, so zero-shot results can be poor for them even on simple tasks.
- A fixed shared vocabulary can split morphologically rich or non-Latin-script words into many short pieces, which may weaken representations for those languages.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Zero-shot and few-shot transfer: a model fine-tuned on labelled data in one language can be applied to other languages without labels in those languages.
- One shared encoder and vocabulary serve many languages, so a single checkpoint can be deployed and maintained instead of one model per language.
- Languages with little labelled data can benefit from representations learned from related, better-resourced languages in the same pre-training corpus.
- Pretrained checkpoints for mBERT, XLM-R, and mT5 are available in Hugging Face Transformers, which lowers the cost of starting a project.
- Because the tokenizer is shared, the same fine-tuning pipeline can be reused across supported languages without a separate tokenizer for each.
Applications
- Multilingual text classification (sentiment, topic, intent) with a single model across many languages.
- Cross-lingual named entity recognition in domains such as biomedical, financial, or legal text.
- Multilingual question answering and reading comprehension over diverse corpora.
- Zero-shot transfer to low-resource languages for tasks where labelled data is unavailable.
- Cross-lingual semantic similarity and document retrieval.
How it works
How it works
A single subword vocabulary, built with SentencePiece or WordPiece over all supported languages, is used for every input. Because the same subword units appear across languages, the tokenizer can represent related words and shared script elements with common tokens. This is one plausible contributor to cross-lingual transfer rather than a guaranteed one.
The encoder is pre-trained on a large multilingual corpus, such as Common Crawl or Wikipedia text in 100+ languages, using a self-supervised objective. Masked language modelling predicts hidden tokens from their context. Through this phase the model learns representations that are shared, to varying degrees, across languages.
Input text in any supported language is tokenised with the shared vocabulary and passed through the transformer encoder. Multi-head self-attention lets each token attend to every other token in the input, and the same network produces the contextual embeddings for every language.
A lightweight classification, extraction, or generation head is attached on top of the pre-trained encoder. For classification, the representation of the special [CLS] token is projected to the target label space; for token-level tasks such as NER, each token representation is projected separately.
The encoder and task head are fine-tuned end-to-end on labelled data, usually in one or more source languages, using a standard cross-entropy loss for classification. The fine-tuned model can then be evaluated on target languages without target-language labels (zero-shot), or after adding a small amount of target-language labelled data (few-shot). Transfer quality is specific to each language and task and should be measured rather than assumed.
Common pitfalls
- Expecting zero-shot results to match supervised results. Check performance on held-out labelled target-language data before deployment, because transfer quality varies by language and task.
- Leaving out available target-language data during fine-tuning. Mixing some target-language examples into fine-tuning often improves results for that language, so skipping them forgoes a cheap gain.
- Using a learning rate that is too high during fine-tuning, which can overwrite the pre-trained multilingual representations. A more conservative learning rate, checked on held-out data, reduces this risk.
- Assuming a language is well covered by the checkpoint. Inspect the pre-training language distribution for your language before relying on the model.
- Treating the model as a translator. It produces language-independent representations and task labels, not translated text.
- Assuming per-language quality is uniform. Quality tracks the amount and quality of each language's text in pre-training, so errors may fall unevenly across languages and disadvantage low-resource ones. Run a per-language error analysis before deployment.
- Expecting reliable handling of mixed-language input. Code-switched or mixed-script text may be handled less reliably than single-language text, so test it separately if your data contains it.
Frequently asked questions
Is a multilingual transformer the same as a machine translation model?
No. A multilingual transformer learns shared representations across languages but does not translate text. It produces language-specific outputs (e.g., a classification label) that are informed by cross-lingual understanding, whereas a translation model generates text in a target language.
Which pretrained checkpoint should I start with?
XLM-RoBERTa-large is a strong general-purpose starting point for most NLP tasks. For tasks requiring generation or translation, mT5 is a good alternative. For very constrained compute budgets, XLM-RoBERTa-base offers a reasonable trade-off.
How much fine-tuning data do I need?
No fixed amount applies. A small labelled set in a source language can support zero-shot transfer to related languages, and adding a modest amount of target-language labelled data is usually worth testing because it often improves results. Measure the gain on a held-out target-language set to decide how much annotation is justified.
What is the multilingual curse and how can I mitigate it?
The multilingual curse refers to the pattern in which sharing model capacity across many languages lowers per-language performance compared with a monolingual model. Common mitigations include using a larger checkpoint, fine-tuning on target-language data when it is available, and language-adaptive fine-tuning (LAFT), which continues pre-training on unlabelled target-language text before task fine-tuning.
Can I use a multilingual transformer for non-European languages?
Yes. Models like XLM-RoBERTa cover Arabic, Chinese, Japanese, Korean, Hindi, Swahili, and many others. However, coverage and quality vary: inspect the pre-training language distribution for your specific language before relying on the model.
Related methods
Sources
Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2019). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. Proceedings of NAACL-HLT 2019, pp. 4171–4186. Association for Computational Linguistics.
Open DOI referenceConneau, A., Khandelwal, K., Goyal, N., Chaudhary, V., Wenzek, G., Guzmán, F., Grave, E., Ott, M., Zettlemoyer, L., & Stoyanov, V. (2020). Unsupervised Cross-lingual Representation Learning at Scale. Proceedings of ACL 2020, pp. 8440–8451. Association for Computational Linguistics.
Open DOI reference