At a Glance & Model Contract
- Upstream Model
- sentence-transformers/msmarco-distilbert-base-v4
- Loaded ONNX Repo
- Xenova/msmarco-distilbert-base-v4
- Task & Pipeline
sentence-similarityviafeature-extraction- Backend & Download Size
WASM·q8(66.95 MB ONNX + 0.71 MB tok/cfg = 67.66 MB)- Architecture
distilbert· 6L · 12H ·dim: 768· 3,072 FFN · 66.4M params- Tokenizer, Pooling & License
DistilBertTokenizer·max_position_embeddings: 512·mean+ L2 ·apache-2.0
query:/passage:)
or BGE instruction prompts, msmarco-distilbert-base-v4 encodes raw queries and passages
through the same DistilBertModel + mean pooling (1_Pooling/config.json)
+ L2 normalization (trained with cosine similarity on 500k MS MARCO pairs, versus v3 dot-product).
Because queries and passages are projected to unit vectors, dot(q, p) === cosine(q, p).
Load & Cache Status
Run It — Live Asymmetric Query-to-Passage Retrieval
.txt, .md, .csv, or .json list of candidate passages.
Ranked Passage Retrieval
Initialise the model to embed query and passages locally.
2D PCA Asymmetric Query → Passage Map
Diamond = short query; dashed rays point to the top-3 highest-scoring passages in 768-d space.
See Inside — 768-d Tensor & DistilBertTokenizer Telemetry
768-d Query Embedding Sparkline & Distribution
Run inference to inspect live 768-d coordinate min, max, mean, std, and L2 norm.
Pairwise Cosine Similarity Matrix
Live Uncased WordPiece Tokenization (DistilBertTokenizer)
Run inference to inspect query and passage token counts, [CLS]=101, [SEP]=102,
[UNK]=100, L2 norms, and 512-token truncation status.
| Item | Tokens | [UNK] | Window | L2 Norm | Score |
|---|---|---|---|---|---|
| Run retrieval above to inspect token telemetry. | |||||
Why It Matters — Asymmetric Semantic Search at 66.4M Params
Traditional keyword engines fail when a short user question ("how to stop a car on black ice") shares few words with the authoritative answer ("ease off the accelerator until tires regain traction on frozen pavement"). DistilBERT's 6-layer encoder cuts BERT-base latency in half while retaining 768-d representational capacity across a full 512-token passage window—all locally in the browser with zero server round-trips.
- Private client-side documentation & FAQ search: Embed thousands of help articles once, store 768-d vectors in IndexedDB/OPFS, and answer queries offline.
- Zero-server RAG Stage 1 recall: Shortlist top-K passages in milliseconds before handing pairs to a cross-encoder reranker or local LLM.
- 512-token passage support: Four times the 128-token ceiling of MiniLM sentence-transformers, fitting full paragraphs without tail clipping.
Use-Case Ladder
- Basics — Asymmetric Query-vs-Passage Similarity, Pooling & Norm Sensitivity
- Practical — MS MARCO Corpus Search & Live MRR@5 / nDCG@5 Evaluation
- Wild — Vocabulary Mismatch, Length Dilution & Adversarial Stress Probes
- Multi-model — Two-Stage Retrieval (DistilBERT Bi-Encoder → MiniLM-L12 Cross-Encoder)
How the API Works & Show the Code
import { pipeline } from "@huggingface/transformers";
const extractor = await pipeline("feature-extraction", "Xenova/msmarco-distilbert-base-v4", {
device: "wasm",
dtype: "q8",
});
const out = await extractor([query, ...passages], { pooling: "mean", normalize: true });
// out.dims => [1 + passages.length, 768]; dot(queryVec, passageVec) === cosine similarity