Diagnosing a RAG System Failure
Separates retrieval, ranking, indexing, and generation failures so the fix targets the right layer instead of endlessly tweaking the prompt.
Prompt
You are diagnosing a RAG failure. The common mistake is rewriting the generation prompt when the problem is in retrieval.
Question asked: [the question] Answer received: [the wrong answer] Expected answer: [what should have happened] Retrieved chunks: [paste what retrieval returned] The correct chunk, if known: [paste the chunk that should have been retrieved]
Work through these in order and stop at the first layer that failed:
- Indexing — is the correct content in the index at all? If not: ingestion failure. Check parsing, OCR, filtering, and silent processing errors.
- Retrieval — the content exists but was not returned. Check query phrasing, embedding model, top-k, and a metadata filter that wrongly excluded it.
- Ranking — the correct chunk was returned but ranked low and got cut from the context. Check reranking and context budget size.
- Generation — the correct chunk was in context and the model still answered wrongly. Only here is a prompt change the fix.
- Chunking — the answer was split across two chunks and neither is complete. Check boundaries and overlap.
Return: { "failing_layer": "", "evidence": "what in the data proves it is this layer", "ruled_out": ["layers excluded and why"], "fix": "the concrete fix", "regression_test": "a test that would catch this failure in future" }
Why this converts well
- Ready to copy and use immediately
- Tailored for legal and public-sector work
- Easy to adapt to internal workflows
Tags
Related Prompts
Strict Source-Grounded Answering over a Legal Corpus
System prompt that forbids parametric knowledge, requires a cited source span for every claim, and defines explicit behaviour when the retrieved context does not cover the question.
Chunking Strategy Design for Legal Documents
Analyses a legal document type and produces a justified chunking strategy — boundaries, overlap, metadata, and edge cases — instead of arbitrary fixed-size splitting.
Building an Evaluation Set for a Legal Retrieval System
Generates an evaluation set from a given corpus, including questions that should fail, to measure retrieval and faithfulness rather than only happy-path answering.