SAVRN
Search Contact SAVRN

Open-weight model · Zero-shot classification

bart-large-mnli-yahoo-answers

by Joe Davison joeddav/bart-large-mnli-yahoo-answers

This model takes facebook/bart-large-mnli and fine-tunes it on Yahoo Answers topic classification. It can be used to predict whether a topic label can be assigned to a given sequence, whether or not the label has been seen before.

Parameters407M
Context1,024
Weights4.9 GB
Licenseapache-2.0
AccessOpen weights
Monthly Downloads6.1k

Runs On

What it takes to serve bart-large-mnli-yahoo-answers (407M parameters): the memory its weights need at each precision, and the cheapest way to rent enough data-center GPUs to hold them.

PrecisionWeightsMemory neededCheapest setupPer hourAlso fits
16-bit 0.8 GB 1.0 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00
8-bit 0.4 GB 0.5 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00
4-bit 0.2 GB 0.2 GB 1x MI300X (192 GB)
Vultr
$1.85 1x H100 $1.99 · 1x MI325X $2.00

Memory is the weights at that precision plus 20% for the runtime and a short context; a long context needs more. Prices are the lowest on-demand hourly rates in the SAVRN Index, read Sep 18, 2026.

Model Card

By Joe Davison, published under apache-2.0, revision 53d5a967011d.

This model takes facebook/bart-large-mnli and fine-tunes it on Yahoo Answers topic classification. It can be used to predict whether a topic label can be assigned to a given sequence, whether or not the label has been seen before. You can play with an interactive demo of this zero-shot technique with this model, as well as the non-finetuned facebook/bart-large-mnli, here. This model was fine-tuned on topic classification and will perform best at zero-shot topic classification. Use hypothesistemplate="This text is about {}." as this is the template used during fine-tuning. For settings other than topic classification, you can use any model pre-trained on MNLI such as facebook/bart-large-mnli…

Read Joe Davison's full model card

bart-lage-mnli-yahoo-answers

Model Description

This model takes facebook/bart-large-mnli and fine-tunes it on Yahoo Answers topic classification. It can be used to predict whether a topic label can be assigned to a given sequence, whether or not the label has been seen before.

You can play with an interactive demo of this zero-shot technique with this model, as well as the non-finetuned facebook/bart-large-mnli, here.

Intended Usage

This model was fine-tuned on topic classification and will perform best at zero-shot topic classification. Use hypothesis_template="This text is about {}." as this is the template used during fine-tuning.

For settings other than topic classification, you can use any model pre-trained on MNLI such as facebook/bart-large-mnli or roberta-large-mnli with the same code as written below.

With the zero-shot classification pipeline

The model can be used with the zero-shot-classification pipeline like so:

from transformers import pipeline
nlp = pipeline("zero-shot-classification", model="joeddav/bart-large-mnli-yahoo-answers")

sequence_to_classify = "Who are you voting for in 2020?"
candidate_labels = ["Europe", "public health", "politics", "elections"]
hypothesis_template = "This text is about {}."
nlp(sequence_to_classify, candidate_labels, multi_class=True, hypothesis_template=hypothesis_template)

With manual PyTorch

# pose sequence as a NLI premise and label as a hypothesis
from transformers import BartForSequenceClassification, BartTokenizer
nli_model = BartForSequenceClassification.from_pretrained('joeddav/bart-large-mnli-yahoo-answers')
tokenizer = BartTokenizer.from_pretrained('joeddav/bart-large-mnli-yahoo-answers')

premise = sequence
hypothesis = f'This text is about {label}.'

# run through model pre-trained on MNLI
x = tokenizer.encode(premise, hypothesis, return_tensors='pt',
                        max_length=tokenizer.max_len,
                        truncation_strategy='only_first')
logits = nli_model(x.to(device))[0]

# we throw away "neutral" (dim 1) and take the probability of
# "entailment" (2) as the probability of the label being true 
entail_contradiction_logits = logits[:,[0,2]]
probs = entail_contradiction_logits.softmax(dim=1)
prob_label_is_true = probs[:,1]

