GOAT EngineerPreparing your learning space…

AI Engineering · Concept Library · Free article

Hybrid Search & Reranking

Hybrid search runs a keyword retriever beside the vector one and fuses the two ranked lists, because their mistakes barely overlap. Reranking is the separate second stage: a cross-encoder reads each question and passage together and reorders the shortlist. Retrieve wide and cheap for recall, rerank narrow and sharp for order. Here is the fusion arithmetic, the cross-encoder mechanics, the depth dial and its knee, and when the whole apparatus is overkill.

Pure vector search has two blind spots. It blurs literal tokens such as error codes, SKUs and names, because embeddings capture meaning rather than spelling; and it orders results by rough similarity, so the best passage often isn't at the top. Hybrid search fixes the first by running an old-fashioned keyword search (BM25) next to the vector search and fusing the two ranked lists, usually with Reciprocal Rank Fusion. Reranking fixes the second by taking the top candidates and re-scoring each one with a cross-encoder that reads the query and the passage together. That is far sharper than the dot product that fetched them, and far too slow to run over everything, so it only touches a shortlist. Put together, that's a cascade: stage one retrieves wide for recall, stage two reranks narrow for precision. The craft is measuring the lift (nDCG), diagnosing whether your problem is recall or ordering, and knowing when the whole apparatus is overkill. A note on vocabulary, because the literature and this page use different words for the same split: keyword search over an inverted index is what papers call sparse retrieval, since each document is a mostly-zero vector over the whole vocabulary, and embedding search is dense retrieval, since every dimension carries a value. Hybrid search means running one of each and fusing them.

The last two pages built a search that thinks in meaning. Every help-center article for Wrenlet's support bot is a point in embedding space; a customer's question becomes a point too, and the vector index finds the nearest ones fast. It's a genuine leap over keyword matching. A customer can describe a problem in their own words and still land on the right article. And for a while, it's enough.

Then two kinds of complaint start trickling into the support queue. The first: a customer pastes an exact error code, “WRN-429 when sending”, and the bot answers with a vaguely-related article about sending limits instead of the one page titled after that exact code. The second is subtler. The bot's answer is almost right, drawn from a passage that is clearly on-topic but not quite the best one in the library. The actually-perfect article was retrieved, just ranked eighth, below seven near-misses, so it never reached the model. Neither is a bug in the vector index. They're the two things pure vector search is structurally bad at: exact terms and precise ordering. This page is the two-part fix.

Why does vector search miss exact terms like error codes?

An embedding is a lossy summary of meaning. That is its superpower: “stop the little checkmarks that show I read a message” lands near an article about disabling read receipts, even with no shared words. But a lossy summary of meaning is exactly the wrong tool when the surface form itself carries the signal. An error code, an order ID, a SKU, a function name, an acronym: these aren't concepts to be understood, they're literal strings to be matched. The embedder tokenizes “WRN-429” into sub-word fragments and parks it near other vaguely-error-ish text, and there is no meaning-neighborhood that separates WRN-429 from WRN-431. The exact page exists; the vector search just can't reliably find it by the code.

The failure has a shape worth memorizing, because it's the mirror image of keyword search's failure. Dense retrieval is strong on paraphrase and synonyms and weak on literal tokens, rare terms, and negation. Old-fashioned keyword search is the exact opposite: it nails the literal token and is helpless against a paraphrase that shares no words. Their mistakes barely overlap, which is the whole reason combining them works. Watch each one miss on the other's home turf:

The interactive version of this example is available when JavaScript loads.

What is BM25, and how does it rank documents?

The keyword half of hybrid search is almost never plain word-counting. It is BM25 (Robertson & Zaragoza, 2009), the ranking function Lucene has used as its default similarity since version 6.0 in April 2016, which is why it is what Elasticsearch and OpenSearch hand you out of the box. Postgres full-text search is the odd one out and does not implement BM25 at all: ts_rank weights by lexeme frequency and ts_rank_cd scores cover density instead, which is why the Postgres snippet later on this page is labelled BM25-style rather than BM25. What BM25 does is score how well a document matches a set of query terms, and it's worth understanding because its three ideas are exactly the ones a naive keyword search gets wrong.

