Skip to content
Goal: Proficient✓ Sources verified 2026-11-24BM25RRFCross-encoder

Hybrid Search and Rerank ​

Vector search alone often fails to find contract numbers, product model numbers and proper nouns. Hybrid search + rerank is standard for production RAG.

Core concepts ​

MethodGood atBad at
Vector search (semantic)Synonyms, questions phrased differentlyExact IDs, code, rare proper nouns
Keyword search (BM25 / full text)Exact words, IDs, terminologyParaphrases
Rerank (cross-encoder reranking)Precise ranking of a few candidates, high accuracySlow, can't run over the whole corpus

Typical pipeline: vector top-50 + keyword top-50 → fusion → rerank to top-5 → LLM.

How it works ​

RRF (Reciprocal Rank Fusion) ​

The two retrievers score on different scales (cosine similarity vs BM25 score), so adding them directly is meaningless. RRF uses only the rank:

RRF_score(d) = Σ  1 / (k + rank_i(d))      k is usually 60
  • From the 2009 SIGIR paper by Cormack, Clarke and Buettcher; the official pgvector README also recommends RRF or a cross-encoder for combining hybrid search results.
  • Advantages: no normalization, no weight tuning, simple to implement.

Bi-encoder vs Cross-encoder ​

  • Bi-encoder (embedding retrieval): the question and the document are encoded separately, so document vectors can be precomputed, which makes it fast.
  • Cross-encoder (rerank model): "question + document" go into the model together for scoring, so it sees the interaction between them. It's more accurate but must be computed online pair by pair, so it is only used on a small set of candidates.

In practice: RRF in PostgreSQL ​

sql
WITH semantic AS (
  SELECT id, ROW_NUMBER() OVER (ORDER BY embedding <=> $1) AS rnk
  FROM chunk ORDER BY embedding <=> $1 LIMIT 50
),
keyword AS (
  SELECT id, ROW_NUMBER() OVER (ORDER BY ts_rank_cd(tsv, q) DESC) AS rnk
  FROM chunk, plainto_tsquery('simple', $2) q
  WHERE tsv @@ q ORDER BY ts_rank_cd(tsv, q) DESC LIMIT 50
)
SELECT id, SUM(1.0 / (60 + rnk)) AS score
FROM (SELECT * FROM semantic UNION ALL SELECT * FROM keyword) t
GROUP BY id ORDER BY score DESC LIMIT 20;

Then pass these 20 to a rerank model (such as Cohere Rerank, Voyage rerank or the open-source bge-reranker) and keep the top 5.

Common pitfalls ​

  1. Too many rerank candidates: latency grows linearly; keep it to a few dozen at most.
  2. Tuning fusion without looking at parsing: poor retrieval is usually a chunking and parsing problem.
  3. No evaluation: without recall numbers you can't tell whether adding rerank is worth it (see RAG Evaluation).

Common interview questions ​

  1. Why do you need hybrid search? Give an example where pure vector search fails.
  2. What is the RRF formula and what are its advantages? What does k=60 mean?
  3. What's the difference between a bi-encoder and a cross-encoder? Why can rerank only be used on a few candidates?
  4. How much latency do hybrid search + rerank add? How do you weigh that?

How it relates to my projects ​

Sources ​

Vin Amory · AI development × content creation · Technical notes cite official docs in each page’s sources section