RAG and Retrieval Interview Questions
Short answers to 12 rag and retrieval interview questions.
Questions and answers (12)
Answers are written in plain English and reviewed for technical accuracy. Each answer states the point first, then the reason.
1. What chunking strategy would you use for a large technical documentation corpus, and why?
Use structure-aware chunking with a target of 300 to 500 tokens and a small overlap. Split on headings and code blocks first, then on paragraphs. This keeps each chunk on one topic and keeps code with its explanation. The overlap protects answers that cross a boundary, but it adds storage and retrieval cost.
2. How do you choose between a sparse retriever (BM25) and a dense retriever? When do you need both?
Start with BM25 for exact terms and dense retrieval for meaning. BM25 wins on identifiers, error codes, and rare names. Dense retrieval wins on paraphrases and natural questions. Use both when users mix exact lookups with open questions, and fuse the ranked lists.
3. What is a reranker, when should you use one, and what does a cross-encoder cost you?
A reranker reorders the top candidates from the first-stage retriever with a cross-encoder. Use it when top-k precision is low and latency budget allows. A cross-encoder scores each query and document pair together, so cost grows with k. Reranking 50 candidates can add 50 to 200 ms.
4. How would you evaluate the quality of a RAG pipeline: retrieval and generation separately?
Measure retrieval and generation with separate metrics. For retrieval, use recall at k and mean reciprocal rank against labeled relevant chunks. For generation, use faithfulness and answer correctness with a labeled question set. Keep the two scores apart, because a good answer can hide bad retrieval.
5. What is HyDE (hypothetical document embeddings) and when does it outperform standard dense retrieval?
HyDE asks a model to write a hypothetical answer, then embeds that answer as the query. It helps when the question is short and the documents are long and formal. The generated text matches document style better than the raw question. It adds one model call and can inject false details into the query.
6. How does agentic RAG differ from standard RAG, and when is the extra complexity justified?
Agentic RAG lets a model plan, call retrieval tools, and iterate before it answers. Standard RAG retrieves once and generates once. Use the agent when questions need several lookups or tool calls. The extra complexity costs latency and money, so keep it for hard queries only.
7. What causes semantic drift in embedding search and how do you detect it?
Semantic drift is a slow change in meaning between the query space and the document space. New jargon, renamed products, and stale embeddings cause it. Detect it with a fixed probe set of queries and track recall over time. A drop in recall on the probe set signals drift.
8. Design permission-aware retrieval: users must never see content they can't access in the source system.
Filter by permission at query time inside the vector store, not after retrieval. Store an access control list with each chunk and pass the user identity into the search filter. This prevents leaks, because blocked chunks never enter the context. Re-check permission in the source system for high-risk content.
9. Compare HNSW, IVF-PQ and flat indexes. How do you pick, and what does recall@k cost in latency?
Flat search checks every vector and gives exact recall. HNSW gives high recall at low latency but uses much memory. IVF-PQ saves memory and speeds search but loses recall. Pick flat for small sets, HNSW for low latency, and IVF-PQ for large sets under memory limits.
10. How do you handle tables, figures and multi-column PDFs in a retrieval pipeline?
Parse the PDF layout before you chunk the text. Detect tables and figures and keep each one as a separate unit with its caption. For multi-column pages, read each column in order and do not merge lines across columns. Store the page number and bounding box as metadata for each span.
11. How do you keep an index fresh when the underlying corpus changes continuously?
Use incremental indexing with versioned documents and a delete-then-insert flow. Give each document a stable ID and a content hash. On a change, remove the old vectors and add the new ones. Run a small reindex job on a schedule and keep the old index until the new one is ready.
12. How do you attribute every claim in a generated answer to a specific retrieved span?
Require the model to cite a span ID for each claim and then check each ID against the retrieved set. Put span IDs in the context and ask for output in a fixed format. Reject or flag any claim with a missing or invalid span ID.
for claim in answer.claims:
if claim.span_id not in retrieved_ids:
claim.status = "unsupported"