← All models

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

Multilingual zero-shot β€” label text in many languages with categories you invent

Ordinary classifiers only know the labels they were trained on, in the one language they were trained in. This one takes your labels, made up on the spot, and scores how well each fits the text β€” in German, Spanish, French, Chinese, Arabic, Hindi and dozens more. It works by asking a multilingual natural-language-inference model "does this text imply 'This example is {your label}'?" and reading off the entailment. Unlike the English DeBERTa zero-shot page, the backbone is mDeBERTa-v3 (100-language SentencePiece vocab, fine-tuned on XNLI) β€” and you can even write the hypothesis template in the text's own language. Nothing leaves your device.

At a glance

ModelMoritzLaurer/mDeBERTa-v3-base-mnli-xnli (ONNX shipped in the canonical repo)
Task / pipelinezero-shot-classification (via multilingual natural-language inference)
How it workseach label becomes a hypothesis "This example is {label}." (template editable, per-language); the model's entailment probability is the label's score
Languagestrained/evaluated on the XNLI 15 (en, fr, es, de, el, bg, ru, tr, ar, vi, th, zh, hi, sw, ur); the mDeBERTa-v3 backbone covers ~100 languages, so many more transfer
ArchitecturemDeBERTa-v3-base (12 layers, ~86M transformer params + a large 250k-token SentencePiece embedding, ~278M total) fine-tuned on MNLI + XNLI
Head3-way sequence-classification: entailment / neutral / contradiction (config order: entailment = index 0)
Modessingle-label (labels compete, softmax) or multi-label (each scored independently)
Quantizationq8 (8-bit) ONNX β€” rankings verified correct across languages; margins are a touch flatter than fp32
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~339 MB (the 250k-token vocab is large), cached after first load
LicenseModel weights: MIT; Transformers.js runtime: Apache-2.0
Web APIsWebAssembly, Web Workers β€” all Baseline widely available

Run it

Pick a language sample or paste your own text and candidate labels (comma-separated). Each label is scored against the text; the winner is the one the model most entails. Try writing the hypothesis template in the text's language for sharper scores.

See inside β€” the entailment logits per hypothesis

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. 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, in whatever language you gave it.

Classify some text above to inspect the entailment logits.

Why it matters

Most zero-shot classifiers are English-only. One multilingual model means you describe the buckets you want in plain words β€” once β€” and sort text in any of dozens of languages into them, changing the labels whenever you like and never collecting a dataset or training a model. Because it runs in a tab, you can triage, route, and tag multilingual text on-device with nothing leaving the browser.

Use cases

Basics

Switch languages, invent labels, and watch the same model score each one β€” no training.

Practical

Route a mixed-language support inbox into custom business categories, one model for every locale.

Wild

Cross-lingual label transfer: classify text in one language with labels written in another.

Multi-model

Translate β†’ classify: pair with a multilingual translator, or tag entities then classify the topic.

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",
  "MoritzLaurer/mDeBERTa-v3-base-mnli-xnli",
); // downloads + caches ~339 MB once

const out = await classifier(
  "Die Regierung hat ein neues Klimagesetz verabschiedet.",
  ["Politik", "Sport", "Technologie"],
  { hypothesis_template: "In diesem Text geht es um {}.", multi_label: false },
);
// β†’ { labels: ["Politik", …], scores: [0.71, …] }  (sorted)

"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. Because XNLI aligns the entailment relation across languages, a template in the text's own language is usually better calibrated than the English default. All of it runs in a Web Worker so classifying never janks the page.

References