sentence-similarity · feature-extraction · 67.66 MB WASM q8 · Apache-2.0

msmarco-distilbert-base-v4 — Asymmetric MS MARCO Passage Retriever

A 66.4M-parameter, 6-layer DistilBertModel trained on 500k MS MARCO real Bing search query–passage pairs to embed short search queries and long candidate passages into a shared 768-d mean-pooled vector space (67.66 MB q8 CPU WASM via shared ../../lib/webai.js on @huggingface/transformers@3.7.5).

At a Glance & Model Contract

Task & Pipeline
sentence-similarity via feature-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
Asymmetric Query–Passage Design (No Prefix Required): Unlike E5 (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

Drop, paste, or upload a .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.

    Per-input WordPiece token counts, truncation flags, L2 norms, and similarity scores
    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.

    Use-Case Ladder

    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
    Show the code: Epoch-safe Web Worker pipeline loader (worker.js)
    Show the code: Cosine vs raw dot-product passage ranking (msmarco-core.mjs)

    References