The three ideas inside BM25

  • Term frequency, but saturating. A document that contains “export” five times is more relevant than one that mentions it once, but not five times as relevant. BM25 lets each additional occurrence count for less, approaching a ceiling. The first mention buys the most; the tenth buys almost nothing. That single curve is what defeats keyword-stuffing, and the knob that controls how fast it saturates is called k1 (typically ~1.2).
  • Rarity is weighted up (IDF). A term that appears in almost every document tells you nothing; a rare term is a strong signal. BM25 multiplies each term's contribution by its inverse document frequency, so matching “WRN-429” (which appears in one article) counts for far more than matching “the” (which appears in all of them). This is precisely why keyword search shines on rare, literal tokens: rarity is a feature, not a problem.
  • Length normalization. A long document has more chances to contain your term by accident, so BM25 discounts matches in documents longer than average and boosts matches in shorter ones, with a knob called b (typically 0.75, where 0 ignores length entirely and 1 fully normalizes). It's the difference between “this word is central to this short article” and “this word appears once in a giant page about something else.”

Written out, the three ideas are one line. A document's score is the sum, over the query terms t, of IDF(t) (f (k1 + 1)) / (f + k1 (1 - b + b docLen / avgDocLen)), where f is how many times t appears in that document. Read it left to right and all three are visible: IDF(t) is the rarity weight out front, the f in a numerator that is capped by k1 + 1 against an f + k1 * ... denominator is the saturating curve, and docLen / avgDocLen is the length correction that b dials between off and full.

You rarely tune k1 and b. The defaults encode decades of information-retrieval research and are fine for almost everyone. What matters is the intuition: BM25 rewards rare, on-topic, non-stuffed matches, which is the behavior you want from the literal half of a hybrid search. There's also a newer middle ground worth knowing by name, learned sparse retrieval like SPLADE, which keeps BM25's exact-match, inverted-index efficiency but learns its term weights and quietly expands each document with related terms, closing some of the vocabulary gap without giving up literal matching. For most systems, plain BM25 is the right starting point.

What is Reciprocal Rank Fusion, and why fuse ranks rather than scores?

Reciprocal Rank Fusion scores every document as the sum of 1 / (k + rank) across the lists it appears in, and then sorts by that. It throws the raw scores away and keeps only the positions, because the two retrievers' scores are not on the same scale and never will be. Now you have two ranked lists for every query, one from BM25 and one from the vector index, and you need a single ordering. The obvious idea, adding the two scores together, is a trap: BM25 scores are unbounded sums that might run from 2 to 40 depending on the query, while cosine similarities sit in a compressed band around 0.6 to 0.9. Add them raw and whichever retriever happens to emit bigger numbers silently dominates; one BM25 outlier can swamp the entire vector signal. The scores live on incomparable scales.

The standard fix throws the raw scores away and keeps only the ranks. Reciprocal Rank Fusion (Cormack et al., 2009) scores each document as the sum, across both lists, of 1 / (k + rank), where rank is its position in that list (1, 2, 3…) and k is a smoothing constant. A document absent from a list simply contributes zero from it. Because “rank 1” means the same thing whether it came from BM25 or the vector index, the scales stop mattering. The trade is that RRF is deliberately lossy: it discards how much a document won by, treating a landslide first place and a photo-finish first place identically.

You will rarely want the two lists to have an equal say, and giving one more weight than the other is a small change to the same formula. The weighted form scores each document as w_kw / (k + rank_kw) + w_vec / (k + rank_vec), and setting w_kw = w_vec = 1 gives you plain RRF back. Those two weights are the dial this page keeps pointing at. Lean w_vec up on a corpus where customers paraphrase, lean w_kw up on one thick with part numbers and error codes, and fit both against a labeled query set rather than by feel, because the right split is a property of your traffic and nobody else can tell you what it is.

The k constant is quietly the interesting part. It sets how sharply the reward decays with rank. Small k makes the very top of each list dominate, so a single #1 wins outright. Larger k flattens those gaps, so a document that both retrievers rate highly can beat one that only one of them loves. Move the dial and watch consensus overtake a lone spike:

The interactive version of this example is available when JavaScript loads.

