MoritzLaurer/mDeBERTa-v3-base-mnli-xnli is a forked repo from huggingface. License: mit
Go to file
Moritz Laurer ec9b89c278 Create README.md 2021-12-05 16:43:41 +00:00
.gitattributes initial commit 2021-12-05 16:18:00 +00:00
README.md Create README.md 2021-12-05 16:43:41 +00:00
added_tokens.json add tokenizer 2021-12-05 16:33:24 +00:00
config.json add model 2021-12-05 16:18:20 +00:00
pytorch_model.bin add model 2021-12-05 16:18:20 +00:00
special_tokens_map.json add tokenizer 2021-12-05 16:33:24 +00:00
spm.model add tokenizer 2021-12-05 16:33:24 +00:00
tokenizer_config.json add tokenizer 2021-12-05 16:33:24 +00:00

README.md

language tags metrics pipeline_tag
en
text-classification
zero-shot-classification
accuracy
zero-shot-classification

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. It was then fine-tuned on the XNLI dataset, which contains hypothesis-premise pairs from 15 languages as well as the English MNLI dataset. As of December 2021, mDeBERTa-base is the best performing multilingual transformer model, introduced by Microsoft in this paper.

Intended uses & limitations

How to use the model

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). 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.

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.