cross-encoder/nli-roberta-base is a forked repo from huggingface. License: apache-2-0
Go to file
nreimers 2b4fd646c4 update 2021-06-21 09:24:49 +02:00
.gitattributes initial commit 2021-01-03 20:09:24 +00:00
CESoftmaxAccuracyEvaluator_AllNLI-dev_results.csv up 2021-01-03 21:23:16 +01:00
README.md update 2021-06-21 09:24:49 +02:00
config.json up 2021-01-03 21:23:16 +01:00
merges.txt up 2021-01-03 21:23:16 +01:00
pytorch_model.bin up 2021-01-03 21:23:16 +01:00
special_tokens_map.json up 2021-01-03 21:23:16 +01:00
tokenizer_config.json up 2021-01-03 21:23:16 +01:00
vocab.json up 2021-01-03 21:23:16 +01:00

README.md

language pipeline_tag tags datasets metrics
en zero-shot-classification
roberta-base
multi_nli
snli
accuracy

Cross-Encoder for Natural Language Inference

This model was trained using SentenceTransformers Cross-Encoder class.

Training Data

The model was trained on the SNLI and MultiNLI datasets. For a given sentence pair, it will output three scores corresponding to the labels: contradiction, entailment, neutral.

Performance

For evaluation results, see SBERT.net - Pretrained Cross-Encoder.

Usage

Pre-trained models can be used like this:

from sentence_transformers import CrossEncoder
model = CrossEncoder('model_name')
scores = model.predict([('A man is eating pizza', 'A man eats something'), ('A black race car starts up in front of a crowd of people.', 'A man is driving down a lonely road.')])

#Convert scores to labels
label_mapping = ['contradiction', 'entailment', 'neutral']
labels = [label_mapping[score_max] for score_max in scores.argmax(axis=1)]

Usage with Transformers AutoModel

You can use the model also directly with Transformers library (without SentenceTransformers library):

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model = AutoModelForSequenceClassification.from_pretrained('model_name')
tokenizer = AutoTokenizer.from_pretrained('model_name')

features = tokenizer(['A man is eating pizza', 'A black race car starts up in front of a crowd of people.'], ['A man eats something', 'A man is driving down a lonely road.'],  padding=True, truncation=True, return_tensors="pt")

model.eval()
with torch.no_grad():
    scores = model(**features).logits
    label_mapping = ['contradiction', 'entailment', 'neutral']
    labels = [label_mapping[score_max] for score_max in scores.argmax(dim=1)]
    print(labels)