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.

What it is good at

  • Zero-shot text classification
  • Multi-label classification
  • Natural Language Inference (NLI)
  • Topic detection, sentiment, intent, content moderation, and many other classification tasks

Just provide the text and a list of candidate labels — the model ranks them by how well they fit.

Model Details

Property Value
Architecture BART-large
Task Sequence Classification (NLI)
Labels contradiction / neutral / entailment
Max Sequence Length 1024
Vocabulary Size 50,265
License MIT

Quick Start

Using the Pipeline (recommended)

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)

Multi-label mode

result = classifier(
    sequence,
    candidate_labels=["travel", "cooking", "dancing", "exploration"],
    multi_label=True
)

Manual usage

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}")

How Zero-Shot Classification works

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.

Tips for best results

  • Use clear and specific labels
  • Prefer multi_label=True when several labels can be true at the same time
  • For short texts the model is usually very accurate
  • For very long texts, keep the most important part near the beginning (truncation keeps the start)

License

MIT

Credits

Based on the excellent facebook/bart-large-mnli model.

Downloads last month
-
Safetensors
Model size
0.4B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for roskosmos19/Coral-Router

Finetuned
(37)
this model

Dataset used to train roskosmos19/Coral-Router