There's a second fusion family worth knowing: score-based fusion, where you normalize each retriever's scores into a 0 to 1 range (usually per-query min-max) and take a weighted average, alpha vector + (1 - alpha) keyword. The alpha weight lets you lean semantic or lexical, and it keeps the magnitude information RRF throws away, at the cost of being fragile to outliers and requiring that normalization step. The rule of thumb: reach for RRF when your scores are uncalibrated and you want robustness (the common case), and score-fusion when your scores are well-behaved and you want to preserve margins. Either way the highest-leverage knob is the same one, the weight between the retrievers, spelled w_kw and w_vec in RRF and alpha in score fusion, and fitted on a labeled set. Which brings us to when this whole exercise is worth it.

When does hybrid search help, and when does it hurt?

Hybrid search is not free lunch, and “always run both” is lazy advice. It helps for one precise reason: the two retrievers fail on different, largely uncorrelated inputs, so fusing them recovers the queries each one alone would drop. That condition, both retrievers individually decent and their mistakes independent, is when hybrid reliably beats either alone, and it's why hybrid wins on domain-heavy corpora full of jargon, codes, and proper nouns.

When adding the other retriever backfires

  • One retriever is much weaker for your workload. Fusion is a democracy; adding a consistently-bad voter with equal weight drags down the good one. If your queries are all natural-language paraphrase and your BM25 is noise, equal-weight fusion makes things worse. The fix is weighting, or dropping the weak retriever, not blindly averaging.
  • The queries are purely semantic. If nobody ever types a literal code or name and every query is a conversational paraphrase, the keyword half contributes little but noise. Measure before assuming you need it.
  • You reach for score-fusion on wild score distributions. Min-max normalization is stretched by a single outlier score, which can distort the whole fused ranking. This is exactly the fragility RRF avoids by ignoring magnitudes.

The second miss: retrieval isn’t ranking

Hybrid search fixed the coverage problem: the right passage is now somewhere in your results. But somewhere isn't good enough. Whether you're feeding a top-5 into a model's context or showing a customer a list, the order matters, and the similarity score that fetched your candidates is a blunt instrument for ordering them. It was optimized to be fast over millions, a dot product between two pre-computed vectors, not to make a fine judgment about which of ten on-topic passages best answers the actual question asked.

This is the difference between recall and precision, and it's the cleanest way to hold the two stages in your head. Recall asks: did we fetch the relevant passage at all? That's retrieval's job, and hybrid search maximizes it. Precision asks: is the best passage actually at the top? That's a separate job, and it needs a separate, sharper tool. It matters especially because models don't read a context window evenly: a great passage buried at position eight can be lost in the middle and effectively ignored. Getting the ranking right isn't cosmetic; it's what decides whether the model sees your best evidence.

What is a cross-encoder, and how does it differ from a bi-encoder?

A cross-encoder reads the question and one passage together, in a single forward pass, and returns how relevant that passage is to that question. A bi-encoder turns each of them into a vector separately and compares the two. That one structural difference is the whole story: the cross-encoder is far sharper because it can let words in the question attend to words in the passage, and far more expensive because nothing can be precomputed. The embeddings page promised this page a sharper judge, and here it is. Recall the split it drew. A bi-encoder, the model behind your vector search, embeds the query and each document separately and ahead of time, then compares the two finished vectors with a dot product. That separation is what makes it fast enough to sweep millions: the document vectors are all pre-computed, and the query only ever meets a summary. A cross-encoder does the opposite. It feeds the query and one document into the transformer together, in a single pass, and lets every query token attend to every document token before emitting one relevance score. Nothing is pre-computed; the score is a judgment about this pair. That is the recipe Nogueira & Cho, 2019 laid out for passage reranking with BERT, and it is still the shape of every cross-encoder reranker you can rent or download today.

That joint reading is why a cross-encoder is sharper. A dot product between two independently-pooled vectors can only compare their overall gist. The fine-grained “does this specific phrase answer that specific question” signal was averaged away before the two texts ever met. The cross-encoder never averages it away, because it reads them side by side. Watch it separate a topically-similar-but-wrong passage from the one that actually answers the question:

The interactive version of this example is available when JavaScript loads.

