zero-shot-classification · text · multilingual · WASM · ~340 MB
The zero-shot trick — score any text against labels you make up on the spot, no training — but multilingual. mDeBERTa-v3 was pretrained on 100 languages and fine-tuned on cross-lingual natural-language inference, so the text, the labels, and even the hypothesis template can be in (almost) any language. Paste Spanish, Japanese, Arabic, or Hindi; classify with labels in the same language — or, remarkably, with English labels on non-English text. Look inside at the raw entailment logits doing the deciding. Nothing leaves your device.
| Model | MoritzLaurer/mDeBERTa-v3-base-mnli-xnli |
|---|---|
| Task / pipeline | zero-shot-classification (via natural-language inference) |
| How it works | each label becomes a hypothesis (default "This example is {label}."); the model's entailment probability is the label's score |
| Languages | pretrained on 100 languages (CC100); NLI fine-tuned on MNLI (English) + XNLI (15 languages) — generalises cross-lingually |
| Architecture | mDeBERTa-v3-base (multilingual DeBERTa-v3, model_type: deberta-v2), 3-way NLI head |
| Modes | single-label (labels compete, softmax) or multi-label (each scored independently) |
| Quantization | q8 (8-bit) ONNX |
| Backend | WebAssembly (runs anywhere; no WebGPU needed) |
| Download | ~340 MB, cached after first load |
| License | MIT |
| Web APIs | WebAssembly, Web Workers — all Baseline widely available |
Distinct from the built English DeBERTa zero-shot and BART-MNLI zero-shot demos: same NLI recipe, but a multilingual encoder — so it classifies text (and takes labels) in dozens of languages, not just English.
Pick a language sample or paste your own text, set your candidate labels (comma-separated, in any language), and classify. Each label is scored by how much the model entails it.
Language samples (text + matching labels):
For every label the model runs one NLI pass and outputs three numbers: how much the text entails, is neutral toward, or contradicts the hypothesis it built from your template and label. The label's score is that entailment slice. Because the encoder is multilingual, the exact hypothesis sentence — shown below each bar — can be in any language, and the model still reasons about whether your text implies it. That's the whole multilingual zero-shot mechanism, in the open.
A single multilingual model that classifies text against labels you define — with no training data in any language — collapses a stack of per-language ML projects into one config. Add a market, add a label, change your mind; nothing to retrain. And at ~340 MB it runs in a tab, so you can route, triage, and moderate text in dozens of languages on-device, with nothing leaving the browser.
Classify the same idea in six languages and watch the model score labels in each.
Multilingual intent routing & moderation: route an inbox of mixed-language messages.
Cross-lingual: keep English labels, throw any language at them, and it still works.
Detect the language first, then classify — a two-model multilingual pipeline.
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",
"MoritzLaurer/mDeBERTa-v3-base-mnli-xnli",
); // downloads + caches ~340 MB once
const out = await classifier(
"El nuevo teléfono tiene una cámara increíble.", // text in any language
["tecnología", "deportes", "política"], // labels in any language
{ multi_label: false, hypothesis_template: "This example is {}." },
);
// → { labels: ["tecnología", …], scores: [0.97, …] } (sorted)
// Cross-lingual works too — English labels on non-English text:
await classifier("这部电影的结局太仓促了。", ["technology", "movie", "sports"]);
"See inside" reuses the same loaded model (classifier.model +
classifier.tokenizer) to run each (text, hypothesis) pair itself and read the raw
entailment / neutral / contradiction logits. All of it runs in a Web Worker so classifying never janks
the page.