Skip to content
Tech Interview Prep
Technical interview guide

Advanced RAG & Retrieval Quality

The retrieval-quality techniques that separate a working RAG demo from a production system that reliably surfaces the right context.

Minutes to read
3
Practice MCQs
25
Interview Q&A
25
Edition
v5
Editorial status
Reviewed

Scope: DPR, ColBERT, SPLADE, BEIR, MTEB, HyDE, Lost in the Middle, RAGAS, HNSW, FAISS, RAG, Model Cards, NIST AI RMF, and OWASP Prompt Injection references reviewed 2026-09-04.

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

Recall@k=∣gold∩top-k∣∣gold∣\text{Recall@}k = \frac{|\text{gold} \cap \text{top-}k|}{|\text{gold}|} nDCG@k=∑i=1kgi/log⁡2(i+1)ideal DCG\text{nDCG@}k = \frac{\sum_{i=1}^{k} g_i / \log_2(i+1)}{\text{ideal DCG}} RRF(d)=∑r1k+rankr(d),k=60 is the common default\text{RRF}(d) = \sum_{r} \frac{1}{k + \text{rank}_r(d)}, \quad k = 60 \text{ is the common default}

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.

Query and auth context Permission filter inside each retriever Lexical BM25 Dense or ColBERT RRF union Reranker over top N Context ordering and compression Generator with citations

When to use and when not to

NeedReach forAvoid when
Exact IDs, error codes, SKUsBM25 or hybridDense-only retrieval, which misses codes
Paraphrased questionsDense or late interaction (ColBERT)Identifiers dominate the query mix, or storage per passage is the constraint
Precise top-10 orderingCross-encoder over top NLatency budget cannot pay the per-pair cost
Multi-hop questionsDecomposition with evidence unionSingle-shot top-k over the whole question
Vocabulary mismatchHyDE, with the original query kept in the unionInvented specifics would mislead the retriever
Tight token budgetCompression with exact source spansQualifiers, versions or conflicts must survive

Traps interviewers probe

  1. Blaming the generator first. Fix: compute recall@k, then nDCG, then required-evidence coverage, in that order, and fix the first layer that fails.
  2. Reranking to fix missing evidence. Fix: raise candidate recall. A reranker cannot recover a document retrieval never returned.
  3. 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.
  4. 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.
  5. 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.