How deep should you rerank?

Deep enough that the answer is in the shortlist, and no deeper. In practice that lands somewhere between 50 and 200 candidates for most corpora, and the honest answer is that you sweep it and look for the knee, because past it every extra candidate is another near-miss for the reranker to prefer and another few milliseconds on the bill. Put the two halves together and you get the funnel that real RAG systems ship. Stage one, hybrid search, retrieves a wide net of candidates cheaply: the top 50, 100, sometimes 200. Its only job is recall: get every relevant passage into the pool, because nothing downstream can recover one it missed. Stage two, the cross-encoder, reads each candidate in that pool against the query and re-sorts them, handing the final top-3 or top-5 to the model. Its job is precision: put the genuinely-best passage where it will actually be read. Cheap-and-wide composes with sharp-and-narrow to land near cross-encoder quality at near-vector-search cost, a point neither model reaches alone.

The dial you actually tune is how deep to rerank, meaning how many of stage one's candidates the cross-encoder reads. It exposes a hard law worth internalizing: reranking can only reorder what retrieval fetched. If the best answer came back at rank 40 and you only rerank the top 20, the cross-encoder never sees it, and no amount of reranking brilliance can promote a passage it was never handed. Deeper reranking raises this ceiling, but every extra candidate is another full transformer pass, so latency and cost climb linearly. Find the depth that catches the good answers, then stop:

The interactive version of this example is available when JavaScript loads.

Which reranker should you use?

Start with a managed rerank API if you can send your data out, and an open-weight cross-encoder if you cannot. “Add a reranker” hides four genuinely different families, and choosing between them is a real decision about quality, latency, cost, and where the model runs. Set your constraints and see which one fits:

The interactive version of this example is available when JavaScript loads.

The four reranker families (capabilities move fast, so treat these as families rather than fixed specs)
FamilyHow it scoresReach for it when
Open-weight cross-encoderReads each query and document pair jointly; you host the weights (the bge / mxbai / MiniLM families).Data must stay in-house, you want zero marginal cost, or you want to fine-tune on your domain.
Managed rerank APIA hosted cross-encoder behind one call (Cohere Rerank, Voyage).You want a strong reranker with no GPU to run and multilingual support out of the box.
Late interaction (ColBERT)Keeps one vector per token and scores with a cheap token-level match (Khattab & Zaharia, 2020).You need to rerank deep (hundreds of candidates) fast, and can pay the large storage cost of per-token vectors.
LLM reranker (listwise)An instruction-tuned LLM ranks the shortlist directly (RankGPT, Sun et al., 2023).Quality is everything, the shortlist is short, and you can absorb seconds of latency and per-token cost.

The middle two deserve a sentence of intuition. ColBERT-style late interaction is a clever midpoint: like a bi-encoder it embeds documents ahead of time so they're pre-computable, but instead of one vector per document it keeps one per token, and defers a cheap token-by-token comparison to query time. That recovers much of the cross-encoder's sharpness while staying fast enough to rerank deep. The price is storage: a vector per token is a lot of vectors. LLM rerankers sit at the opposite extreme, highest quality and flexibility because the model can reason about relevance, but each pass is a full generation over the whole candidate list, so they're mostly used offline (to generate evaluation labels, or to distill a cheaper model) rather than on a hot path.

How do you measure whether reranking actually helped?

With nDCG@k, measured on a labelled set, before and after, with stage one held still. You cannot tune what you don't measure, and “the results look better” is not a metric. Reranking is judged by whether it puts the most relevant passages at the very top, which is exactly what nDCG, normalized discounted cumulative gain, captures. The idea is simple: give each retrieved passage a graded relevance label (say 0 to 3, from a human or a strong model), reward the ranking for placing high grades near the top with a discount that grows the further down the list a passage sits, and normalize against the best-possible ordering so the score lands between 0 and 1. It's the dominant retrieval metric for a reason: it's order-aware and it handles “somewhat relevant,” not just hit-or-miss.

