Contextual Precision
Contextual Precision is a single-turn metric used to evaluate a RAG retriever
Overview
The contextual precision metric is a single-turn RAG metric that uses LLM-as-a-judge to evaluate how well your retriever ranks the retrieved context based on the input query.
Required Parameters
These are the parameters you must supply in your test case to run evaluations for contextual precision metric:
inputstringRequired
The input query you supply to your RAG application.
expected_outputstringRequired
The expected output your RAG application has to generate for a given input.
retrieval_contextlist of stringRequired
The retrieved context your retriever outputs for a given input sorted by their rank.
How Is It Calculated?
The contextual precision metric evaluates each retrieved node using an LLM to check if it is correctly ranked for relevance to the input. It then calculates the final score using the following equation:
A high contextual precison score indicates that all the retrieved nodes are in the order of their relevance to the input.
Usage
To run the contextual precision metric on Confident AI, add it to a single-turn metric collection. This will allow you to use contextual precision metric for:
- Single-turn E2E testing
- Single-turn component-level testing
- Online and offline evals for traces and spans
Last updated on