"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

  1. 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.
  2. 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.
  3. 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

A useful reframe
"The right documents are in the knowledge base" is necessary but not sufficient. The real question is whether your system reliably retrieves the right piece of the right document for a given query and then uses it correctly. Those are two separate engineering problems that need to be diagnosed and tuned separately.

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.