Written out, discounted cumulative gain is DCG@k = sum over positions i = 1..k of rel_i / log2(i + 1), and the normalized version divides that by the same sum computed over the ideal ordering of the same labels: nDCG@k = DCG@k / IDCG@k. The log2(i + 1) divisor is the whole idea, and it grows as you descend: it is 1 at position 1, 2 at position 3, and 3 at position 7, so the same passage contributes a third as much down at seven as it would at the top. Watch a poor ordering's nDCG jump when the reranker sorts it:

The interactive version of this example is available when JavaScript loads.

Two companions to nDCG round out the toolkit. MRR (mean reciprocal rank) tracks how high the first relevant result lands, which is the right metric when there's essentially one correct answer, like looking up a specific article. And the recall/precision split from earlier becomes a literal measurement: recall@N for how many relevant docs made the retrieved pool (stage one's score), precision@k or nDCG@k for how well they're ordered (stage two's score). Measuring both separately is what powers the single most useful diagnosis in retrieval.

How much lift should you expect? Reported gains from adding a reranker typically run a handful of nDCG points on clean corpora, up to double digits on lexically hard ones. Real, but not magic, and smaller the better your retrieval already is. To tune, freeze stage one and your evaluation set, sweep the rerank depth, and watch nDCG climb until it flattens: that knee is your depth, the point where reranking deeper only buys latency. And remember the honest label problem. Graded relevance judgments are expensive, so many teams bootstrap them with an LLM judge, which is cheaper and noisier and needs its own spot-check against human labels before you trust it.

How much latency and cost does this add?

Hybrid search adds little, and the reranker adds most of what you will feel. Every stage you add is latency and money. Hybrid search roughly doubles retrieval work (two indexes, then a fusion step), which is usually cheap. The reranker is the expensive part: a managed API or a self-hosted cross-encoder adds somewhere from tens to hundreds of milliseconds over a shortlist of a few dozen candidates, and reranking a hundred or more can push into the seconds. That cost scales linearly with rerank depth, which is exactly why the depth dial matters.

When hybrid + reranking is overkill

  • Your corpus is small. With a few thousand well-chunked documents, stage-one recall is already near-perfect and a flat, exact search may beat the whole apparatus. Complexity you don't need is a cost, not a feature.
  • Your domain is cleanly semantic and your embedder is well-tuned. If nobody types literal codes and the vector search already ranks well, the keyword half and the rerank stage may add latency for a lift you can't measure.
  • You're on a latency-critical hot path. A few hundred milliseconds of reranking is fine for a support answer and unacceptable for an autocomplete. Match the machinery to the budget.

Security: filter before you rerank

Adding stages adds places to leak data, and reranking has a specific one. The safe order of operations is: authenticate the user, cut the searchable set to what they're allowed to see, retrieve within that scope, and only then rerank. The dangerous inversion, where you retrieve and rerank across everything and filter at the end, has already let unauthorized content into the candidate pool, where it can consume the top slots and, if any post-filter has a bug, reach the model. Permission filtering belongs before retrieval, never after reranking. For high-stakes systems, validate twice: filter the searchable scope up front, and re-check every surviving candidate's access right before it goes into the prompt, to catch stale permissions and index drift.

One distinction is worth naming here, because the two get written into the same WHERE clause and only one of them is a security control. A subscription tier is an entitlement: it decides what a customer has paid for. An access-control list is a permission: it decides what they are allowed to read at all. Leak the first and a customer reads a feature they didn't buy. Leak the second and a customer reads another tenant's support history. Filter on the permission scope, and if you also filter on plan, know that you did two different jobs in one predicate.

Hybrid search and reranking in code

Stripped to essentials on Postgres with pgvector, the whole funnel is four moves: run both searches, fuse by rank, rerank the shortlist, hand back the top few. The filter in the first two steps is acl_group, a permission scope rather than a billing plan, for the reason the last section gave.

