Commit
•
da4fa2f
1
Parent(s):
a420845
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
tags:
|
5 |
+
- text-classification
|
6 |
+
- zero-shot-classification
|
7 |
+
metrics:
|
8 |
+
- accuracy
|
9 |
+
datasets:
|
10 |
+
- xnli
|
11 |
+
- mnli
|
12 |
+
- anli
|
13 |
+
- lingnli
|
14 |
+
pipeline_tag: zero-shot-classification
|
15 |
+
|
16 |
+
---
|
17 |
+
# xtremedistil-l6-h256-mnli-fever-anli-ling-binary
|
18 |
+
## Model description
|
19 |
+
This model was trained on 782 357 hypothesis-premise pairs from 4 NLI datasets: [MultiNLI](https://huggingface.co/datasets/multi_nli), [Fever-NLI](https://github.com/easonnie/combine-FEVER-NSMN/blob/master/other_resources/nli_fever.md), [LingNLI](https://arxiv.org/abs/2104.07179) and [ANLI](https://github.com/facebookresearch/anli).
|
20 |
+
|
21 |
+
Note that the model was trained on binary NLI to predict either "entailment" or "not-entailment". This is specifically designed for zero-shot classification, where the difference between "neutral" and "contradiction" is irrelevant.
|
22 |
+
|
23 |
+
The base model is [xtremedistil-l6-h256-uncased from Microsoft](https://huggingface.co/microsoft/xtremedistil-l6-h256-uncased).
|
24 |
+
|
25 |
+
## Intended uses & limitations
|
26 |
+
#### How to use the model
|
27 |
+
```python
|
28 |
+
from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
29 |
+
import torch
|
30 |
+
|
31 |
+
model_name = "MoritzLaurer/xtremedistil-l6-h256-mnli-fever-anli-ling-binary"
|
32 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
33 |
+
model = AutoModelForSequenceClassification.from_pretrained(model_name)
|
34 |
+
|
35 |
+
premise = "I first thought that I liked the movie, but upon second thought it was actually disappointing."
|
36 |
+
hypothesis = "The movie was good."
|
37 |
+
|
38 |
+
input = tokenizer(premise, hypothesis, truncation=True, return_tensors="pt")
|
39 |
+
output = model(input["input_ids"].to(device)) # device = "cuda:0" or "cpu"
|
40 |
+
prediction = torch.softmax(output["logits"][0], -1).tolist()
|
41 |
+
label_names = ["entailment", "not_entailment"]
|
42 |
+
prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
|
43 |
+
print(prediction)
|
44 |
+
```
|
45 |
+
### Training data
|
46 |
+
This model was trained on 782 357 hypothesis-premise pairs from 4 NLI datasets: [MultiNLI](https://huggingface.co/datasets/multi_nli), [Fever-NLI](https://github.com/easonnie/combine-FEVER-NSMN/blob/master/other_resources/nli_fever.md), [LingNLI](https://arxiv.org/abs/2104.07179) and [ANLI](https://github.com/facebookresearch/anli).
|
47 |
+
|
48 |
+
### Training procedure
|
49 |
+
xtremedistil-l6-h256-mnli-fever-anli-ling-binary was trained using the Hugging Face trainer with the following hyperparameters.
|
50 |
+
```
|
51 |
+
training_args = TrainingArguments(
|
52 |
+
num_train_epochs=5, # total number of training epochs
|
53 |
+
learning_rate=2e-05,
|
54 |
+
per_device_train_batch_size=32, # batch size per device during training
|
55 |
+
per_device_eval_batch_size=32, # batch size for evaluation
|
56 |
+
warmup_ratio=0.1, # number of warmup steps for learning rate scheduler
|
57 |
+
weight_decay=0.06, # strength of weight decay
|
58 |
+
fp16=True # mixed precision training
|
59 |
+
)
|
60 |
+
```
|
61 |
+
### Eval results
|
62 |
+
The model was evaluated using the binary test sets for MultiNLI, ANLI, LingNLI and the binary dev set for Fever-NLI (two classes instead of three). The metric used is accuracy.
|
63 |
+
|
64 |
+
dataset | mnli-m-2c | mnli-mm-2c | fever-nli-2c | anli-all-2c | anli-r3-2c | lingnli-2c
|
65 |
+
--------|---------|----------|---------|----------|----------|------
|
66 |
+
accuracy | 0.897 | 0.898 | 0.861 | 0.607 | 0.62 | 0.827
|
67 |
+
speed (text/sec, GPU Tesla P100, 128 batch) | 1490 | 1485 | 760 | 1186 | 1062 | 1791
|
68 |
+
|
69 |
+
|
70 |
+
## Limitations and bias
|
71 |
+
Please consult the original paper and literature on different NLI datasets for potential biases.
|
72 |
+
|
73 |
+
### BibTeX entry and citation info
|
74 |
+
If you want to cite this model, please cite the original paper, the respective NLI datasets and include a link to this model on the Hugging Face hub.
|
75 |
+
|
76 |
+
### Ideas for cooperation or questions?
|
77 |
+
If you have questions or ideas for cooperation, contact me at m{dot}laurer{at}vu{dot}nl or [LinkedIn](https://www.linkedin.com/in/moritz-laurer/)
|
78 |
+
|
79 |
+
### Debugging and issues
|
80 |
+
Note that the model was released recently and older versions of HF Transformers seem to have issues running the model (e.g. resulting in an issue with the tokenizer). Using Transformers==4.13 might solve some issues.
|