At a glance
| Model (Upstream & ONNX) | MongoDB/mdbr-leaf-ir |
|---|---|
| Task / pipeline | sentence-similarity via Transformers.js feature-extraction (pooling: "mean", normalize: true) |
| Architecture | BertModel (MiniLM-L6-v2 LEAF backbone) · 23M params · 6 layers · 12 heads · 384-d ONNX output (64d–384d MRL) · 512 max tokens · 30,522 WordPiece vocab (SentenceTransformers adds an optional 2_Dense 384→768 teacher projection) |
| Asymmetric prompt | Queries: "Represent this sentence for searching relevant passages: " · Passages: no prefix |
| Quantization & size | q8 ONNX (model_quantized.onnx 0.22 MB + model_quantized.onnx_data 22.95 MB = 23.17 MB) |
| Backend | CPU WebAssembly (wasm) via shared lib/webai.js — no WebGPU required |
| License | Apache-2.0 |
| Web APIs | WebAssembly, dedicated module Web Workers, Cache Storage, FileReader/Blob — all Baseline widely available |
Run it — Live Asymmetric Semantic Search Explorer
Type a search question and compare it against candidate passages locally on your CPU. Toggle MongoDB's asymmetric query prefix to measure the real cosine separation gain between relevant answers and distractors.
Initialise MDBR-LEAF-IR above to embed the query and passages live on your device.
See inside — 384-d unit vector & diagnostics
The browser ONNX graph (onnx/model_quantized.onnx) outputs a 384-dimensional L2-normalized vector
(norm = 1.0000) directly from the MiniLM-L6-v2 LEAF backbone without the separate SentenceTransformers
2_Dense (384→768) projection layer. Dashed guides at 64d, 128d, and 256d mark Matryoshka (MRL)
truncation boundaries probed live in Basics.
Tensor & runtime telemetry
Strongest query dimensions
Top 6 coordinates by absolute magnitude in the live query vector.
Why it matters
mdbr-leaf-ir outperforms models 2× its size on standard retrieval benchmarks and runs on any
CPU via WebAssembly in tens of milliseconds — making private, offline semantic search genuinely practical in
every browser tab.
- Zero-server documentation & FAQ search — index product manuals or personal notes locally with zero API keys or data leaving the device.
- Matryoshka-compressed vector stores — slice 384-d vectors down to 128-d or 64-d for tiny IndexedDB / OPFS client-side search indexes.
- Fast Stage 1 recall for two-stage RAG — retrieve top candidates in ~60 ms, then hand a tight shortlist to a cross-encoder reranker (see Multi-model).
- Teacher-aligned asymmetric search — in SentenceTransformers, adding the checkpoint's
2_Dense(384→768) projection aligns lightweight queries against server-indexed 768-dsnowflake-arctic-embed-m-v1.5document collections; this browser ONNX suite uses the standalone 384-d backbone for both queries and passages.
Use-case ladder
Basics — Asymmetric Prefix & MRL Lab
Compare prefixed vs unprefixed queries live, inspect the N×N cosine heatmap canvas, and probe 64d–384d Matryoshka retention.
Practical — Local Knowledge-Base Workbench
Upload or paste custom docs with auto-chunking, toggle MMR diversity, run Recall@1 / MRR batch evals, and export CSV/JSON.
Wild — 2D PCA Constellation & Query Compass
Explore 20 multi-topic passages projected into 2D PCA where live queries shoot cosine attraction rays to their nearest clusters.
Multi-model — 2-Stage Search + Rerank Bump Chart
Combine MDBR-LEAF-IR (23.17 MB) recall with MS MARCO MiniLM Cross-Encoder (23.14 MB) reranking and inspect live rank shifts.
How the API works
In Transformers.js, load MongoDB/mdbr-leaf-ir as a feature-extraction pipeline on
wasm with dtype: "q8". Prepend the search prompt to queries only, then call the
pipeline with pooling: "mean" and normalize: true:
import { pipeline } from "@huggingface/transformers";
const extractor = await pipeline("feature-extraction", "MongoDB/mdbr-leaf-ir", {
device: "wasm",
dtype: "q8",
});
const PREFIX = "Represent this sentence for searching relevant passages: ";
const out = await extractor(
[PREFIX + "How do I persist large ML weights offline?", "OPFS lets workers stream binary weights locally."],
{ pooling: "mean", normalize: true },
);
// out.dims => [2, 384], unit-length float32 vectors; cosine similarity = dot product