The whole funnel, step by step

  • Keyword search (BM25-style). SELECT id, ts_rank_cd(tsv, query) AS r FROM chunks WHERE tsv @@ plainto_tsquery($q) AND acl_group = ANY($userGroups) ORDER BY r DESC LIMIT 100. Postgres full-text search over a tsvector column, with the permission filter inline so unauthorized rows never enter the pool. It says BM25-style because ts_rank_cd scores cover density, which is not BM25.
  • Vector search. SELECT id, embedding <=> $qVec AS d FROM chunks WHERE acl_group = ANY($userGroups) ORDER BY d LIMIT 100. The same top-100 by cosine distance, same filter. Two ranked lists, same allowed scope.
  • Fuse by rank (RRF). Join the two lists and score each id as w_kw/(k + kw_rank) + w_vec/(k + vec_rank) with k around 60, both weights starting at 1, and a zero term for any id missing from a list; keep the top ~50 by fused score. No score normalization needed, because ranks fuse cleanly. When you tune this pipeline, the two weights are what you move.
  • Rerank the shortlist. Send the query and those ~50 candidate texts to a cross-encoder (rerank(query, docs) on a managed API or a self-hosted model), take the returned top-5, and pass those to the model. The reranker touches 50 documents, never the corpus.

Where hybrid + reranking bites

The ones that actually bite

  • Reranking too shallow. If the best answer comes back at rank 40 and you rerank the top 20, no reranker can save it. Sweep the depth against recall before trusting a fixed number.
  • Adding a reranker to a recall problem. If the relevant docs aren't in the retrieved pool, reranking is wasted effort. Split recall@N from nDCG@k first and fix the stage that's actually broken.
  • Letting the analyzer eat your exact tokens. A stock analyzer splits WRN-429 into wrn and 429, so the literal match you were counting on never happens. Index a keyword sub-field or write an analyzer that keeps alphanumerics together, then test it on real pasted strings.
  • Summing raw scores instead of fusing ranks. BM25 and cosine live on different scales; adding them lets one silently dominate. Use RRF, or normalize carefully if you must keep magnitudes.
  • Equal-weight fusion with one weak retriever. Fusion averages; a bad retriever with equal weight drags the good one down. Weight them, or drop the weak one. More retrievers is not automatically better.
  • Filtering permissions after reranking. Unauthorized content in the candidate pool is already a leak waiting for a bug. Filter to the allowed scope before retrieval, not after.
  • Trusting the vendor's benchmark and its billing math. Self-reported “state of the art” is marketing, and long documents get chunked-and-billed past the per-search cap. Measure quality on your data; budget from the real document count.

Habits that keep retrieval sharp

What senior teams wire in from the start

  • Default to hybrid, but prove it. Run BM25 beside the vector search, fuse with RRF, and confirm on a labeled set that hybrid beats the better single retriever before shipping it.
  • Tune the weights, not the constant. The biggest fusion lever is w_kw against w_vec, fitted on a small labeled set. k is a weak knob; leave it near its default.
  • Check what your analyzer actually indexed. Run the codes, SKUs and IDs your customers paste through the analyzer and confirm they survive as single tokens, because the exact-match half of hybrid is worth nothing if they don't.
  • Rerank a shortlist, tuned by depth. Retrieve wide for recall, rerank the smallest depth whose recall is high enough that nDCG stops climbing. Deeper only burns latency.
  • Filter to the allowed scope first. Enforce permissions before retrieval and re-validate before the prompt; a reranker trusts whatever it's handed, stale or unauthorized.
  • Measure the lift in numbers and in dollars. Track nDCG against a frozen eval set and the reranker's real per-search document count, so a regression or a bill spike shows up as a metric, not a surprise.

Interview cheat-sheet: intern to principal

