MoritzLaurer HF staff commited on
Commit
ec9b89c
1 Parent(s): aa728f3

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +59 -0
README.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - text-classification
6
+ - zero-shot-classification
7
+ metrics:
8
+ - accuracy
9
+ pipeline_tag: zero-shot-classification
10
+
11
+ ---
12
+ # Multilingual mDeBERTa-v3-base-mnli-xnli
13
+ ## Model description
14
+ 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).
15
+ 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).
16
+
17
+
18
+ ## Intended uses & limitations
19
+ #### How to use the model
20
+ ```python
21
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
22
+ import torch
23
+ model_name = "MoritzLaurer/mDeBERTa-v3-base-xnli-mnli"
24
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
25
+ model = AutoModelForSequenceClassification.from_pretrained(model_name)
26
+ premise = "I first thought that I liked the movie, but upon second thought it was actually disappointing."
27
+ hypothesis = "The movie was good."
28
+ input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
29
+ output = model(input["input_ids"].to(device)) # device = "cuda:0" or "cpu"
30
+ prediction = torch.softmax(output["logits"][0], -1).tolist()
31
+ label_names = ["entailment", "neutral", "contradiction"]
32
+ prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
33
+ print(prediction)
34
+ ```
35
+
36
+ ### Training data
37
+ 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.
38
+
39
+ ### Training procedure
40
+ DeBERTa-v3-base-mnli was trained using the Hugging Face trainer with the following hyperparameters.
41
+ ```
42
+ training_args = TrainingArguments(
43
+ num_train_epochs=2, # total number of training epochs
44
+ learning_rate=2e-05,
45
+ per_device_train_batch_size=16, # batch size per device during training
46
+ per_device_eval_batch_size=16, # batch size for evaluation
47
+ warmup_ratio=0.1, # number of warmup steps for learning rate scheduler
48
+ weight_decay=0.06, # strength of weight decay
49
+ )
50
+ ```
51
+ ### Eval results
52
+ The model was evaluated using the matched test set and achieves 0.90 accuracy.
53
+
54
+
55
+
56
+ ## Limitations and bias
57
+ Please consult the original DeBERTa-V3 paper and literature on different NLI datasets for potential biases.
58
+ ### BibTeX entry and citation info
59
+ 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.