New Tool Radar

AI Concepts

How to Check the Top-k Chunks a RAG Retriever Returns for a Question

Check the top-k chunks your retriever returns for a question before trusting the answer built on them.

Schematic illustration of check the top-k chunks a rag retriever returns for a question: step one set k to 5, step two read the 5 chunks, step three count the relevant ones.

A RAG answer is only as good as the chunks retrieved for it. Before you trust an answer, look at what the retriever actually returned: set k, the number of chunks retrieved, to a small number such as 5, read all 5, and count how many are relevant to the question. If most are irrelevant, the answer is built on noise, whatever it says.

Prerequisites

  • A working retriever over an embedded index.
  • A test question with a known answer in the documents.
  • Access to the retriever’s returned chunks, not just the final answer.

Steps

Step 1: Set k to 5

Set the retriever to return 5 chunks. Five is small enough to read and large enough to show whether the ranking works.

Step 2: Read the 5 chunks

Read each chunk and mark it relevant or not: does it contain information that helps answer the question? Do not judge by the final answer; judge the chunks on their own.

Step 3: Count the relevant ones

Count the relevant chunks out of 5. Three or more relevant means retrieval is working for this question; fewer means you need to change the chunking, the embedding model or the query.

Worked example: Harbor Light library opening hours

The fictional Harbor Light library asks its RAG system when the library opens on Saturdays. The retriever returns 5 chunks.

Rank Chunk topic Relevant
1 Saturday opening hours Yes
2 Weekday opening hours Yes
3 Holiday opening hours Yes
4 Library history No
5 Book donations No

Three of the 5 chunks are relevant, and the top chunk gives the Saturday hours, so retrieval works for this question.

Expected result. You can say how many of the top 5 chunks were relevant, and the answer is traceable to the top chunk. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • One question does not prove retrieval works; test at least 20 questions before changing anything.
  • Relevance is a judgement call; have a second person mark a sample to check your marking.
  • This guide does not cover re-ranking, which is a separate step.

Sources

See all