Why add keyword search when you already have vector search?
Because embeddings capture meaning, not surface form, so they fumble exact tokens like error codes, IDs, SKUs and rare names, where the literal string is the signal. Keyword search (BM25) nails exactly those and fails on paraphrase, which is where vectors shine. Their errors are largely uncorrelated, so fusing the two ranked lists recovers queries either would drop alone. That's hybrid search.
What does BM25 add over naive keyword counting?
Three things: term-frequency saturation (each repeat of a word counts for less, defeating keyword stuffing), inverse document frequency (rare terms weigh more than common ones, which is why it's strong on literal codes), and length normalization (matches in shorter documents count for more). The k1 and b knobs control saturation and length normalization; the defaults are fine for almost everyone. The catch is upstream of the formula: if your analyzer split the rare token into common fragments, the IDF advantage is gone before BM25 runs.
How do you combine a keyword list and a vector list?
Don't add the raw scores. BM25 scores are unbounded and cosine sits in a narrow band, so one silently dominates. The standard fix is Reciprocal Rank Fusion: score each doc as the sum of 1/(k+rank) across both lists, keeping only ranks so the scales stop mattering. In practice you weight the lists, w_kw/(k+rank_kw) + w_vec/(k+rank_vec), and those weights are the knob you actually tune. Score-based fusion (normalize, then weighted-average with an alpha) is the alternative when you want to preserve magnitudes and your scores are well-behaved.
What is the RRF k constant, and is it always 60?
k smooths how sharply the reward decays with rank: small k lets a single #1 dominate, larger k rewards documents both retrievers rate highly. 60 is the original paper's value and a common default, but it's not a law: Supabase uses 50, Qdrant uses 2 over zero-based ranks. It's a weak knob; tune the weight between retrievers before you touch k.
Bi-encoder vs cross-encoder: what is the difference, and when do you use each?
A bi-encoder embeds the query and each document separately, so document vectors are pre-computed and searched cheaply with a dot product, which is what makes first-stage retrieval over millions possible. A cross-encoder reads the query and one document together in a single pass, so every query token attends to every document token, giving a far sharper relevance score. Nothing is pre-computable, so it runs per pair and is only affordable on a shortlist. Retrieve with the bi-encoder, rerank with the cross-encoder.
Why can’t you just use a cross-encoder for everything?
Because its score depends on the query and document pair, nothing can be pre-computed, so scoring N documents is N full transformer passes at query time. Published throughput puts a pair in the single-digit to low-tens of milliseconds on a GPU, and around five milliseconds in the sentence-transformers figures, so a million documents is well over an hour for one query. It's inherently a second pass over a shortlist a fast retriever already narrowed, never a retriever itself.
Describe the two-stage retrieval cascade and its central trade-off.
Stage one (hybrid search) retrieves a wide, cheap net of candidates, optimizing recall: get every relevant doc into the pool. Stage two (cross-encoder) reranks that pool for precision, putting the best passages at the top for the model to read. The tuning dial is rerank depth: deeper catches more but costs linearly more latency, and it can only reorder what stage one fetched. That cap is the recall ceiling.
Retrieval quality is bad. How do you decide whether to add a reranker?
Split the metric. Measure recall@N and nDCG@k separately. High recall but low nDCG means the right docs are retrieved but ordered badly, an ordering problem, so add or improve the reranker. Low recall means the right docs never made the pool, a recall problem, so a reranker can't help; fix hybrid search, chunking, or embeddings upstream. Diagnosing this before building saves weeks tuning the wrong stage.
How do you measure that a reranker actually helped?
nDCG@k is the main metric. It rewards putting higher-graded passages nearer the top and normalizes against the ideal ordering, so it's order-aware and handles graded relevance. MRR tracks how high the first relevant hit lands when there's one right answer. Freeze stage one and a labeled set, then compare nDCG before and after reranking and sweep the depth for the knee where it flattens.
What are the four reranker families and when do you pick each?
Open-weight cross-encoders (self-host, zero marginal cost, fine-tunable); managed rerank APIs (strong, no GPU, multilingual, pay per search); late-interaction models like ColBERT (per-token vectors, precomputable, fast enough to rerank deep, but heavy storage); and LLM listwise rerankers (highest quality and flexibility, but slow and expensive, mostly offline). Pick by quality bar, latency budget, whether you must self-host, and how deep you rerank.
What security mistake is specific to reranking, and what does a reranker not protect against?
Filtering permissions after reranking instead of before retrieval. That lets unauthorized content into the candidate pool, where it can take top slots or leak through a post-filter bug. Filter to the allowed scope before retrieval, and keep the two kinds of filter straight: a plan tier is an entitlement, an ACL is a permission, and only the second one is protecting other people's data. And a reranker scores relevance, not truth or safety: it will happily promote a plausible-but-wrong passage or one carrying an injected instruction, and it faithfully reranks stale or newly-unauthorized docs if the index lags. Freshness and access control live at retrieval.

By GOAT Engineer. Back to Concept Library. Privacy Policy · Contact.