Training

The model is a pre-trained MNLI classifier further fine-tuned on Yahoo Answers topic classification in the manner originally described in Yin et al. 2019 and this blog post. That is, each sequence is fed to the pre-trained NLI model in place of the premise and each candidate label as the hypothesis, formatted like so: This text is about {class name}. For each example in the training set, a true and a randomly-selected false label hypothesis are fed to the model which must predict which labels are valid and which are false.

Since this method studies the ability to classify unseen labels after being trained on a different set of labels, the model is only trained on 5 out of the 10 labels in Yahoo Answers. These are "Society & Culture", "Health", "Computers & Internet", "Business & Finance", and "Family & Relationships".

Evaluation Results

This model was evaluated with the label-weighted F1 of the seen and unseen labels. That is, for each example the model must predict from one of the 10 corpus labels. The F1 is reported for the labels seen during training as well as the labels unseen during training. We found an F1 score of .68 and .72 for the unseen and seen labels, respectively. In order to adjust for the in-vs-out of distribution labels, we subtract a fixed amount of 30% from the normalized probabilities of the seen labels, as described in Yin et al. 2019 and our blog post.

Configuration

Architecture
BartForSequenceClassification
Context length (tokens)
1,024
Layers
12
Vocabulary size
50,265
Model type
bart

Identity and Version

Repository
joeddav/bart-large-mnli-yahoo-answers
Publisher
Joe Davison
Task
Zero-shot classification
Modality
Text
Library
transformers
Parameters
407M parameters
Languages
en
Revision
53d5a967011d30a0aa2c86a2008c7c31724e213c
First published
2022-03-02
Last updated
2025-09-15

Files and Weights

10 files, 4.9 GB in total. The weights are 3 files totalling 4.9 GB in bin, msgpack, safetensors.

Weights3 files · 4.9 GB
Configuration2 files · 1.2 KB
Tokenizer3 files · 1.4 MB
Documentation1 file · 4.3 KB
Repository1 file · 445 B
Every file
FileTypeSizeSHA-256
flax_model.msgpackWeights1.6 GB 4cea25662c8c
model.safetensorsWeights1.6 GB 844031a8e3de
pytorch_model.binWeights1.6 GB 6bf03356b0a2
config.jsonConfiguration1.1 KB
special_tokens_map.jsonConfiguration150 B
README.mdDocumentation4.3 KB
.gitattributesRepository445 B
merges.txtTokenizer456.3 KB
tokenizer_config.jsonTokenizer26 B
vocab.jsonTokenizer898.8 KB

License and Download

License
apache-2.0
Access
Open weights, no gate
Download size
4.9 GB
Download from Joe Davison

Released by Joe Davison through its official repository on Hugging Face. Read the license.

Built From

Memory Requirements

PrecisionWeights in memory
As published4.9 GB
16-bit0.8 GB
8-bit0.4 GB
4-bit0.2 GB

Weights only, from the published parameter count; the key-value cache and runtime add to this.

Questions About bart-large-mnli-yahoo-answers

How much GPU memory does bart-large-mnli-yahoo-answers need?

About 1 GB at 16-bit and 0.2 GB at 4-bit: the weights (407M parameters) plus a working margin. A long context needs more.

What is the cheapest GPU to run bart-large-mnli-yahoo-answers on?

At 16-bit, 1x MI300X from $1.85 an hour; at 4-bit, 1x MI300X from $1.85 an hour, at the lowest on-demand prices the SAVRN Index lists.

Can I use bart-large-mnli-yahoo-answers commercially?

Yes. bart-large-mnli-yahoo-answers is released under Apache License 2.0. The Apache License 2.0 is a permissive open-source license. It permits commercial use, modification and redistribution. It requires keeping the license and copyright notices and any NOTICE file, stating significant changes, and it includes an express patent grant from contributors.

What is bart-large-mnli-yahoo-answers's context length?

1,024 tokens, from the maximum position embeddings in its published configuration.

Similar Models

Model · Zero-shot classification

bart-large-mnli

AI at Meta

