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.
from sentence_transformers import CrossEncoder
model = CrossEncoder('cross-encoder/nli-deberta-v3-small')
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('cross-encoder/nli-deberta-v3-small')
tokenizer = AutoTokenizer.from_pretrained('cross-encoder/nli-deberta-v3-small')
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)
Zero-Shot Classification
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-small')
sent = "Apple just announced the newest iPhone X"
candidate_labels = ["technology", "sports", "politics"]
res = classifier(sent, candidate_labels)
print(res)
Runs of cross-encoder nli-deberta-v3-small on huggingface.co
1.6K
Total runs
0
24-hour runs
-117
3-day runs
242
7-day runs
356
30-day runs
More Information About nli-deberta-v3-small huggingface.co Model
nli-deberta-v3-small huggingface.co is an AI model on huggingface.co that provides nli-deberta-v3-small's model effect (), which can be used instantly with this cross-encoder nli-deberta-v3-small model. huggingface.co supports a free trial of the nli-deberta-v3-small model, and also provides paid use of the nli-deberta-v3-small. Support call nli-deberta-v3-small model through api, including Node.js, Python, http.
nli-deberta-v3-small huggingface.co is an online trial and call api platform, which integrates nli-deberta-v3-small's modeling effects, including api services, and provides a free online trial of nli-deberta-v3-small, you can try nli-deberta-v3-small online for free by clicking the link below.
cross-encoder nli-deberta-v3-small online free url in huggingface.co:
nli-deberta-v3-small is an open source model from GitHub that offers a free installation service, and any user can find nli-deberta-v3-small on GitHub to install. At the same time, huggingface.co provides the effect of nli-deberta-v3-small install, users can directly use nli-deberta-v3-small installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
nli-deberta-v3-small install url in huggingface.co: