Contrastive Learning for Universal Zero-Shot NLI with Cross-Lingual Sentence Embeddings

Md. Kowsher, Md. Shohanur Islam Sobuj, Nusrat Jahan Prottasha, Mohammad Shamsul Arefin, Yasuhiko Morimoto2023

Abstract

Natural Language Inference (NLI) is a crucial task in natural language processing, involving the classification of sentence pairs into entailment, contradiction, or neutral categories. This paper introduces a novel approach to achieve universal zero-shot NLI by employing contrastive learning with cross-lingual sentence embeddings. We utilize a large-scale pretrained multilingual language model trained on NLI data from 15 diverse languages, enabling our approach to achieve zero-shot performance across other unseen languages during the training, including low-resource ones. Our method incorporates a Siamese network-based contrastive learning framework to establish semantic relationships among similar sentences in the 15 languages. By training the zero-shot NLI model using contrastive training on this multilingual data, it effectively captures meaningful semantic relationships. Leveraging the fine-tuned language model's zero-shot learning capabilities, our approach extends the zero-shot capability to additional languages within the multilingual model. Experimental results demonstrate the effectiveness of our approach in achieving universal zero-shot NLI across diverse languages, including those with limited resources. We showcase our method's ability to handle previously unseen low-resource language data within the multilingual model, highlighting its practical applicability and broad language coverage.

Introduction

Natural Language Inference (NLI)—the ability to determine if one sentence entails, contradicts, or is neutral toward another—is a cornerstone of language understanding. However, most NLI models suffer from a "language bottleneck." They perform exceptionally well in English or the handful of high-resource languages they were trained on, but fail when applied to the thousands of other languages spoken globally. Collecting labeled NLI data for every language is prohibitively expensive. This research addresses the "zero-shot" challenge: training a model on a limited set of languages such that it can accurately perform NLI on completely "unseen" languages without additional training data.

Methodology

The proposed framework moves beyond simple classification by focusing on semantic alignment across languages.

Base Models and Architecture

The approach utilizes powerful pre-trained multilingual models such as XLM-RoBERTa-large and mDeBERTa-v3 as backbones. A Siamese network structure is employed where multiple encoders share weights, mapping sentence pairs into a shared semantic space.

Siamese network architecture for contrastive learning and semantic alignment.

Contrastive Learning Objective

Training incorporates a dual-loss objective, combining standard Cross-Entropy loss for classification with Contrastive Learning (Triplet Loss). The model is trained to minimize the distance between "anchor" sentences and "positive" samples (semantically similar sentences in different languages) while maximizing the distance to "negative" samples. To enhance robustness, a clustering approach identifies "hard negatives"—sentences that are semantically distant but potentially confusing—ensuring the model learns clear boundaries between categories.

Experimental Setup

The model was trained on the XNLI dataset, which includes NLI pairs in 15 diverse languages (e.g., Arabic, Bulgarian, Greek, Hindi, Swahili, and Urdu). To evaluate "universal" performance, the model was tested on datasets in languages not seen during NLI training, including DKHate (Danish), MARC-ja (Japanese), Kor-3i4k (Korean), Id-clickbait (Indonesian), MCT4 (Bengali), and ToLD-br (Brazilian Portuguese).

Results and Discussion

The proposed models, denoted as XLM-RoBERTa and mDeBERTa-v3, consistently outperformed standard multilingual baselines across various tasks and languages.

Performance comparison across diverse datasets for unseen and seen languages.

Key findings include:

  • Zero-Shot Superiority: On the Indonesian clickbait dataset, the proposed XLM-RoBERTa* achieved an F1-score of 0.79, significantly higher than the 0.73 achieved by the vanilla version.
  • Closing the Language Gap: In several instances, the zero-shot model performed comparably to models explicitly trained on those specific languages. For example, on the Japanese MARC-ja dataset, the model achieved 82% accuracy, rivaling specialized local models.
  • Low-Resource Resilience: Significant gains were observed in languages like Bengali and Danish, demonstrating that semantic alignment via contrastive learning is a viable path for supporting low-resource languages.

The core insight is that contrastive learning acts as a regularizer, forcing the model to focus on underlying universal meaning rather than language-specific idioms.

Conclusion

This work demonstrates that combining Siamese networks with contrastive learning can effectively align semantic embeddings across languages, enabling universal zero-shot NLI. While the approach is highly effective, it remains dependent on the target language being present in the base multilingual model's initial pre-training. Future work will explore expanding these semantic "bridges" to even more languages and more complex reasoning tasks.

Summary updated

BibTeX
@misc{kowsher2023contrastive,
  author = {Md. Kowsher and Md. Shohanur Islam Sobuj and Nusrat Jahan Prottasha and Mohammad Shamsul Arefin and Yasuhiko Morimoto},
  title = {{Contrastive Learning for Universal Zero-Shot NLI with Cross-Lingual Sentence Embeddings}},
  year = {2023},
  doi = {10.18653/v1/2023.mrl-1.18},
}
Figure