New Tool Radar

AI Concepts

How to Diagnose Why RAG Retrieved the Wrong Chunks

Compare the question with the returned chunks, check the embedding and the filters, and fix the cause instead of adding more chunks.

Schematic with three steps: Compare the question with the returned chunks; Check the embedding, the filter and the; Fix the cause, then re-measure.

When RAG returns the wrong chunks for a question that has an answer in the documents, the failure is in retrieval, and adding more chunks or a bigger context window will not fix it. The causes are usually one of four: the question wording does not match the document wording, the embedding model handles the language or the domain poorly, a metadata filter excludes the right document, or the chunking split the answer across a boundary. Diagnose in that order, and fix the cause you find.

What you need

  • A question with a known correct document
  • The chunks the retriever returned, in rank order
  • The embedding model, the filters and the chunking settings in use

Step 1: Compare the question with the returned chunks

Read the top chunks and note whether they share words with the question or share meaning. Chunks that share words but not meaning point to a keyword problem; chunks that share neither point to an embedding or chunking problem.

Step 2: Check the embedding, the filter and the chunk boundary

Test the same question with the filter removed to see if the filter hid the answer. Then check whether the answer is split across two chunks, and whether the embedding model handles the question language.

Step 3: Fix the cause, then re-measure

Fix only the cause you found: rewrite the query, loosen the filter, re-chunk the document, or change the model. Then run the same test set again and confirm the correct chunk now ranks in the top results.

Worked example: synthetic wrong-chunk diagnosis

The table below is a synthetic example. It shows the expected result of diagnosing a retrieval failure; no search was run.

Check Found Fix
Top chunks Share words, not meaning Keyword mismatch
Filter removed Correct chunk appears Filter was too strict
Chunk boundary Answer split in two Re-chunk with overlap
After fixes Correct chunk at rank 1 Pass

Expected result (UNTESTED). the filter hid the answer and the chunking split it, and after both fixes the correct chunk ranks first. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Dense-only search beat hybrid in one published 156-query benchmark, so the fix is not always to add keyword search.
  • Chunk size barely mattered in that benchmark, so do not assume re-chunking alone will fix a retrieval failure.
  • A test set with known ground truth is the only way to know whether a fix worked; a single example can mislead.
  • If the correct document is not in the knowledge base at all, no retrieval fix will find it.

Sources

See all