← All models

text-classification · natural-language inference · WASM · ~25 MB

MobileBERT — the tiny judge

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.

At a glance

ModelXenova/mobilebert-uncased-mnli (ONNX) · original google/mobilebert-uncased
Tasktext-classification — NLI (entailment / neutral / contradiction)
ArchitectureMobileBERT — 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)
BackendWebAssembly (CPU) — no GPU required
Download~25 MB, cached after first load
LicenseApache-2.0
Web APIsWeb Workers, Cache Storage (via Transformers.js), WebAssembly

Run it

See inside — three-way probability

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.

Why it matters

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.

Use cases

Basics

The three-way judgment — premise vs hypothesis with real probabilities.

Practical

Summary fidelity checker: paste a source and a summary, get entailment scores.

Wild

Contradiction bench — craft sneaky hypotheses and see which the 25 MB judge catches.

How the API works

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.

References