This project hasn't been updated in a long time, so it no longer appears on the homepage, categories, or search results — the data is preserved and this page still works normally.
Back to Trending
Modelzero-shot-classification
MoritzLaurer

MoritzLaurer/ernie-m-large-mnli-xnli

Multilingual ernie-m-large-mnli-xnli Model description This multilingual model can perform natural language inference (NLI) on 100 languages and is therefore also suitable for multilingual zero-shot classification. The underlying model was pre-train...

18likes
224downloads
0views

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: arxiv:1911.02116

#1 Repository Của Tuần

1
TINIX TRENDING·Chủ đề: ernie_m

#1 Repository Của Tuần

1
TINIX TRENDING·Chủ đề: arxiv:2012.15674

#1 Repository Của Tuần

Multilingual ernie-m-large-mnli-xnli

Model description

This multilingual model can perform natural language inference (NLI) on 100 languages and is therefore also suitable for multilingual zero-shot classification. The underlying model was pre-trained by Baidu, based on Meta's RoBERTa (pre-trained on the CC100 multilingual dataset. It was then fine-tuned on the XNLI dataset, which contains hypothesis-premise pairs from 15 languages, as well as the English MNLI dataset. The model was introduced by Baidu in this paper. The model outperforms RoBERTa models of equal size.

If you are looking for a much faster (but less performant) model, you can try multilingual-MiniLMv2-L6-mnli-xnli. If you are looking for a base-sized model with a good mix of performance and speed, you can try mDeBERTa-v3-base-mnli-xnli

How to use the model

Simple zero-shot classification pipeline

from transformers import pipeline
classifier = pipeline("zero-shot-classification", model="MoritzLaurer/ernie-m-large-mnli-xnli")

sequence_to_classify = "Angela Merkel ist eine Politikerin in Deutschland und Vorsitzende der CDU"
candidate_labels = ["politics", "economy", "entertainment", "environment"]
output = classifier(sequence_to_classify, candidate_labels, multi_label=False)
print(output)

NLI use-case

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")

model_name = "MoritzLaurer/ernie-m-large-mnli-xnli"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name).to(device)

premise = "Angela Merkel ist eine Politikerin in Deutschland und Vorsitzende der CDU"
hypothesis = "Emmanuel Macron is the President of France"

input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
output = model(input["input_ids"].to(device))  # device = "cuda:0" or "cpu"
prediction = torch.softmax(output["logits"][0], -1).tolist()
label_names = ["entailment", "neutral", "contradiction"]
prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
print(prediction)

Training data

This model was trained on the XNLI development dataset and the MNLI train dataset. The XNLI development set consists of 2490 professionally translated texts from English to 14 other languages (37350 texts in total) (see this paper). Note that the XNLI contains a training set of 15 machine translated versions of the MNLI dataset for 15 languages, but due to quality issues with these machine translations, this model was only trained on the professional translations from the XNLI development set and the original English MNLI training set (392 702 texts). Not using machine translated texts can avoid overfitting the model to the 15 languages; avoids catastrophic forgetting of the other 85 languages ernie-m was pre-trained on; and significantly reduces training costs.

Training procedure

ernie-m-large-mnli-xnli was trained using the Hugging Face trainer with the following hyperparameters.

training_args = TrainingArguments(
    num_train_epochs=3,              # total number of training epochs
    learning_rate=3e-05,
    per_device_train_batch_size=16,   # batch size per device during training
    gradient_accumulation_steps=2,
    per_device_eval_batch_size=16,    # batch size for evaluation
    warmup_ratio=0.1,                # number of warmup steps for learning rate scheduler
    weight_decay=0.01,               # strength of weight decay
    fp16=True,
)

Eval results

The model was evaluated on the XNLI test set on 15 languages (5010 texts per language, 75150 in total). Note that multilingual NLI models are capable of classifying NLI texts without receiving NLI training data in the specific language (cross-lingual transfer). This means that the model is also able of doing NLI on the other 85 languages mDeBERTa was training on, but performance is most likely lower than for those languages available in XNLI.

Also note that if other multilingual models on the model hub claim performance of around 90% on languages other than English, the authors have most likely made a mistake during testing since non of the latest papers shows a multilingual average performance of more than a few points above 80% on XNLI (see here or here).

