Why this matters
"Walk me through a RAG pipeline" and "it gives wrong answers; how do you debug?" are the two most common RAG interview questions. In production, they're the daily work.
Q1. Walk me through a RAG pipeline end to end.
- Ingest: connectors; type and size checks; layout-aware parsing (faxes and PDFs with tables break naive extraction); sensitive-data handling before anything is indexed.
- Normalize + metadata: headings, pages, section path, version, tenant, ACL labels.
- Chunk: structure-aware first; parent-child when context matters.
- Embed: batched; record the embedding model with every vector; a model change means a full re-embed.
- Index: vectors + lexical index + metadata.
- Query: authenticate, resolve tenant and permissions, optionally rewrite.
- Retrieve: mandatory permission filters; hybrid (dense + lexical) fused with RRF.
- Re-rank: top-50 → top-5.
- Assemble: token budget, source IDs attached.
- Generate: answer only from evidence, cite chunk IDs, explicit insufficient-evidence path.
- Validate: schema; every cited ID exists in the retrieved set; business rules.
- Evaluate: retrieval and generation separately, in CI and on sampled traffic.
Q2. It gives wrong answers. How do you debug?
Paste the correct context manually: now right → retrieval problem; still wrong → generation problem. Retrieval: chunk boundaries, embedding mismatch, filters, stale index, exact terms missed by dense search. Generation: prompt, context order (lost in the middle), model tier. Log chunk IDs and scores per answer. Rerun the eval suite after each change.
| Symptom | Likely cause | Inspect |
|---|---|---|
| Right answer never appears | Retrieval miss | Recall@k, chunking, filters |
| Wrong source | Similar but irrelevant | Precision@k, re-rank, metadata |
| Right source, wrong answer | Generation | Prompt, order, model |
| Another tenant's data | Missing filter | Server-side filters, RLS, cache keys |
| Stale answer | Stale index | Versioning, deletion flow |
| High cost | Too much context | Top-k, re-rank cutoff, caching |
Q7. How do you evaluate RAG?
| Layer | Metrics |
|---|---|
| Retrieval | Recall@k, Precision@k, MRR, nDCG; RAGAS context precision and recall |
| Generation | Faithfulness, answer relevance, citation correctness |
| Product | Corrections, acceptance, edit distance on drafts |
Golden set with expert answers; run on every prompt, model or chunking change; calibrate LLM-as-judge against humans (10.2).
Q10. Hallucination?
Say: "You don't eliminate hallucination. You engineer containment."
Grounding with citations, schemas, citation verification, an explicit insufficient-evidence path, faithfulness in evals, human review for consequential outputs, sources visible in the UI. Structural containment when possible: constrain the answer space so a fabricated value can't be expressed (S4).
Common mistakes
- One end-to-end "accuracy" number that can't tell you which stage broke.
- No logging of which chunks fed each answer.
- Evaluating on questions written by the same person who wrote the prompt.
Check yourself
How do you tell a retrieval failure from a generation failure in one step?
Give the model the known-correct context directly. If the answer becomes right, retrieval was the problem; if it's still wrong, the prompt, context order or model is.
Name three retrieval metrics and three generation metrics.
Retrieval: recall@k, precision@k, MRR, nDCG. Generation: faithfulness, answer relevance, citation correctness.
Build it
Create a 30-question golden set for your RAG project with expected source chunks and reference answers. Report recall@5, MRR and faithfulness, then change chunk size and report again.