Understanding Context Precision and Context Recall in RAG Systems
When you build or test a Retrieval-Augmented Generation (RAG) system, two terms come up again and again: context precision and context recall. If they are new to you, do not worry. In this article I will explain both in the simplest way I can, with real examples.
Whether you are a developer, a QA, or just someone curious about how to evaluate LLMs properly, these two metrics will give you a clear way to judge whether your retrieval is doing its job.
A quick recap: what is RAG?
In a RAG system, when a user asks a question, the system:
- Retrieves the most relevant documents from a vector database, based on similarity
- Combines the retrieved content with the user’s question
- Sends it to an LLM (like GPT-4) to generate a final answer
If any of that is unfamiliar, I cover it from scratch in what is RAG. The question these two metrics answer is this: how do we know whether the retrieved documents were actually useful, and whether we found all of them?
What is context precision?
Context precision measures how much of the retrieved content is actually relevant to the question.
Think of it this way: of everything I pulled from the database, how much was useful?
Here is an example. You ask, “What is the average cost of living for a single person in Singapore?” The system retrieves five documents. When you review them:
- 3 are about the cost of living
- 2 are about tourist attractions, which are not useful
So:
Context precision = 3 relevant / 5 total = 0.6, or 60%
✅ High precision means most of the retrieved documents were on topic. ❌ Low precision means too much irrelevant information, or noise.
(For the curious, the real numbers behind that example are in my guide to the cost of living for singles in Singapore.)
What is context recall?
Context recall measures how much of the relevant content you actually found.
Think of it this way: out of everything in the database that could have helped, how much did I retrieve?
Here is an example. There are 4 good documents in the database that could answer the question. Your system retrieves only 2 of them.
So:
Context recall = 2 retrieved / 4 relevant = 0.5, or 50%
✅ High recall means you captured most of the useful information. ❌ Low recall means you missed important pieces.
The two side by side
| Metric | Think of it as | Simple analogy |
|---|---|---|
| Context precision | How much of what I got was good? | How many of the books you picked were useful? |
| Context recall | Did I get everything I needed? | Did you grab all the books that had the answer? |
Precision is about noise, and recall is about completeness. A strong RAG system needs both: it should retrieve mostly relevant documents, and it should not miss the ones that matter.
Knowing the theory is one thing. Measuring it on a real system is another. In how to set up RAGAS and run your first LLM evaluation test, I show you how to score context precision in code with a working example.
That’s it for today, guys. Thank You for Reading! I hope you found this article informative and useful.
If you think it could benefit others, please share it on your social media networks with friends and family who might also appreciate it.