Instructions to use kavoye/zeroshot-choice-400m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use kavoye/zeroshot-choice-400m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-classification", model="kavoye/zeroshot-choice-400m", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModel tokenizer = AutoTokenizer.from_pretrained("kavoye/zeroshot-choice-400m", trust_remote_code=True) model = AutoModel.from_pretrained("kavoye/zeroshot-choice-400m", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
zeroshot-choice-400m
A 396M-parameter encoder that answers a question about a text by choosing from options you give it: labels, yes/no, actions or multiple-choice answers. All options are scored together in one pass over the text, and the order of the options never changes the answer.
from transformers import pipeline
clf = pipeline("zero-shot-classification", model="kavoye/zeroshot-choice-400m", trust_remote_code=True)
clf("The package arrived broken and support never answered my emails.",
candidate_labels=["happy", "neutral", "angry"], question="How does the customer feel?")
# {'sequence': '...', 'labels': ['angry', 'neutral', 'happy'], 'scores': [0.977, 0.021, 0.002]}
clf("The central bank raised rates by 50 basis points.", ["sports", "economy", "science", "politics"])
# labels: ['economy', ...], scores: [0.944, ...]
The call and output follow the standard zero-shot pipeline, with these differences:
question(optional) is the question the labels answer. The default is "Which label fits this text best?".- There is no hypothesis template;
hypothesis_templateis ignored with a warning. - The scores are one softmax over the labels, so at least two labels are needed and
multi_labelis not supported. - Texts are scored one at a time;
batch_sizeis ignored with a warning.
Without the pipeline, score() returns probabilities in the order you give the options:
from transformers import AutoModel, AutoTokenizer
tok = AutoTokenizer.from_pretrained("kavoye/zeroshot-choice-400m")
model = AutoModel.from_pretrained("kavoye/zeroshot-choice-400m", trust_remote_code=True).eval()
model.score(tok, "Either party may end the contract with 30 days' written notice.",
"Can the customer cancel the contract?", ["yes", "no"])
# [0.967, 0.033]
trust_remote_code=True runs the two short files in this repository, modeling_zeroshot_choice.py and
pipeline_zeroshot_choice.py. Tested with transformers 5.23 and torch 2.15.
Results
The fair zero-shot comparison: 13 public test sets whose datasets this model never saw in training and that were not used to choose between training recipes. Every model gets the same text, question and options; NLI models score each option as a hypothesis. Most sets have 300 questions, the others 150 to 1,500. Best score per column in bold.
| Model | Never-seen tasks (13) | Unseen by all models (8) | Classic benchmarks (6) | BTZSC (22) |
|---|---|---|---|---|
| zeroshot-choice-400m | 68.4 | 76.7 | 89.1 | 87.7 |
| GLiClass v4.1 edge | 67.2 | 76.1 | 88.1 | 83.5 |
| DeBERTa-v3-large zeroshot v2.0 | 61.7 | 69.3 | 82.6 | 86.3 |
| d1-omni 600M | 59.2 | 63.6 | 82.6 | 76.7 |
| DeBERTa-v3-large NLI | 59.0 | 67.9 | 73.9 | 63.5 |
| bge-m3 zeroshot v2.0 | 54.4 | 62.4 | 76.3 | 82.2 |
| DeBERTa-v3-base NLI | 54.3 | 61.5 | 69.9 | 58.7 |
| nli-deberta-v3-large | 51.9 | 59.4 | 64.8 | 56.9 |
| bart-large-mnli | 51.9 | 58.3 | 67.2 | 53.1 |
| bge-reranker-v2-m3 | 49.5 | 56.4 | 68.0 | 62.6 |
- Never-seen tasks (13): the comparison above. No train split, no shared 13-word run, not used for recipe choices.
- Unseen by all models (8): the 8 of those 13 that, according to their model cards, none of the compared models trained on: climate disclosure, contract yes/no, fact-check need, medical abstract topic, science yes/no, argument stance, statute entailment and web page topic.
- Classic benchmarks (6) and BTZSC (22): SST-2, AG News, emotion, RTE, BoolQ, Banking77 and the BTZSC collection. This model trained on the train splits of all six classic datasets and of 17 of the 22 BTZSC datasets, never on their test texts. GLiClass and the MoritzLaurer zero-shot v2.0 models also trained on most BTZSC train splits, so these two columns are in-domain results. BTZSC is reported as accuracy; its public leaderboard uses macro F1.
Per task
Against GLiClass on the 13 never-seen tasks, this model is ahead on 8 and behind on 5. It is clearly behind on business records and short business decisions, where the 600M d1-omni is the strongest model.
All per-task scores, including 4 tasks used for recipe choices
| Task | Dataset | zeroshot-choice-400m | GLiClass v4.1 edge | DeBERTa-v3-large zeroshot v2.0 | d1-omni 600M |
|---|---|---|---|---|---|
| Climate disclosure | climatebert/climate_sentiment | 72.0 | 70.0 | 60.3 | 63.3 |
| Contract yes/no | nguha/legalbench | 87.7 | 91.3 | 79.7 | 67.7 |
| Fact-check need | kalyan-ks/fact-check-need-classification | 75.0 | 76.0 | 73.7 | 60.3 |
| Medical abstract topic | TimSchopf/medical_abstracts | 63.0 | 59.7 | 58.3 | 59.7 |
| Science yes/no | allenai/sciriff-yesno | 85.0 | 84.7 | 80.0 | 70.0 |
| Argument stance | AIcademic/iam-stance | 89.7 | 83.7 | 78.3 | 64.3 |
| Statute entailment | nguha/legalbench | 61.8 | 65.4 | 51.1 | 56.6 |
| Web page topic | agentlans/en-document-topic-classification | 79.3 | 78.0 | 73.0 | 67.0 |
| Business decisions | fastino/fast-decisions | 60.8 | 63.7 | 58.8 | 76.6 |
| Business records | LocalLLaMA/typed-decisions | 50.3 | 57.1 | 58.4 | 60.8 |
| Long passages | tasksource/ConTRoL-nli | 61.7 | 59.7 | 49.0 | 44.7 |
| Long business threads | fastino/fast-decisions | 55.3 | 51.3 | 34.7 | 41.7 |
| Long business records | LocalLLaMA/typed-decisions | 47.3 | 33.3 | 46.7 | 37.0 |
| Airline intent ¹ | tuetschek/atis | 89.0 | 96.0 | 67.0 | 71.0 |
| Claim stance ¹ | ibm-research/claim_stance | 92.3 | 82.7 | 67.7 | 55.3 |
| Symptom diagnosis ¹ | gretelai/symptom_to_diagnosis | 41.5 | 43.9 | 42.5 | 36.3 |
| Newsgroup topic ¹ | SetFit/20_newsgroups | 64.7 | 68.0 | 58.3 | 71.7 |
Best score per task in bold. ¹ Not trained on, but used to choose between training recipes, so not counted as never seen.
Notes on the tasks:
- Science yes/no draws mostly on PubMedQA. The training data has other PubMedQA questions, with no shared abstracts.
- Long passages (ConTRoL) are up to 1,800 tokens. Long business threads and Long business records place test questions from the two business sets inside threads of 2,000 to 5,800 tokens of other messages or records; the model has to answer about the one marked CURRENT.
- The contract and policy yes/no training rows (ShARC, ConditionalQA, unfair_tos) were also checked against the contract test texts for any shared 8-word run.
Speed (RTX 4080): about 35 ms per call through the pipeline for a short text with a few options, and about 11 ms
for the model alone with torch.compile and fp16. On 2 CPU threads a short call takes about 0.2 s; a text near the
4,096-token limit takes tens of seconds.
Usage notes
- Write the question you want answered. "Which topic is this news article about?" works better than a bare label list.
- Options can be descriptions as well as labels:
"escalate: a person must look at this now". Each option is cut to 48 tokens and the question to 96. - Yes/no: use
["yes", "no"]as the labels; the score of "yes" is P(yes). For a statement, ask "Is this true: ...?". - Many options are fine. Option lists longer than 4,096 tokens are scored in several passes; options never read each other, so the result is the same as one pass.
- Long texts: text, question and the longest option share 4,096 tokens, and the text is cut at the end. With a text near the limit, adding a long option cuts the text a little more for all options.
- Half precision:
pipeline(..., device=0, dtype=torch.bfloat16)uses about 1 GB of GPU memory and gave the same accuracy as fp32 on 200 held-out training-distribution questions. - Scores use a temperature fitted on held-out questions. The average calibration error is 0.09 across all test sets but 0.16 on the 13 never-seen tasks, where the model is overconfident. Check thresholds on your own data.
Architecture
[CLS] text [SEP] question -> | option 1 [SEP] | option 2 [SEP] | ...
All options sit in one sequence. Every option block starts at the same position number and may read only the text,
the question and itself; the text and question do not read the options. Each option's tokens are averaged, a small
two-layer head gives one score per option, and a softmax runs over the options. Because of this attention pattern
the answer does not depend on option order, and the text is encoded once for all options in a pass.
modeling_zeroshot_choice.py (about 160 lines) contains the whole model.
Training
- Base model: cross-encoder/ettin-reranker-400m-v1, a ModernBERT-architecture reranker built on jhu-clsp/ettin-encoder-400m, with a new option head.
- Data: 1.63 million questions from 123 sources: NLI, topic and intent classification, stance, sentiment, fact verification, multiple-choice QA, contracts, support tickets and agent actions, plus program-written questions (rule checks, policy decisions, spatial reasoning and moves in simple grid games). Train splits only. Every row was checked against every test set above for shared 13-word runs. The full list, with row counts and licenses, is in TRAINING_DATA.md.
- Recipe: one epoch, learning rate 7e-6 (head 3e-4), inputs up to 4,096 tokens, cross-entropy over the options, then a temperature fitted on held-out questions.
- Final weights: the 50/50 average of the weights of two runs from the same start and recipe: one on the final data, one on an earlier version without the contract, policy and article-stance rows. In a comparison on 1,000 questions per test set, the average answered more questions correctly than either run.
Limitations
- English only.
- It picks among the options you give. It cannot say "none of these" unless you add that as an option.
- Weaker on structured records where the answer follows from rules over many fields, and on fine-grained intent sets with near-synonym labels.
- Most test sets have 300 questions; a difference of 1 to 2 points on a single task is within noise.
License
Weights and code: Apache 2.0, the same license as the base model cross-encoder/ettin-reranker-400m-v1. The underlying Ettin encoder is MIT-licensed. The training data comes from many datasets, each under its own license (including CC BY, CC BY-SA, CC BY-NC and MIT); the weights' license does not change those terms. See TRAINING_DATA.md and check the terms that apply to your use.
- Downloads last month
- 43
Model tree for kavoye/zeroshot-choice-400m
Base model
jhu-clsp/ettin-encoder-400mDatasets used to train kavoye/zeroshot-choice-400m
facebook/anli
google/civil_comments
Evaluation results
- Accuracy on Climate disclosure (never seen in training)test set self-reported72.000
- Accuracy on Contract yes/no (never seen in training)test set self-reported87.700
- Accuracy on Fact-check need (never seen in training)test set self-reported75.000
- Accuracy on Medical abstract topic (never seen in training)test set self-reported63.000
- Accuracy on Science yes/no (never seen in training)test set self-reported85.000
- Accuracy on Argument stance (never seen in training)test set self-reported89.700
- Accuracy on Statute entailment (never seen in training)test set self-reported61.800
- Accuracy on Web page topic (never seen in training)test set self-reported79.300