EPFL's ConLID Rescues 2,099 Languages Disappearing From AI Training Data
EPFL researchers apply supervised contrastive learning to language identification, gaining 3.2 points on low-resource languages without hurting high-resource ones
ProTakeaways
- ConLID is a new language identification model from EPFL that applies supervised contrastive learning to improve accuracy on low-resource languages by 3.2 percentage points.
- The core problem: most low-resource languages have training data from only one domain (typically Bible translations), causing models to fail on real-world web text.
- ConLID uses a memory bank to scale contrastive learning across 2,099 language classes, and hard negative mining to force domain-invariant representations.
- Languages with diverse training domains gain up to 5.4 percentage points; script-level gains reach +10.9 points for Javanese and +6.8 for Arabic-script languages.
- Ensembling ConLID-S with existing GlotLID-M achieves the best results on both FLORES-200 and UDHR benchmarks, suggesting the methods are complementary.
- Code and model weights are publicly available; the paper is on arXiv.
Every multilingual LLM starts with a web crawl. Before a single token is trained, billions of documents need to be sorted by language -- a step called language identification (LID). Get it wrong for low-resource languages, and those communities simply disappear from the training data. A team from EPFL and UT Austin is now proposing a smarter way to do that sorting, with a paper introducing ConLID, a supervised contrastive learning approach to LID that specifically targets the domain-generalization failures plaguing low-resource languages.
The Bible problem
Language identification is a critical step in curating multilingual LLM pretraining corpora from web crawls. The challenge sounds deceptively simple: given a piece of text, say what language it is. For English, French, or Mandarin, this is essentially solved. For low-resource languages, the situation is different -- they are often limited to single-domain data, such as the Bible, and continue to perform poorly.
That single-domain constraint is the crux of the problem. A model trained exclusively on Bible translations for a language like Chimborazo Highland Quichua learns to recognize that style of text -- archaic, formal, translated from Hebrew and Greek. When it then encounters a web page, a chat log, or a government document in the same language, it fails. Models tend to exhibit improved generalization in languages for which they had more diverse training domains, and generalize worse on languages for which training data was only available in one domain.
The scale of the imbalance is striking. Of the 2,099 languages in the training dataset, most languages contain either exclusively or inclusively Bible data. That is not a niche edge case -- it is the default condition for the majority of the world's languages in NLP.
Why standard training fails here
Current LID systems -- including the widely-used GlotLID-M -- are built on FastText, a lightweight model trained with standard cross-entropy loss. Cross-entropy is great at memorizing patterns in whatever data it sees, but it does not explicitly encourage the model to learn what makes a language a language across different contexts. It learns "this looks like Quechua Bible text" rather than "this is Quechua."
Supervised contrastive learning (SCL) is a training technique that changes this objective. Instead of just predicting the right label, SCL also pushes the model to make the representations of same-language text cluster together in embedding space, while pushing different-language text apart. The result is a model that has internalized a more robust notion of what each language looks like -- one that generalizes beyond the training domain.
The catch: SCL's effectiveness scales with batch diversity. You need many different languages in each training batch to get useful positive and negative pairs. With 2,099 language classes, fitting enough examples of each language into a single GPU batch is infeasible. The team solves this with a memory bank -- a rolling buffer of recent examples that each batch can draw contrasting pairs from, effectively expanding the pool without blowing up memory requirements.
Hard negatives: the key design choice
The paper introduces two variants of ConLID, and the difference between them reveals the core insight. The simpler variant (ConLID-S) uses soft negative selection: any text from a different language counts as a negative example. The harder variant (ConLID-H) uses domain-aware hard negative mining:
- For each training sample, the model preferentially selects negatives from the same domain and same script but a different language
- If not enough such negatives exist, it relaxes the constraint progressively: same script only, then same domain only, then any different language
- This forces the model to learn what distinguishes, say, two Latin-script African languages in the same religious text domain -- the hardest possible discrimination
The intuition is sound: if your model can tell apart two closely related languages when they are both writing about the same topic in the same script, it has genuinely learned language-specific features rather than domain shortcuts.
What the numbers show
The team evaluates on three benchmarks: GlotLID-C-test (2,099 languages, in-domain), FLORES-200 (199 languages, out-of-domain), and UDHR -- the Universal Declaration of Human Rights translated into 360 languages, which serves as the primary out-of-domain test since it is not in the training data.
The best SCL-based approaches achieve a 3.2 percentage point improvement over cross-entropy-based models for low-resource languages, and a 5.4 percentage point improvement for languages with data from diverse domains, indicating enhanced domain generalization. High-resource languages are essentially unaffected, gaining only 0.66 percentage points.
The gains are even sharper when broken down by training domain. For languages trained exclusively on random-domain data (machine translation datasets, chat logs, web-scraped text), ConLID-S achieves improvements of up to 5.41 percentage points. For Bible-only languages the gain is more modest at 1.9 points -- still positive, but the narrower domain leaves less room for contrastive learning to exploit diversity.
The team also tested an ensemble approach, combining ConLID-S predictions with those from the existing GlotLID-M model by summing their predicted distributions. This ensemble, GlotLID-M+ConLID-S, achieves the best scores across both UDHR and FLORES-200, suggesting the two methods are genuinely complementary -- the contrastive model catches cases the cross-entropy model misses, and vice versa.
Script-level surprises
One of the more interesting findings emerges from the script-level analysis. The gains are not uniform across writing systems:
- Javanese script: +10.9 F1 points -- the largest single-script gain
- Arabic script: +6.8 F1 points, driven almost entirely by low-resource Arabic-script languages (low-resource Arabic languages alone gain +28.2 points)
- Latin script: modest +0.9 points overall, reflecting that most Latin-script languages are already high-resource
- Cyrillic and Hani scripts: near-zero gains, consistent with those scripts being dominated by high-resource languages
The pattern is consistent: SCL helps most where training data is scarce and domain-narrow. Where data is already abundant and diverse, cross-entropy is already doing a good job.
Where it still struggles
The paper is candid about failure modes. Among the 3,448 misclassifications in the UDHR dataset, 99.6% occur within the same script, while only 0.4% involve different scripts. The model's remaining errors are almost entirely cases of closely related languages being confused with each other -- Chimborazo Highland Quichua misclassified as Southern Pastaza Quechua, Croatian confused with Serbo-Croatian, Hakka Chinese confused with Wu Chinese. These are linguistically adjacent pairs that even human annotators sometimes struggle to distinguish from text alone.
There is also a data limitation: while the training and in-domain test datasets encompass 2,099 languages, the out-of-domain evaluation dataset (UDHR) is limited to only 360 languages, leaving the majority of languages without a rigorous out-of-domain evaluation.
Real-world stakes
To ground the work in practice, the authors evaluate ConLID-S on FineWeb-2, a corpus covering 1,868 language-script pairs with substantial corpora for over 1,000 languages, comprising 20 TB and over 5 billion documents. When comparing ConLID-S against GlotLID-M on FineWeb-2's low-resource language subset, the two models disagree on roughly 41% of documents -- a gap that directly translates to different amounts of training data being assigned to those languages.
The authors note that even a 1% improvement in low-resource language identification accuracy corresponds to roughly 28,000 documents in that corpus. At the scale of modern pretraining pipelines, better LID is not a preprocessing footnote -- it determines which languages get represented at all.
Code and models
The ConLID code and model weights are publicly available. The architecture stays lightweight: it follows the same FastText-style character n-gram and word embedding approach as GlotLID-M, making it a practical drop-in for existing pipelines. The main addition is the SCL training objective and memory bank, which run on 8 A100 GPUs for a single epoch over 62M sentences.
For teams building multilingual pretraining datasets or evaluating LID quality on low-resource languages, ConLID offers a concrete improvement with no tradeoff on high-resource performance. The ensemble with GlotLID-M is probably the most practical starting point -- it captures the best of both training objectives and is straightforward to implement at inference time.