The SNLI corpus (version 1.0) is a collection of 570k human-written English sentence pairs manually labeled for balanced classification with the labels entailment, contradiction, and neutral, supporting the task of natural language inference (NLI), also known as recognizing textual entailment (RTE).
The Multi-Genre Natural Language Inference (MultiNLI) corpus is a crowd-sourced collection of 433k sentence pairs annotated with textual entailment information. The corpus is modeled on the SNLI corpus, but differs in that covers a range of genres of spoken and written text, and supports a distinctive cross-genre generalization evaluation.
Usage
Inference API has been disabled as it is not suitable for this kind of task.
python
1from transformers import AutoTokenizer, AutoModelForSequenceClassification
2import torch
34# Load model and tokenizer5model_checkpoint ='AdamCodd/ettin-nli-classifier'6model = AutoModelForSequenceClassification.from_pretrained(model_checkpoint)7tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)89# Set device10device = torch.device("cuda"if torch.cuda.is_available()else"cpu")11model.to(device)1213# Sample premise and hypothesis14premise ="The cat is sleeping under the sun."15hypothesis ="It's raining, and the cat is getting wet."1617# Tokenize and predict18input= tokenizer(premise, hypothesis, truncation=True, padding=True, return_tensors="pt", max_length=256).to(device)19with torch.no_grad():20 output = model(**input)21 probabilities = torch.softmax(output.logits, dim=-1)[0].tolist()2223# Output prediction24label_names =["Entailment","Neutral","Contradiction"]25prediction ={name:round(prob *100,1)for name, prob inzip(label_names, probabilities)}26print(prediction)27# e.g. {'Entailment': 1.3, 'Neutral': 8.2, 'Contradiction': 90.5}
Training and evaluation data
The training data consists of a concatenated corpus of the SNLI train split and the MultiNLI train split. The evaluation metrics were calculated using a concatenated validation set consisting of the SNLI validation split and the MultiNLI validation_matched split. All -1 labels (samples without annotator consensus) were filtered out prior to training.
Training procedure
Training hyperparameters
The following hyperparameters were used during training:
learning_rate: 3e-05
train_batch_size: 32
eval_batch_size: 64
seed: 42
optimizer: AdamW with betas=(0.9,0.999) and epsilon=1e-08