New Tool Radar

AI Concepts

How to Measure Context Precision So Relevant Chunks Rank First

Score the retrieved chunks in rank order, and check the relevant ones sit above the irrelevant ones.

Schematic with three steps: Mark each returned chunk relevant or not; Score in rank order; Compare configurations on the same set.

Context precision measures whether the relevant chunks in the retrieved set rank above the irrelevant ones. It is not enough for the right chunk to be somewhere in the top 10: if it sits at rank 9 below 8 irrelevant chunks, the model must read through noise to find it, and a short context window may cut it off entirely. Context precision is one of the standard RAG metrics, and it is the metric to watch when you change the ranking, the re-ranker or the top-k.

What you need

  • A test question with the known relevant chunks
  • The ranked list the retriever returned, in order
  • A fixed top-k for the measurement

Step 1: Mark each returned chunk relevant or not

Go through the ranked list in order and mark each chunk relevant if it contains the answer, irrelevant if it does not. Do not mark a chunk relevant because it mentions the topic.

Step 2: Score in rank order

Give more weight to relevant chunks at the top of the list and less to the same chunk lower down. A relevant chunk at rank 1 scores far more than the same chunk at rank 9.

Step 3: Compare configurations on the same set

Run the same questions through each retriever configuration and compare the average context precision. A configuration that raises recall but drops context precision has traded ranking quality for coverage.

Worked example: synthetic context precision for one question

The table below is a synthetic example. It shows the expected result of scoring a ranked list; no retriever was run.

Rank Chunk Relevant?
1 Refund policy page Yes
2 Shipping policy page No
3 Refund window section Yes
4 General FAQ No
5 Pricing page No

Expected result (UNTESTED). 2 of 5 chunks are relevant and one sits at rank 1, so context precision is moderate, but the irrelevant chunk at rank 2 pushes good evidence down. This check was not run live; the table shows the expected result for the synthetic example.

Limits

  • Context precision needs ground truth for every question, so it costs more to measure than a simple hit rate.
  • A re-ranker usually raises context precision without changing recall, because it reorders the same set.
  • If the relevant chunk is never retrieved, context precision is zero for that question no matter how good the ranking is.
  • Context precision and context recall measure different things; report both, not one alone.

Sources

See all