Downloads · 30 days
77
0% of all-time downloads
navteca/nli-deberta-v3-xsmall
nli-deberta-v3-xsmall is a zero-shot classification model from navteca. Use it when you need labels you did not train the model on. It is set up for transformers. The card lists the license as apache-2.0.
This model was trained using SentenceTransformers Cross-Encoder class. This model is based on microsoft/deberta-v3-xsmall
Downloads · 30 days
77
0% of all-time downloads
All-time downloads
22.2K
Public
Repo size
569 MB
Likes
1
Public
Click a slice to open those files.
.bin283 MB · 99%
From the Hugging Face model README
This model was trained using SentenceTransformers Cross-Encoder class. This model is based on microsoft/deberta-v3-xsmall
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.
For futher evaluation results, see SBERT.net - Pretrained Cross-Encoder.
Pre-trained models can be used like this:
from sentence_transformers import CrossEncoder
model = CrossEncoder('cross-encoder/nli-deberta-v3-xsmall')
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)]
You can use the model also directly with Transformers library (without SentenceTransformers library):
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model = AutoModelForSequenceClassification.from_pretrained('cross-encoder/nli-deberta-v3-xsmall')
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/nli-deberta-v3-xsmall')
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)
This model can also be used for zero-shot-classification:
from transformers import pipeline
classifier = pipeline("zero-shot-classification", model='cross-encoder/nli-deberta-v3-xsmall')
sent = "Apple just announced the newest iPhone X"
candidate_labels = ["technology", "sports", "politics"]
res = classifier(sent, candidate_labels)
print(res)