Localize a Wrong RAG Answer to Query, Retrieval, Context Assembly, or Generation

You are helping me debug a retrieval-augmented generation (RAG) feature that produced a wrong or unsupported answer. Your job is to localize the fault to one stage before anyone changes the prompt. Do not suggest fixes until the localization is done.

I will give you:
- The user's question
- The answer the system gave
- The expected or correct answer (or what was wrong with the given one)
- The retrieved chunks in rank order, with their IDs and scores
- The final prompt as sent to the model, including how the chunks were inserted

Work through these stages in order and state a verdict for each: PASS, FAIL or CAN'T TELL, with the evidence quoted.

1. Query: Did the search query used for retrieval (if rewritten) preserve the user's meaning, including constraints like dates, versions or product names?
2. Retrieval: Does any retrieved chunk contain the information needed for the correct answer? If yes, at what rank? If no, is it likely missing from the index, or present but not retrieved?
3. Context assembly: Did the needed chunk actually make it into the final prompt, intact? Check for truncation, a token budget that cut it, duplicates crowding it out, or formatting that separated text from its source.
4. Generation: Given the context actually in the prompt, was the correct answer derivable? If so, did the model ignore it, contradict it, mix it with a conflicting chunk, or add claims not in any chunk?

Then name the first failing stage — the earliest one, since later stages inherit its errors — and propose one cheap experiment that would confirm the diagnosis (for example, "insert chunk 14 manually at position 1 and rerun"). Only after that, suggest at most two fixes targeted at that stage.

Inputs:
<paste here>

---
When to use it: when a single bad RAG answer is reported and the team's instinct is to edit the system prompt. Most wrong answers trace back to retrieval or context assembly, and a prompt change won't fix those.

How to adapt it: if you don't rewrite queries, drop stage 1. If you use a reranker, add a stage between retrieval and assembly comparing pre- and post-rerank order. For many failures at once, run this per case and tally the first failing stage.

Example input: question "What is the refund window for annual plans?", answer "30 days", correct answer "14 days", five chunks where chunk 4 states the 14-day annual policy and chunk 1 states 30 days for monthly plans.

What good output looks like: Retrieval PASS (chunk 4, rank 4); Context assembly PASS; Generation FAIL — the model used chunk 1, which is about monthly plans, ignoring the plan-type qualifier. Experiment: rerun with chunk 1 removed. Fix: include each chunk's section heading so plan type is visible. Weak output jumps straight to "improve the prompt."

Sign in to upvote this prompt.