Datasetsavg_xnlimnli_mmnli_mmarbgdeelenesfrhiruswthtrurvizh
Accuracy0.8220.8810.8780.8180.8530.840.8370.8820.8550.8490.7990.830.7510.8090.8180.760.8260.799
Inference text/sec (A100, batch=120)1415.0783.0774.01487.01396.01430.01206.01623.01482.01291.01302.01366.01484.01500.01609.01344.01403.01302.0

Limitations and bias

Please consult the original ernie-m paper and literature on different NLI datasets for potential biases.

Citation

If you use this model, please cite: Laurer, Moritz, Wouter van Atteveldt, Andreu Salleras Casas, and Kasper Welbers. 2022. ‘Less Annotating, More Classifying – Addressing the Data Scarcity Issue of Supervised Machine Learning with Deep Transfer Learning and BERT - NLI’. Preprint, June. Open Science Framework. https://osf.io/74b8k.

Ideas for cooperation or questions?

If you have questions or ideas for cooperation, contact me at m{dot}laurer{at}vu{dot}nl or LinkedIn

Debugging and issues

The ernie-m architecture is only supported with transformers==4.27 or higher (which is not yet released and causes an error in the inference widget as of 03.03.23). In order to run the model before the release of 4.27, you need to install transformers from source with: pip install git+https://github.com/huggingface/transformers
as well as the sentencepiece tokenizer with: pip install sentencepiece
After the release, you can run: pip install transformers[sentencepiece]>=4.27

Similar Projects

Discover other similar projects and AI models.

Modelautomatic-speech-recognition
openai/whisper-large-v3

Whisper Whisper is a state-of-the-art model for automatic speech recognition (ASR) and speech translation, proposed in the paper Robust Speech Recognition via Large-Scale Weak Supervision(https://huggingface.co/papers/2212.04356) by Alec Radford et...

♥0
3.5M
Aug 12, 2024
Modelsentence-similarity
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2

sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic se...

♥0
39.2M
Jan 28, 2026
Modelautomatic-speech-recognition
openai/whisper-large-v3-turbo

Whisper Whisper is a state-of-the-art model for automatic speech recognition (ASR) and speech translation, proposed in the paper Robust Speech Recognition via Large-Scale Weak Supervision(https://huggingface.co/papers/2212.04356) by Alec Radford et...

♥0
5.8M
Oct 4, 2024
Modelfill-mask
FacebookAI/xlm-roberta-base

XLM-RoBERTa (base-sized model) XLM-RoBERTa model pre-trained on 2.5TB of filtered CommonCrawl data containing 100 languages. It was introduced in the paper Unsupervised Cross-lingual Representation Learning at Scale(https://arxiv.org/abs/1911.02116)...

♥0
8.3M
Feb 19, 2024
Modelfeature-extraction
intfloat/multilingual-e5-large

Multilingual-E5-large Multilingual E5 Text Embeddings: A Technical Report(https://arxiv.org/pdf/2402.05672). Liang Wang, Nan Yang, Xiaolong Huang, Linjun Yang, Rangan Majumder, Furu Wei, arXiv 2024 This model has 24 layers and the embedding size is...

♥0
6.5M
Apr 2, 2026
Modelsentence-similarity
intfloat/multilingual-e5-small

Multilingual-E5-small Multilingual E5 Text Embeddings: A Technical Report(https://arxiv.org/pdf/2402.05672). Liang Wang, Nan Yang, Xiaolong Huang, Linjun Yang, Rangan Majumder, Furu Wei, arXiv 2024 This model has 12 layers and the embedding size is...

♥0
9.3M
Apr 2, 2026
Modeltext-to-speech
k2-fsa/OmniVoice

OmniVoice 🌍           OmniVoice is a massively multilingual zero-shot text-to-speech (TTS) model supporting over 600 languages. Built on a novel diffusion language model-style architecture, it delivers high-quality speech w...

♥0
2.3M
Jul 3, 2026
Modelautomatic-speech-recognition
openai/whisper-large-v2

Whisper Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation. Trained on 680k hours of labelled data, Whisper models demonstrate a strong ability to generalise to many datasets and domains without the need for...

♥0
65.4k
Feb 29, 2024
Modelsentence-similarity
intfloat/multilingual-e5-base

Multilingual-E5-base Multilingual E5 Text Embeddings: A Technical Report(https://arxiv.org/pdf/2402.05672). Liang Wang, Nan Yang, Xiaolong Huang, Linjun Yang, Rangan Majumder, Furu Wei, arXiv 2024 This model has 12 layers and the embedding size is 7...

♥0
5.5M
Apr 2, 2026