← All models

zero-shot-classification · text · multilingual · WASM · ~340 MB

mDeBERTa zero-shot — label text in ~100 languages with categories you invent

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.

At a glance

ModelMoritzLaurer/mDeBERTa-v3-base-mnli-xnli
Task / pipelinezero-shot-classification (via natural-language inference)
How it workseach label becomes a hypothesis (default "This example is {label}."); the model's entailment probability is the label's score
Languagespretrained on 100 languages (CC100); NLI fine-tuned on MNLI (English) + XNLI (15 languages) — generalises cross-lingually
ArchitecturemDeBERTa-v3-base (multilingual DeBERTa-v3, model_type: deberta-v2), 3-way NLI head
Modessingle-label (labels compete, softmax) or multi-label (each scored independently)
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~340 MB, cached after first load
LicenseMIT
Web APIsWebAssembly, 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.

Run it

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):

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 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.

Classify some text above to inspect the entailment logits.

Why it matters

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.

Use cases

Basics

Classify the same idea in six languages and watch the model score labels in each.

Practical

Multilingual intent routing & moderation: route an inbox of mixed-language messages.

Wild

Cross-lingual: keep English labels, throw any language at them, and it still works.

Multi-model

Detect the language first, then classify — a two-model multilingual pipeline.

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 ~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.

References