Multi-model · Retrieve then rerank · ~173.4 MB total · WASM q8

ModernBERT Embed recall → MS MARCO cross-encoder rerank

A two-stage hybrid retriever in one browser tab. Stage 1 (nomic-ai/modernbert-embed-base, 150.3 MB) embeds the query and every passage with the search_query: / search_document: prefixes and shortlists by cosine — at full 768d or a 3× smaller 256d Matryoshka slice. Stage 2 (Xenova/ms-marco-MiniLM-L-6-v2, 23.1 MB, reusing the site's MS MARCO reranker worker) reads each query–passage pair together and reorders the shortlist. The bump chart shows every rank change.

1. Two independent models (~173.4 MB combined)

Stage 1 · ModernBERT Embed bi-encoder (150.3 MB)

Stage 2 · MS MARCO MiniLM cross-encoder (23.1 MB)

Initialise both models above to run Stage 1 → Stage 2 locally. Either can be released on its own.

2. Query, corpus & stage controls

Stage 1 embed–
256d vs 768d top-K–
Relevant in shortlist–
Stage 2 rerank–
Spearman ρ–
Top-1 after rerank–
Max promotion–

3. Rank-shift bump chart

Left: Stage 1 rank and cosine at the chosen vector size. Right: Stage 2 rank and raw cross-encoder logit. Green ribbons were promoted by the cross-encoder, red ribbons demoted (often keyword look-alikes that do not answer the question).

Stage 1 bi-encoder vs Stage 2 cross-encoder
Final # Stage 1 # Shift Passage Cosine Logit Sigmoid

Stage 1 shortlist (256d vs 768d)

The shortlist actually sent to Stage 2, with the rank each passage would have had at the other vector size.

    The code

    Show the code — Stage 1 → Stage 2 rank shifts & Spearman ρ (modernbert-core.mjs) computeRankShifts()
    Show the code — FIFO client for the shared reranker worker (modernbert.js) MsMarcoRerankerClient