"The right document was in the knowledge base, so why did the system give a wrong answer?" is one of the most common debugging questions in retrieval-augmented generation systems. The honest answer is usually that having the right document in the index, and actually retrieving and using it correctly, are two separate problems, each with its own failure modes.
Retrieval can fail even when the document exists
The chunk boundary cuts the answer in half
If a document is split into fixed-size chunks without regard for where the actual information boundaries are, the answer to a question can end up split across two chunks, with neither one containing the complete picture on its own. The retrieval step finds a chunk that's technically relevant but incomplete, and the model does its best with a partial answer.
The embedding doesn't capture what the question is actually asking
Semantic search relies on the embedding model placing similar meanings close together in vector space, but embeddings aren't perfect. A question phrased differently from the source document can retrieve a less relevant chunk than a human searching manually would find immediately. Hybrid search, which combines embeddings with keyword matching, and a reranking step are common ways to close this gap.
Too many similar documents dilute the actual answer
If the knowledge base has several documents covering similar ground, with small but meaningful differences (an old policy version and a current one, for instance), retrieval can surface the wrong one, or a blend that isn't quite right, unless the system has an explicit way to prioritize recency or authority.
Even when retrieval works, generation can still fail
The model doesn't actually use the retrieved content the way you'd expect
Retrieving the correct document doesn't guarantee the model weighs it correctly against its own training knowledge. Without an explicit instruction to prioritize retrieved content over general knowledge, a model can produce an answer that blends the two in a way that's subtly wrong, especially where the retrieved content contradicts what the model would otherwise "know."
Too much retrieved context buries the relevant part
Retrieving more chunks than necessary, on the theory that more context can only help, often does the opposite. The model's attention gets spread thin across irrelevant material, and the genuinely relevant chunk becomes easier to underweight.
How to actually diagnose which layer is failing
- Check what was actually retrieved, not just what the final answer said. Most RAG failures are diagnosable in minutes once you look at the actual retrieved chunks for a failing query, rather than only looking at the final output.
- Test retrieval quality separately from generation quality. If the right chunk was retrieved but the answer was still wrong, that's a generation and prompting problem. If the wrong chunk was retrieved, that's a retrieval and indexing problem. The fix is completely different in each case.
- Build a real evaluation set with known-correct answers and run it regularly. It's the same discipline covered in building an evaluation harness that actually catches regressions, applied specifically to retrieval quality rather than only end-to-end behavior.
What actually improves retrieval quality
- Chunk with structure awareness, respecting section and paragraph boundaries rather than fixed character counts, so an answer isn't arbitrarily split in two.
- Add metadata filtering, so recency, document type, or authority can narrow the candidate set before semantic similarity ranks within it. Don't rely on embedding similarity alone to work out which of several similar documents is the current one.
- Retrieve fewer, more targeted chunks rather than maximizing recall, and tune based on actual evaluation results, not intuition about what "more context" should do.
- Instruct the model explicitly to prioritize retrieved content, with clear behavior defined for what to do when retrieved content is insufficient or contradicts general knowledge, rather than leaving that judgment call implicit.
How we approach this
We treat retrieval evaluation as a distinct, ongoing discipline, separate from end-to-end testing. Retrieval failures and generation failures need different diagnosis and different fixes, and conflating them makes both harder to solve.