ConLID: Supervised Contrastive Learning for Low-Resource Language Identification

Negar Foroutan, Jakhongir Saydaliev, Grace Kim, Antoine Bosselut

TL;DR

ConLID introduces a supervised contrastive learning (SCL) framework to solve "domain entanglement" in language identification (LID). By forcing the model to learn language-specific features rather than domain-specific ones (like the style of religious texts), it achieves a 3.2 percentage point F1-score improvement on out-of-domain data for low-resource languages while scaling to over 2,000 languages.

What Problem Does This Paper Address?

Language Identification (LID) is the essential first step in building massive multilingual datasets for LLMs. If the LID model fails, the resulting training data is noisy or missing entire languages.

The core challenge for low-resource languages is domain entanglement. Because training data for these languages is scarce, it often comes from a single source—most commonly the Bible. Standard models trained with cross-entropy loss often "cheat" by learning the stylistic features of the domain (e.g., archaic religious phrasing) rather than the actual linguistic features of the language. Consequently, when these models encounter the same language in a different context (like a web crawl or a news article), they fail to recognize it.

Methods

The authors propose ConLID, which augments a standard FastText-style architecture (efficient character n-gram embeddings) with a dual-objective loss function.

  1. Dual Loss: The model is trained using both standard Cross-Entropy (CE) loss and Supervised Contrastive Learning (SCL) loss. The SCL loss explicitly pulls representations of the same language closer together in the embedding space while pushing different languages further apart.
  2. Memory Bank: Contrastive learning usually requires massive batch sizes to be effective. Since ConLID targets over 2,000 languages, a standard GPU batch is too small to contain enough positive/negative pairs. The authors implement a memory bank that stores the last 2,048 embeddings, effectively expanding the "view" of the model during training without increasing memory overhead.
  3. Hard Negative Mining: To break domain entanglement, the authors use a novel sampling strategy. They specifically pick "hard negatives"—examples that are from a different language but the same domain or script. This forces the model to ignore the domain-specific "noise" and focus on the unique linguistic signal.

Datasets

  • Training: GlotLID-C, covering 2,099 languages. The authors down-sampled high-resource languages to 100k sentences to mitigate class imbalance.
  • Evaluation (Out-of-Domain):
    • UDHR (Universal Declaration of Human Rights): 360 languages.
  • FLORES-200: 199 languages.
  • Real-World Application: FineWeb-2, a large-scale multilingual web-crawled corpus (~1,800 languages), used to test the model's scalability and agreement with existing SOTA tools.

Key Insights and Ideas

  • Scaling Contrastive Learning: Most SCL research focuses on datasets with fewer than 10 classes. This paper proves that SCL can be successfully scaled to 2,000+ classes in NLP using a memory bank approach.
  • Generalization via Contrast: The "aha moment" is that contrastive learning isn't just about better features; it's a tool for de-biasing. By contrasting a low-resource language against other languages in the same domain (e.g., comparing a Yoruba Bible verse against an Igbo Bible verse), the model learns that "Bible-ness" is a shared trait to be ignored, while the language itself is the discriminative factor.
  • The "Bible" Bottleneck: The paper quantifies the "Bible effect." Languages trained exclusively on religious texts see the most significant gains from ConLID, confirming that domain entanglement is indeed the primary barrier to low-resource LID.

Key Results

  • OOD Performance: ConLID-S achieved a 3.2 percentage point F1-score gain over the cross-entropy baseline for low-resource languages on the UDHR dataset.
  • Diverse Domain Gains: For languages with data from more diverse domains (the "Random" category in their analysis), the improvement was even higher, reaching 5.4 percentage points.
  • Stability: Importantly, the model maintained its high performance on high-resource languages, proving that the contrastive objective doesn't come at the cost of general accuracy.
  • Real-world Impact: On the FineWeb-2 dataset, the authors found that even a 1% improvement in low-resource LID accuracy translates to correctly identifying approximately 28,000 additional documents, highlighting the massive scale of the impact.

Limitations and Future Work

  • Evaluation Gap: While the model supports 2,000+ languages, high-quality out-of-domain evaluation sets (like UDHR) only exist for about 360 of them. The performance on the remaining ~1,700 languages remains difficult to verify rigorously.
  • Label Noise: SCL is sensitive to label quality. If the underlying training data (GlotLID-C) contains mislabeled examples, the contrastive objective might inadvertently reinforce those errors.
  • Future Directions: The authors suggest expanding evaluation to more diverse domains beyond the Bible and legal texts and investigating how to better handle "UND" (undefined/unknown) labels in web-scale data.

Summary updated

BibTeX
@inproceedings{foroutan2026conlid,
  author = {Negar Foroutan and Jakhongir Saydaliev and Grace Kim and Antoine Bosselut},
  title = {{ConLID: Supervised Contrastive Learning for Low-Resource Language Identification}},
  booktitle = {EACL (Volume 1: Long Papers)},
  year = {2026},
  doi = {10.18653/v1/2026.eacl-long.315},
}
Figure