nyu-mll/multi_nli
Viewer • Updated • 412k • 46.5k • 121
Coral-MNLI
Coral-MNLI is a high-quality zero-shot classification model based on BART-large, fine-tuned on MultiNLI.
It delivers strong performance for zero-shot and few-shot text classification without any task-specific training.
Just provide the text and a list of candidate labels — the model ranks them by how well they fit.
| Property | Value |
|---|---|
| Architecture | BART-large |
| Task | Sequence Classification (NLI) |
| Labels | contradiction / neutral / entailment |
| Max Sequence Length | 1024 |
| Vocabulary Size | 50,265 |
| License | MIT |
from transformers import pipeline
classifier = pipeline(
"zero-shot-classification",
model="path/to/Coral-MNLI"
)
sequence = "One day I will see the world"
candidate_labels = ["travel", "cooking", "dancing"]
result = classifier(sequence, candidate_labels)
print(result)
result = classifier(
sequence,
candidate_labels=["travel", "cooking", "dancing", "exploration"],
multi_label=True
)
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch
model = AutoModelForSequenceClassification.from_pretrained("path/to/Coral-MNLI")
tokenizer = AutoTokenizer.from_pretrained("path/to/Coral-MNLI")
premise = "One day I will see the world"
label = "travel"
hypothesis = f"This example is {label}."
inputs = tokenizer(premise, hypothesis, return_tensors="pt", truncation=True)
with torch.no_grad():
logits = model(**inputs).logits
# Take only contradiction (0) and entailment (2)
probs = torch.softmax(logits[:, [0, 2]], dim=1)
prob_label_is_true = probs[0, 1].item()
print(f"Probability that the text is about '{label}': {prob_label_is_true:.4f}")
The model treats the input text as a premise and turns each candidate label into a hypothesis of the form:
"This example is {label}."
It then uses the entailment probability as the score for that label. This simple trick works surprisingly well across many domains.
MIT
Based on the excellent facebook/bart-large-mnli model.
Base model
facebook/bart-large-mnli