Skip to main content
Home › Categories › Artificial Intelligence & Computing › Semantic Search, BM25 Lexical Retrieval, and Cross-Encoder Reranking

Semantic Search, BM25 Lexical Retrieval, and Cross-Encoder Reranking

Author: ZUVDEX Team 4 min read
semantic search vs bm25 reranking okapi bm25 inverted index bi encoder vs cross encoder reranker sparse splade bge m3 retrieval colbert late interaction maxsim reciprocal rank fusion rrf

Modern information retrieval—powering enterprise search bars, e-commerce product discovery, legal e-discovery, and the retrieval core of every RAG system—rests on a clear empirical lesson: neither pure keyword search nor pure dense vector search wins every query alone. Production search architectures fuse exact lexical retrieval (Okapi BM25 or learned sparse vectors), dense bi-encoder semantic retrieval, Reciprocal Rank Fusion (RRF), and a final high-precision Cross-Encoder Reranker.

Key Highlights

  • Okapi BM25 over an inverted index scores exact term frequency with saturation (k1) and document-length normalization (b), excelling on part numbers, error codes, proper nouns, and statutes.
  • Dense Bi-Encoders compress queries and passages independently into vectors (384–1,536 dims) to bridge vocabulary mismatch ("cardiac arrest" matching "heart attack"), but blur rare exact strings.
  • Learned Sparse (SPLADE) and Multi-Vector Late-Interaction (ColBERT MaxSim) models bridge exact token precision and contextual semantics.
  • Cross-Encoder Rerankers concatenate `[Query, Candidate Passage]` inside full bidirectional self-attention over the top 50–100 retrieved candidates—boosting NDCG@10 by 8%–18% across out-of-domain BEIR benchmarks.

BM25, Dense Bi-Encoders, SPLADE, ColBERT, and Cross-Encoders

Why can’t a Cross-Encoder simply score every document in a 10-million-passage corpus directly? Because full cross-attention requires running a forward pass over every `(query, document)` pair at query time—10 million neural evaluations would take minutes. Bi-encoders precompute document vectors once offline so HNSW indexes retrieve top-100 candidates in 4 milliseconds, handing a tiny shortlist to a Cross-Encoder Reranker that finishes in 25 milliseconds.

When merging raw BM25 scores (unbounded positive floats like `14.7`) with cosine similarities (`0.0` to `1.0`), naive addition breaks across queries of varying length; Cormack’s Reciprocal Rank Fusion `1 / (k + rank)` combines ranked lists cleanly with zero score-scale tuning.

Retrieval Tier Index Footprint Query Latency (10M Docs) Strengths & Blind Spots
Okapi BM25 (Inverted Index) Compact (~15% of raw text) 2–8 ms (CPU) Unbeatable on exact SKUs/acronyms; misses synonyms ("pto" vs "vacation")
Dense Bi-Encoder (HNSW) 1 vector / chunk (FP16/INT8/Binary) 3–10 ms Strong multilingual & conceptual recall; blurs exact rare IDs
ColBERTv2 (Multi-Vector) Compressed per-token vectors 10–25 ms Fine-grained token matching + semantics; larger storage footprint
Cross-Encoder Reranker None (scores top 50–100 live) +15–40 ms (GPU) Highest semantic & negation precision across query–passage pairs

Matryoshka Embeddings, Binary Quantization, and Hard-Negative Mining

Matryoshka Representation Learning trains nested vector prefixes so the first 256 dimensions of a 1,024-dimensional embedding retain >97% retrieval quality, while Binary / Scalar INT8 quantization shrinks vector RAM up to 32× when paired with FP32 rescoring over top-200 candidates.

  • Prepend document title and section breadcrumb headers into every chunk string before embedding so isolated paragraphs retain parent context.
  • Enforce user Access Control Lists (RBAC tenant/group filters) inside Stage-1 hybrid retrieval—never retrieve unauthorized documents and hope the LLM hides them.
  • Fine-tune domain bi-encoders with mined hard negatives (passages that look lexically similar but do not answer the query) for substantial recall jumps.

FAQs

Why is k = 60 standard in the Reciprocal Rank Fusion formula 1 / (k + rank)?

Cormack, Clarke, and Buettcher showed empirically that k = 60 dampens extreme outlier dominance from rank #1 of a single noisy retriever while rewarding documents that rank consistently near the top across both BM25 and dense semantic search.

Does a Cross-Encoder Reranker replace the need for good chunking and hybrid retrieval?

No—a reranker can only reorder the top 50–100 candidates handed to it by Stage 1; if Stage-1 retrieval misses the right paragraph entirely (Recall@100 = 0), no reranker can recover it.

References & Sources

  • Robertson, Stephen; Zaragoza, Hugo (2009) — The Probabilistic Relevance Framework: BM25 and Beyond, Foundations and Trends in Information Retrieval.
  • Thakur, Nandan et al. (2021) — BEIR: A Heterogeneous Benchmark for Zero-Shot Evaluation of Information Retrieval Models, NeurIPS.
  • Khattab, Omar; Zaharia, Matei (2020) — ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT, ACM SIGIR.