--- --- language: - multilingual - en tags: - zero-shot-classification - text-classification - nli - pytorch metrics: - accuracy datasets: - mnli - xnli - anli license: mit pipeline_tag: zero-shot-classification widget: - text: "De pugna erat fantastic. Nam Crixo decem quam dilexit et praeciderunt caput aemulus." candidate_labels: "violent, peaceful" - text: "La película empezaba bien pero terminó siendo un desastre." candidate_labels: "positivo, negativo, neutral" - text: "La película empezó siendo un desastre pero en general fue bien." candidate_labels: "positivo, negativo, neutral" - text: "¿A quién vas a votar en 2020?" candidate_labels: "Europa, elecciones, política, ciencia, deportes" --- # Multilingual mDeBERTa-v3-base-mnli-xnli ## Model description This multilingual model can perform NLI on 100+ languages. It was pre-trained by Microsoft on the [CC100 multilingual dataset](https://huggingface.co/datasets/cc100). It was then fine-tuned on the [XNLI dataset](https://huggingface.co/datasets/xnli), which contains hypothesis-premise pairs from 15 languages as well as the English [MNLI dataset](https://huggingface.co/datasets/multi_nli). As of December 2021, mDeBERTa-base is the best performing multilingual transformer model, introduced by Microsoft in [this paper](https://arxiv.org/pdf/2111.09543.pdf). ## Intended uses & limitations #### How to use the model ```python from transformers import AutoTokenizer, AutoModelForSequenceClassification import torch model_name = "MoritzLaurer/mDeBERTa-v3-base-xnli-mnli" tokenizer = AutoTokenizer.from_pretrained(model_name) model = AutoModelForSequenceClassification.from_pretrained(model_name) premise = "I first thought that I liked the movie, but upon second thought it was actually disappointing." hypothesis = "The movie was good." 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 development set of the XNLI dataset and the MNLI dataset. The XNLI development set consists of 5010 professionally translated texts for each of 15 languages (see [this paper](https://arxiv.org/pdf/1809.05053.pdf)). Note that the XNLI train set also contains machine 15 machine translated versions of the MNLI dataset, but due to quality issues with these machine translations, the model was only trained on the XNLI development and the original English MNLI training set (392 702 texts). Not using machine translated texts can avoid overfitting the model to the 15 languages and avoid catastrophic forgetting of the other 85 languages mDeBERTa was pre-trained on. ### Training procedure DeBERTa-v3-base-mnli was trained using the Hugging Face trainer with the following hyperparameters. ``` training_args = TrainingArguments( num_train_epochs=2, # total number of training epochs learning_rate=2e-05, per_device_train_batch_size=16, # batch size per device during training 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.06, # strength of weight decay ) ``` ### Eval results The model was evaluated using the matched test set and achieves 0.90 accuracy. average | ar | bg | de | el | en | es | fr | hi | ru | sw | th | tr | ur | vu | zh ---------|----------|---------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|----------|---------- 0.808 | 0.802 | 0.829 | 0.825 | 0.826 | 0.883 | 0.845 | 0.834 | 0.771 | 0.813 | 0.748 | 0.793 | 0.807 | 0.740 | 0.795 | 0.8116 {'ar': 0.8017964071856287, 'bg': 0.8287425149700599, 'de': 0.8253493013972056, 'el': 0.8267465069860279, 'en': 0.8830339321357286, 'es': 0.8449101796407186, 'fr': 0.8343313373253493, 'hi': 0.7712574850299401, 'ru': 0.8127744510978044, 'sw': 0.7483033932135729, 'th': 0.792814371257485, 'tr': 0.8065868263473054, 'ur': 0.7403193612774451, 'vi': 0.7954091816367266, 'zh': 0.8115768463073852} ## Limitations and bias Please consult the original DeBERTa-V3 paper and literature on different NLI datasets for potential biases. ### BibTeX entry and citation info If you want to cite this model, please cite the original DeBERTa paper, the respective NLI datasets and include a link to this model on the Hugging Face hub.