At a glance
| Model (ONNX) | onnx-community/ModernBERT-base-nli-ONNX (upstream: tasksource/ModernBERT-base-nli) |
|---|---|
| Task / pipeline | zero-shot-classification (natural language inference) |
| Backbone & NLI head |
answerdotai/ModernBERT-base · 22 layers · 768 hidden · RoPE +
128-tok local / every-3rd-layer global attention ·
id2label: {0: entailment, 1: neutral, 2: contradiction}
|
| Context window |
2,048 config max_position_embeddings (base ModernBERT
trained to 8,192; tokenizer.model_max_length unclipped, tested to
3,068 tok in WASM)
|
| Quantization & size | q8 (onnx/model_quantized.onnx · 150,873,420 B · 150.87 MB) |
| Runtime & backend |
Shared @huggingface/transformers@3.7.5 on WebAssembly (wasm)
in a dedicated module Web Worker
|
| License | Apache-2.0 |
| Web APIs | WebAssembly, Web Workers, Cache Storage, File & Clipboard APIs |
Run it — Zero-Shot & Policy Classifier
Initialise ModernBERT-Base NLI above to classify text locally on your device.
See inside — raw 3-way NLI logits per hypothesis
Unlike older NLI checkpoints where class 0 is contradiction,
onnx-community/ModernBERT-base-nli-ONNX stores
id2label = {0: entailment, 1: neutral, 2: contradiction}. The worker resolves
these indices dynamically from model.config.id2label and exposes every raw
logit and softmax probability below.
| Candidate label | Entailment (prob / logit) | Neutral (prob / logit) | Contradiction (prob / logit) | 3-way split | Pair tokens |
|---|---|---|---|---|---|
| Run classification above to inspect raw 3-way NLI logits. | |||||
Why it matters
Classic DeBERTa and RoBERTa NLI classifiers clip inputs at 512 tokens, dropping rules at the end of contracts, DPAs, or multi-paragraph support threads. ModernBERT-Base NLI preserves zero-shot flexibility while keeping multi-thousand-token context intact inside the user's browser.
- Long-policy clause detection — catch obligations or exceptions buried past token 512 without brittle text chunking.
- Dynamic taxonomy routing — add, rename, or test multi-label categories in plain English with zero retraining.
-
Framing control — tune the
hypothesis_templatefor sentiment, policy obligation, or topic classification on the same weights.
Use-case ladder
Basics · Hypothesis Framing & Length Audit
Compare hypothesis templates side-by-side and benchmark 256 → 512 → 1,024+ token NLI against a 512-token BERT clip.
Practical · Zero-Shot Auto-Router & Triage
Upload CSV/JSON/MD/TXT ticket or policy queues, stream cancellable FIFO triage, and export formula-safe CSV + JSON reports.
Wild · Negation, Dilution & Needle Lab
Stress-test double negation, if/unless rules, 3 → 8 → 12 distractor dilution, and needle placement across long premises.
Multi-model · Rampart PII → ModernBERT NLI
165.6 MB privacy-first pipeline: Stage 1 strips raw PII locally before Stage 2 runs long-context compliance routing.
How the API works & source inspection
import { pipeline } from "@huggingface/transformers";
const classifier = await pipeline(
"zero-shot-classification",
"onnx-community/ModernBERT-base-nli-ONNX",
{ device: "wasm", dtype: "q8" },
);
const out = await classifier(
premiseText,
["prohibits biometric retention", "allows unlimited biometric storage"],
{ hypothesis_template: "This policy {}.", multi_label: false },
);