Downloads · 30 days
118
1% of all-time downloads
MoritzLaurer/xtremedistil-l6-h256-mnli-fever-anli-ling-binary
xtremedistil-l6-h256-mnli-fever-anli-ling-binary is a zero-shot classification model from MoritzLaurer. Use it when you need labels you did not train the model on. It is set up for transformers.
This model was trained on 782 357 hypothesis-premise pairs from 4 NLI datasets: MultiNLI, Fever-NLI, LingNLI and ANLI.
Downloads · 30 days
118
1% of all-time downloads
All-time downloads
16.1K
Public
Parameters
12.8M
76.6 MB on disk
Likes
3
Public
Click a slice to open those files.
.bin25.5 MB · 49%
How the weights are stored.
F1612.8M · 100%
From the Hugging Face model README
This model was trained on 782 357 hypothesis-premise pairs from 4 NLI datasets: MultiNLI, Fever-NLI, LingNLI and ANLI.
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.
The base model is xtremedistil-l6-h256-uncased from Microsoft.
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model_name = "MoritzLaurer/xtremedistil-l6-h256-mnli-fever-anli-ling-binary"
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", "not_entailment"]
prediction = {name: round(float(pred) * 100, 1) for pred, name in zip(prediction, label_names)}
print(prediction)
This model was trained on 782 357 hypothesis-premise pairs from 4 NLI datasets: MultiNLI, Fever-NLI, LingNLI and ANLI.
xtremedistil-l6-h256-mnli-fever-anli-ling-binary was trained using the Hugging Face trainer with the following hyperparameters.
training_args = TrainingArguments(
num_train_epochs=5, # total number of training epochs
learning_rate=2e-05,
per_device_train_batch_size=32, # batch size per device during training
per_device_eval_batch_size=32, # batch size for evaluation
warmup_ratio=0.1, # number of warmup steps for learning rate scheduler
weight_decay=0.06, # strength of weight decay
fp16=True # mixed precision training
)
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.
| dataset | mnli-m-2c | mnli-mm-2c | fever-nli-2c | anli-all-2c | anli-r3-2c | lingnli-2c |
|---|---|---|---|---|---|---|
| accuracy | 0.897 | 0.898 | 0.861 | 0.607 | 0.62 | 0.827 |
| speed (text/sec, GPU Tesla P100, 128 batch) | 1490 | 1485 | 760 | 1186 | 1062 | 1791 |
Please consult the original paper and literature on different NLI datasets for potential biases.
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.
If you have questions or ideas for cooperation, contact me at m{dot}laurer{at}vu{dot}nl or LinkedIn
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.