text-classification · natural-language inference · WASM · ~25 MB
Natural-language inference asks: given a premise, does a hypothesis follow (entailment), contradict it, or stay neutral? MobileBERT is Google's mobile-optimized BERT — a bottleneck architecture that keeps BERT-base's quality at a fraction of the size. This MNLI fine-tune answers with real probabilities, on-device, in 25 megabytes.
| Model | Xenova/mobilebert-uncased-mnli (ONNX) · original google/mobilebert-uncased |
|---|---|
| Task | text-classification — NLI (entailment / neutral / contradiction) |
| Architecture | MobileBERT — bottleneck layers + grouped attention, fine-tuned on MNLI (~95% of BERT-base quality at ~1/4 the size) |
| Params / dtype | ~25M · int8 (8-bit quantized ONNX) |
| Backend | WebAssembly (CPU) — no GPU required |
| Download | ~25 MB, cached after first load |
| License | Apache-2.0 |
| Web APIs | Web Workers, Cache Storage (via Transformers.js), WebAssembly |
MNLI scores the hypothesis against the premise across three classes; the bars are the model's real softmax probabilities. The green bar is its verdict. Because MobileBERT is tiny, this runs in milliseconds on a plain CPU — try flipping a word in the hypothesis and watch the probabilities move.
NLI is the workhorse of consistency checking: does a summary match the source, does an answer follow from the evidence, does a claim contradict known facts? MobileBERT makes that judgment fast enough and small enough for on-device, real-time use.
The friendly one-liner is the text-classification pipeline:
import { pipeline } from "@huggingface/transformers";
const clf = await pipeline("text-classification", "Xenova/mobilebert-uncased-mnli", { dtype: "int8" });
const out = await clf("The sky is clear. It is a sunny day.", { topk: 3 });
// [{label:"entailment", score:0.99}, {label:"neutral",…}, {label:"contradiction",…}]
The premise + hypothesis are concatenated into one input; the model classifies the pair. Everything runs in a Web Worker off the main thread.