← All models

zero-shot-classification Β· text Β· WASM Β· ~309 MB

BART-large-MNLI β€” the canonical zero-shot classifier

When people say "just use zero-shot classification," this is usually the model they mean: facebook/bart-large fine-tuned on MultiNLI. It takes your labels, invented on the spot, and scores how well each fits the text β€” no training, no fixed categories. The trick is natural-language inference: it asks "does this text imply 'This example is {your label}'?" and reads off the entailment. It's a big model (~309 MB, 406M parameters) so it's slower and heavier than the tiny DeBERTa-v3 zero-shot page β€” but it's the reference implementation, and below you can run the same text through both and see where they differ. Nothing leaves your device.

At a glance

ModelXenova/bart-large-mnli (ONNX build of facebook/bart-large-mnli)
Task / pipelinezero-shot-classification (via natural-language inference)
How it workseach label becomes a hypothesis "This example is {label}."; the model's entailment probability is the label's score
ArchitectureBART-large (12-layer encoder + 12-layer decoder, ~406M params) fine-tuned on the MultiNLI entailment dataset
Modessingle-label (labels compete, softmax) or multi-label (each scored independently)
Quantizationq4f16 (4-bit weights + fp16 compute) ONNX β€” model_q4f16.onnx. Deliberately not q8: the int8 build of this model is badly degraded (near-uniform, often wrong); q4f16 restores full accuracy at a smaller download.
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~309 MB, cached after first load (larger than DeBERTa-xsmall's ~70 MB)
LicenseMIT
Web APIsWebAssembly, Web Workers β€” all Baseline widely available

Run it

Type some text and your candidate labels (comma-separated). Each label is scored against the text via entailment; the winner is the one the model most entails. First run downloads ~309 MB and warms up the session, so the initial classification takes a moment.

Contrast β€” BART vs DeBERTa on the same input

Both models do zero-shot the same way (NLI entailment), but they're different backbones trained on different data: BART-large-MNLI (406M params, MultiNLI) vs DeBERTa-v3-xsmall (22M params, from the other page). Loading DeBERTa here adds a one-time ~70 MB download; then it runs the same text + labels through both so you can see where a 18Γ— larger model actually changes the answer β€” and where the tiny one keeps up.

See inside β€” the entailment logits per hypothesis

This is the NLI-as-classifier mechanism laid bare. For every label the model runs one NLI pass and outputs three numbers: how much the text contradicts, is neutral toward, or entails the hypothesis "This example is {label}." The label's score is that entailment slice. Below is the real 3-way distribution for each label β€” the labels that win are simply the ones the model most entails. There is no classification head with fixed categories anywhere in here; the "classifier" is entirely the entailment probability of a sentence you wrote at run time.

Classify some text above to inspect the entailment logits.

Why it matters

Zero-shot classification means you never have to collect a labelled dataset or train a model to sort text β€” you describe the buckets you want in plain words and change them whenever you like. That's the difference between a two-week ML project and a one-line config. BART-large-MNLI is the model most tutorials, papers, and pipelines reach for, so its behaviour is the reference point other zero-shot classifiers get compared against β€” and here it runs entirely in a tab, nothing leaving the browser.

Use cases

Basics

Type text, invent labels, and watch the canonical zero-shot model score each one β€” no training.

Practical

Intent routing / triage: sort an inbox into custom business categories, then route to a queue.

Wild

Surprising label sets & multi-label overlap β€” see how far you can push zero-shot with weird buckets.

Multi-model

Zero-shot route β†’ run the chosen downstream model (summarize / extract) on just the matched text.

How the API works

You pass the text and your labels; the pipeline builds a hypothesis per label and ranks them:

import { pipeline } from "@huggingface/transformers";

const classifier = await pipeline(
  "zero-shot-classification",
  "Xenova/bart-large-mnli",
  { dtype: "q4f16" }, // NOT q8 β€” int8 wrecks this model's accuracy; q4f16 is smaller AND correct
); // downloads + caches ~309 MB once

const out = await classifier(
  "The phone overheats and the battery drains fast.",
  ["hardware fault", "software bug", "billing problem"],
  { multi_label: false }, // labels compete via softmax; true = independent scores
);
// β†’ { labels: ["hardware fault", …], scores: [0.91, …] }  (sorted)

"See inside" reuses the same loaded model (classifier.model + classifier.tokenizer) to run each (text, hypothesis) pair itself and read the raw contradiction / neutral / entailment logits. Everything runs in a Web Worker so classifying β€” and loading a second model to compare β€” never janks the page.

References