Multi-model ยท 2-Stage Bi-Encoder Retrieval โ†’ Cross-Encoder Reranking

msmarco-distilbert-base-v4 โ†’ ms-marco-MiniLM-L-12-v2 Rerank

As shown in the Wild probes, bi-encoders retrieve fast at scale but miss negation flips and role swaps. Chain Stage 1 Xenova/msmarco-distilbert-base-v4 (67.66 MB q8 WASM) for dense Top-K candidate recall with Stage 2 Xenova/ms-marco-MiniLM-L-12-v2 (34.20 MB q8 WASM, reusing ../../ms-marco-minilm-l12/worker.js) for joint [CLS] query [SEP] passage [SEP] cross-attention reranking.

1. Load Both Stages (101.86 MB combined q8 WASM)

Stage 1 ยท msmarco-distilbert-base-v4 (67.66 MB ยท Apache-2.0)

Bi-encoder retriever (../worker.js, 768-d mean-pooled cosine)

Stage 2 ยท ms-marco-MiniLM-L-12-v2 (34.20 MB ยท Apache-2.0)

Cross-encoder reranker (../../ms-marco-minilm-l12/worker.js, 12-layer logits)

Initialise Stage 1 (msmarco-distilbert-base-v4) and Stage 2 (ms-marco-MiniLM-L-12-v2) above to run the 2-stage retrieve-then-rerank pipeline.

2. Retrieve Top-K (Stage 1) โ†’ Cross-Attention Rerank (Stage 2)

Drop, paste, or upload a .txt, .md, .csv, or .json list of candidate passages.
Pipeline Verdict: Run Stage 1 and Stage 2 above to see how cross-attention reranking promotes true passages over bi-encoder traps.

Stage 1 ยท DistilBERT Bi-Encoder Shortlist

Load Stage 1 to embed and shortlist candidates by 768-d cosine.

    Stage 2 ยท MiniLM-L12 Cross-Encoder Reranked

    Load Stage 2 to score joint [CLS] query [SEP] passage [SEP] logits.

      Stage 1 โ†’ Stage 2 Rank-Shift Waterfall

      Rank-Shift Waterfall Table

      Two-stage MS MARCO bi-encoder cosine vs cross-encoder logit and rank shift
      ID S1 Rank S1 Cos S2 Rank S2 Logit S2 Prob ฯƒ(z) Shift Passage
      Run both stages above to inspect live rank promotions and demotions.

      Show the Code

      Show the code: Reused Stage 2 MiniLM-L12 cross-encoder rerank() worker (ms-marco-minilm-l12/worker.js)
      Show the code: Stage 1 โ†’ Stage 2 rank-shift & Spearman correlation (msmarco-core.mjs)