Overview
Curated: · Written: · Reviewed:
Advanced RAG & Retrieval Quality
In one line
Retrieval quality is whether the system reliably surfaces the authorized, current, answer-bearing evidence under real query language, corpus scale and latency budgets. Reach for this framing when a RAG demo works on easy questions but fails on identifiers, paraphrases, multi-hop questions, permissions or stale sources.
Key definitions
- Recall@k: share of gold evidence found in the top k candidates. It is the ceiling for everything downstream.
- nDCG@k: graded ordering quality of the top k, rewarding relevant items near the top.
- Required-evidence coverage: 1 only when the whole required set is in context, otherwise 0.
- Reciprocal rank fusion (RRF): sums 1/(k+rank) across rankers. Needs no score calibration.
- Reranker ceiling: a reranker only reorders its candidates. A gold passage missed at retrieval stays missed.
Formulas and complexity
Worked check (hypothetical grades A=3, B=2, C=1, X=0): the ranking B, X, A, C gives DCG@4 = 2 + 0 + 3/log2(4) + 1/log2(5) = 3.9307. The ideal order A, B, C, X gives 3 + 2/log2(3) + 1/log2(4) = 4.7619. So nDCG@4 = 0.825. Moving the ungraded X to rank 4 (B, A, C, X) gives DCG@4 = 4.3928 and nDCG@4 = 0.922. The X at rank 2 costs about 0.10 of nDCG by pushing A and C down.
How it works
Apply the permission filter inside every candidate generator, not after top-k. Lexical and dense retrievers each produce candidates, and RRF fuses the union by rank. The reranker orders the fused candidates, but recall at the candidate stage caps the result. Context ordering and compression then decide what the generator actually sees.
When to use and when not to
| Need | Reach for | Avoid when |
|---|---|---|
| Exact IDs, error codes, SKUs | BM25 or hybrid | Dense-only retrieval, which misses codes |
| Paraphrased questions | Dense or late interaction (ColBERT) | Identifiers dominate the query mix, or storage per passage is the constraint |
| Precise top-10 ordering | Cross-encoder over top N | Latency budget cannot pay the per-pair cost |
| Multi-hop questions | Decomposition with evidence union | Single-shot top-k over the whole question |
| Vocabulary mismatch | HyDE, with the original query kept in the union | Invented specifics would mislead the retriever |
| Tight token budget | Compression with exact source spans | Qualifiers, versions or conflicts must survive |
Traps interviewers probe
- Blaming the generator first. Fix: compute recall@k, then nDCG, then required-evidence coverage, in that order, and fix the first layer that fails.
- Reranking to fix missing evidence. Fix: raise candidate recall. A reranker cannot recover a document retrieval never returned.
- Post-filtering permissions. Fix: filter inside each generator, reranker, cache and snippet path. Cutting a top-20 down to 3 permitted documents is both a recall bug and a leak risk.
- Raising top-k as the fix. Fix: measure required-evidence coverage and context order first. More chunks add tokens and can bury the evidence that matters.
- Mixing embedding spaces during a migration. Fix: build a parallel index, validate it, then switch an alias atomically.
Interview tips
Open with the contract: "Before I touch a model I want the relevance unit, permissions, freshness, latency budget and release thresholds. Then I walk the layers."
Expect these follow-ups:
- "Recall@20 is 0.95 but users still complain." Go to ranking, context order or generation, and measure nDCG and coverage before changing the model.
- "How do you know a chunk is stale?" Source-update-to-query lag, tombstones, atomic alias switch, reconciliation across source, chunk and index inventories.
- "A tenant saw another tenant's document." Walk every candidate generator, cache, reranker and snippet path, plus the policy-service failure mode.
- "You switch embedding models." Vector spaces differ, so rebuild a parallel index and never mix spaces.
- "No labeled set." Use model judges calibrated against expert labels, and keep critical failures out of the aggregate score.
30-second outline: symptom, then contract, then recall@k ceiling per query class, then ranking nDCG, then context coverage, then faithfulness, then fix at the first failing layer with permissions enforced at retrieval.
Feedback on this overview
Log in free to save your progress and keep bookmarks and notes for a quick revision before your interview.