Contextual Precision
Evaluates whether relevant documents in the retrieval context are ranked higher than irrelevant ones.
The Contextual Precision metric is one of several non-deterministic Metric Types Galtea uses to assess how well your RAG pipeline’s retriever prioritizes relevant content. Specifically, it checks whether relevant items in the retrieval_context
are ranked higher than irrelevant ones, based on their contribution to answering the user’s query.
High contextual precision means that the retriever is efficiently surfacing the most useful information near the top.
Evaluation Parameters
To compute the contextual_precision
metric, the following are required:
input
: The user’s query.retrieval_context
: The list of retrieved documents or nodes, in ranked order.
This setup allows for a rank-sensitive evaluation of retrieval effectiveness.
How Is It Calculated?
The score is calculated as follows:
- Relevance Annotation: An LLM identifies which items in the
retrieval_context
are relevant to theinput
. - Ranking Evaluation: It checks whether relevant items appear near the top of the list.
The metric is computed using a simplified formula:
Where k is a configurable cutoff (e.g., top 5 or top 10). This helps gauge whether the most useful content is easily accessible to the generator.