This is the checkpoint for bart-large after being trained on the MultiNLI (MNLI) dataset. - The bart-large model page - BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension Yin et al. proposed a method for using pre-trained NLI models as a ready-made zero-shot sequence classifiers. The method works by posing the sequence to be classified as the NLI premise and to construct a hypothesis from each candidate label. For example, if we want to evaluate whether a sequence belongs to the class "politics", we could construct a hypothesis of This text is about politics.. The probabilities for entailment and contradiction are then converted…

Open weights mit 407M parameters 1,024 tokens transformers

Model · Zero-shot classification

ModernBERT-large-nli

Tasksource

This model is ModernBERT multi-task fine-tuned on tasksource NLI tasks, including MNLI, ANLI, SICK, WANLI, doc-nli, LingNLI, FOLIO, FOL-NLI, LogicNLI, Label-NLI and all datasets in the below table). This is the equivalent of an "instruct" version. The model was trained for 200k steps on an Nvidia A30 GPU. It is very good at reasoning tasks (better than llama 3.1 8B Instruct on ANLI and FOLIO), long context reasoning, sentiment analysis and zero-shot classification with new labels. The following table shows model test accuracy. These are the scores for the same single transformer with different classification heads on top. Further gains can be obtained by fine-tuning on a single-task, e.g.…

Open weights apache-2.0 396M parameters 2,048 tokens transformers

Model · Zero-shot classification

finecat-nli-l

Lee Miller

This model is a fine-tune of the excellent tasksource/ModernBERT-large-nli, trained on the dleemiller/FineCat-NLI dataset—a compilation of several high-quality NLI data sources with quality screening and reduction of easy samples in the training split. The training also incorporates logit distillation from MoritzLaurer/DeBERTa-v3-large-mnli-fever-anli-ling-wanli, a top-performing NLI model, particularly on ANLI benchmarks. \begin{equation} \mathcal{L} = \alpha \cdot \mathcal{L}{\text{CE}}(z^{(s)}, y) + \beta \cdot \mathcal{L}{\text{MSE}}(z^{(s)}, z^{(t)}) \end{equation} where \\(z^{(s)}\\) and \\(z^{(t)}\\) are the student and teacher logits, \\(y\\) are the ground truth labels, and…

Open weights 396M parameters 2,048 tokens sentence-transformers

Models in this series are designed for efficient zeroshot classification with the Hugging Face pipeline. These models can do classification without training data and run on both GPUs and CPUs. An overview of the latest zeroshot classifiers is available in my Zeroshot Classifier Collection. The main update of this zeroshot-v2.0 series of models is that several models are trained on fully commercially-friendly data for users with strict license requirements. These models can do one universal classification task: determine whether a hypothesis is "true" or "not true" given a text (entailment vs. notentailment). This task format is based on the Natural Language Inference task (NLI). The task is…

Open weights mit 435M parameters 512 tokens transformers

The model is designed for zero-shot classification with the Hugging Face pipeline. The model should be substantially better at zero-shot classification than my other zero-shot models on the The model can do one universal task: determine whether a hypothesis is true or nottrue given a text (also called entailment vs. notentailment). This task format is based on the Natural Language Inference task (NLI). The task is so universal that any classification task can be reformulated into the task. The model was trained on a mixture of 27 tasks and 310 classes that have been reformatted into this universal format. 1. 26 classification tasks with ~400k texts: 'amazonpolarity', 'imdb', 'appreviews'…

Open weights mit 435M parameters 512 tokens transformers

The model is designed for zero-shot classification with the Hugging Face pipeline. The model can do one universal classification task: determine whether a hypothesis is "true" or "not true" given a text (entailment vs. notentailment). This task format is based on the Natural Language Inference task (NLI). The task is so universal that any classification task can be reformulated into this task. A detailed description of how the model was trained and how it can be used is available in this paper. The model was trained on a mixture of 33 datasets and 387 classes that have been reformatted into this universal format. 1. Five NLI datasets with ~885k texts: "mnli", "anli", "fever", "wanli"…

Open weights mit 435M parameters 512 tokens transformers