Lesson 21.3 · 3 of 5 · 4 min read · Reviewed 24 Nov 2026
Where naive RAG breaks
By the end, you can
- Spot the ways naive RAG fails.
- Match each failure to a fix.
Common failures
| Failure | Example | Fix |
|---|---|---|
| Chunk split mid-idea | Rule in one chunk, its exception in the next | Better chunking, overlap (23.1) |
| Vocabulary mismatch | Asks “PTO”, docs say “annual leave” | Hybrid search, query rewriting (23.2, 23.4) |
| Chunk lacks context | “It must be returned in 30 days” — what is “it”? | Contextual retrieval (23.5) |
| Needs several documents | “Compare plan A and plan B” | Multi-query or agentic RAG (chapter 24) |
| Exact ids and codes | Searching “ERR-4012” | Keyword search alongside vectors |
| Stale index | Policy changed last week | Re-index on change |
| Too many weak chunks | Twenty loosely related passages | Reranking, fewer chunks (23.3) |
| Model ignores sources | Answers from memory | Stronger grounding prompt, citations (21.2) |
Diagnose in two steps
- Retrieval: was the right chunkChunking: Splitting documents into smaller passages before embedding and indexing them. in the top results? Check with a test set (chapter 26).
- Generation: given the right chunk, did the model answer correctly and cite it?
Fixing the prompt when retrieval is the problem wastes time, and the other way round.
Key points
- Naive RAG fails when retrieval misses: bad chunking, vocabulary mismatch, questions needing several documents, or stale indexes.
- It also fails when retrieval succeeds but the model ignores or misreads the chunks.
- Diagnose first: was the right chunk retrieved? Then fix retrieval or generation accordingly.
Diagnose retrieval versus generation failures
Sort each failed RAG test case into a retrieval failure or a generation failure, so you fix the right half.
You will have: A diagnosis table over six test cases with counts per failure type.
Steps
- Read the test cases: the gold chunk id, the retrieved ids, and whether the answer was correct.
- If the gold chunk is not in the top retrieved ids, label it a retrieval failure.
- If it was retrieved but the answer is wrong, label it a generation failure.
- Count each label and print which half to work on first.
Done when
- 2 cases are retrieval failures.
- 1 case is a generation failure.
- The script names retrieval as the first thing to fix.
Open in the Playground No API key needed.
Starter code (Python)
CASES = [
{"q": "Return window for shoes?", "gold": "pol-4.2", "retrieved": ["pol-4.2", "pol-4.1"], "correct": True},
{"q": "PTO carryover?", "gold": "hr-2.3", "retrieved": ["hr-1.1", "hr-5.0"], "correct": False},
{"q": "Refund for ERR-4012 device?", "gold": "man-7.1", "retrieved": ["man-7.4", "man-7.2"], "correct": False},
{"q": "Sale items returnable?", "gold": "pol-4.3", "retrieved": ["pol-4.3", "pol-4.2"], "correct": False},
{"q": "Refund timing?", "gold": "pol-5.1", "retrieved": ["pol-5.1"], "correct": True},
{"q": "Clothing return window?", "gold": "pol-4.1", "retrieved": ["pol-4.1", "pol-4.2"], "correct": True},
]
def diagnose(case):
# TODO: return "ok", "retrieval" or "generation"
return "ok"
counts = {"ok": 0, "retrieval": 0, "generation": 0}
for c in CASES:
d = diagnose(c)
counts[d] += 1
print(f"{c['q']:30} {d}")
print(counts)
Show a solution
CASES = [
{"q": "Return window for shoes?", "gold": "pol-4.2", "retrieved": ["pol-4.2", "pol-4.1"], "correct": True},
{"q": "PTO carryover?", "gold": "hr-2.3", "retrieved": ["hr-1.1", "hr-5.0"], "correct": False},
{"q": "Refund for ERR-4012 device?", "gold": "man-7.1", "retrieved": ["man-7.4", "man-7.2"], "correct": False},
{"q": "Sale items returnable?", "gold": "pol-4.3", "retrieved": ["pol-4.3", "pol-4.2"], "correct": False},
{"q": "Refund timing?", "gold": "pol-5.1", "retrieved": ["pol-5.1"], "correct": True},
{"q": "Clothing return window?", "gold": "pol-4.1", "retrieved": ["pol-4.1", "pol-4.2"], "correct": True},
]
def diagnose(case):
if case["gold"] not in case["retrieved"]:
return "retrieval"
return "ok" if case["correct"] else "generation"
counts = {"ok": 0, "retrieval": 0, "generation": 0}
for c in CASES:
d = diagnose(c)
counts[d] += 1
print(f"{c['q']:30} {d}")
print(f"retrieval failures: {counts['retrieval']}, generation failures: {counts['generation']}, ok: {counts['ok']}")
first = "retrieval (chunking, hybrid search, query rewriting)" if counts["retrieval"] >= counts["generation"] else "generation (grounding prompt, citations)"
print("fix first:", first)