What are common RAG failure modes and how do you debug them?
562 views
73 of 83
1
The problem
Question presented to candidate:
"Users say our RAG assistant sometimes gives wrong or outdated answers, and sometimes says it does not know things that are definitely in the docs. What usually goes wrong in a RAG system, and how would you actually debug one of these reports?"
What a strong answer should cover:
Failures happen at a specific stage and should be named by it: not indexed or badly parsed, stale or duplicated versions, a fact split across chunks, retrieval miss (vocabulary mismatch, exact identifiers, wrong filter), ranked out by the reranker or the context budget, context present but ignored or contradicted, wrong citations, and answering questions the documents cannot answer
The debugging method: reproduce from a per-request trace (rewritten query, filter, retrieved IDs and scores, reranked and packed IDs, prompt version, answer), identify the gold chunk, and walk the stages in order; the first stage that lost the gold chunk is where the fix goes
Check the cheap upstream things first: is the document in the index at all, is it the current version, does one chunk actually contain the answer
Turn single reports into an eval set and a funnel (indexed, retrieved, packed, answered correctly) so you fix the stage losing the most questions, and add each fixed case as a regression test
Typical fixes per stage: parsing and sync fixes, structure-aware chunking or contextual headers, hybrid search and query rewriting, deeper reranking, fewer and better-ordered chunks, grounding and abstention instructions, citation validation
Clarifying questions expected:
Do we log retrieved chunk IDs and scores per request, or only the question and answer?
Do we have examples of the failing questions with the documents users expected?
Code / implementation expected: Optional โ a triage function that classifies a logged request by the first stage that lost the answer, or a clear step-by-step debugging procedure.
rag
debugging
failure-modes
retrieval
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Engineers who run or are about to run a RAG feature in production and need a systematic way to turn "the bot got it wrong" into a specific, fixable cause.
Difficulty: Hard
Verified with: Node 22.22.0 and Python 3.12.3 (the chunk-boundary demo and the triage harness below). The request logs in the triage are hand-written examples of each failure type, not data from a real system. Research findings are cited inline.
How to read this doc: Every idea is explained in plain language first, then tagged with ๐ Interview term: so you also learn the words an interviewer expects. All program output shown was produced by actually running the example; the Verified section quotes it in full.
1. Why This Even Matters โ A Story First
A parcel arrives at the wrong address. "The delivery service is bad" is true and useless. A logistics team asks a sequence o
The solution is hidden so you can try first
16 min read ยท 9 sections
4
Read the code
Chunk-boundary check and a first-failing-stage triage over logged requests