At a glance
| Model card | cross-encoder/ms-marco-MiniLM-L-12-v2 |
|---|---|
| Browser ONNX build | Xenova/ms-marco-MiniLM-L-12-v2 |
| Task & pipeline | text-ranking via text-classification (AutoModelForSequenceClassification, num_labels = 1, raw Identity logit) |
| Architecture | BertForSequenceClassification (MiniLM-L12-H384-uncased, 12 layers, 12 heads, 384-d, 30,522 WordPiece vocab) |
| Context window | 512 tokens max pair budget ([CLS] query [SEP] passage [SEP]) |
| Quantization & size | q8 CPU WASM — 34.20 MB (onnx/model_quantized.onnx, 34,201,341 bytes) |
| License & runtime | Apache-2.0 · shared ../../lib/webai.js (@huggingface/transformers@3.7.5 + module Web Worker) |
Run it — live 12-layer cross-encoder reranker
Identity output head (relevant hits typically score > 0 up to +10,
while irrelevant passages drop down to -11). We sort by raw logit and display calibrated
sigmoid σ(z), listwise softmax p, and the live score gap vs runner-up #2.
Tip: drag and drop a file onto this zone or press Ctrl/⌘+V anywhere outside an input to load custom passages.
| Rank | Candidate passage | Raw logit z | Sigmoid σ(z) | Softmax | Pair tokens | Lexical overlap |
|---|---|---|---|---|---|---|
| Waiting for live cross-encoder inference… | ||||||
See inside — raw logit spectrum & pair WordPiece tokens
Inspect the unbounded logit distribution across candidates and the exact WordPiece tokens fed into
[CLS] query [SEP] passage [SEP] for the top-ranked result.
Rerank passages above to inspect the live WordPiece pair encoding.
Why it matters — 12-layer precision in 34.2 MB
Doubling depth from 6 layers (ms-marco-MiniLM-L-6-v2) to 12 layers
(ms-marco-MiniLM-L-12-v2) sharpens cross-attention over negation, relational roles, and
multi-hop conditions while staying only 34.20 MB quantized to q8 ONNX and
running in ~50 ms on CPU WebAssembly without WebGPU.
- Zero-server RAG precision stage: pair a 24 MB bi-encoder retriever with this 34 MB 12-layer reranker completely offline.
- Unbounded ranking separation: raw logits separate true answers from keyword-stuffed distractors by 10+ logits.
- Private enterprise search: evaluate sensitive incident runbooks, clinical notes, or contracts without data leaving the tab.
Use-case ladder
-
Basics — 12-Layer Cross-Attention, Token Budget Audit & Sigmoid Curve:
audit live
128 → 512WordPiece truncation boundaries, inspectσ(z)saturation, and compare exact-word traps vs paraphrases. - Practical — Multi-Query Enterprise Search Benchmark Bench: upload RFC 4180 CSV/JSON/MD/TXT corpora, run cancellable FIFO multi-query evaluation, and measure live MRR@5, nDCG@5, and Top-1 Recall.
- Wild — Lexical Overlap, Negation, Antonym & Length-Bias Stress Lab: test 6 adversarial ranking probes including BM25 keyword stuffing, negation inversion, zero-keyword synonyms, and 512-token overflow traps.
-
Multi-model — 58.6 MB Retrieve-then-Rerank Studio:
chain
mxbai-embed-xsmall-v1(24.45 MB bi-encoder) withms-marco-MiniLM-L-12-v2(34.20 MB cross-encoder) and inspect live Spearmanρand rank shifts.
How the API works
import { AutoTokenizer, AutoModelForSequenceClassification } from "@huggingface/transformers";
const modelId = "Xenova/ms-marco-MiniLM-L-12-v2";
const tokenizer = await AutoTokenizer.from_pretrained(modelId);
const model = await AutoModelForSequenceClassification.from_pretrained(modelId, {
device: "wasm",
dtype: "q8",
});
// Joint cross-attention pair encoding: [CLS] query [SEP] passage [SEP]
const inputs = tokenizer(
passages.map(() => query),
{ text_pair: passages, padding: true, truncation: true, max_length: 512 },
);
const { logits } = await model(inputs); // shape [N, 1] raw Identity relevance logits