Launch Week 3: Five days of launches

Turn Contextual Precision

Turn Contextual Precision is a multi-turn metric used to evaluate a RAG retriever at each turn

Overview

The turn contextual precision metric is a multi-turn RAG metric that uses LLM-as-a-judge to evaluate how well your retriever ranks the context it retrieves at each turn of the conversation.

Required Parameters

These are the parameters you must supply in your test case to run evaluations for turn contextual precision metric:

turnslist of TurnRequired

A list of Turns as exchanges between user and assistant.

Parameters of Turn:

roleuser | assistantRequired

The role of the person speaking, it's either user or assistant

contentstringRequired

The content provided by the role for the turn

retrieval_contextlist of stringRequired

The retrieved context your retriever outputs for the turn sorted by their rank

expected_outcomestringRequired

The expected outcome your chatbot has to reach for the given conversation.

How Is It Calculated?

The turn contextual precision metric slides a window over the turns and uses an LLM to evaluate each retrieved node in the window on whether it was useful in arriving at the expected outcome, weighting the nodes that appear earlier more heavily.


Turn Contextual Precision=Turn Contextual Precision ScoresTotal Number of Assistant Turns\text{Turn Contextual Precision} = \frac{\sum \text{Turn Contextual Precision Scores}}{\text{Total Number of Assistant Turns}}

The final score is the average of the contextual precision scores of every assistant turn in the conversation.

Usage

To run the turn contextual precision metric on Confident AI, add it to a multi-turn metric collection. This will allow you to use turn contextual precision metric for:

  • Multi-turn E2E testing
  • Online and offline evals for traces and spans

Last updated on

Built byConfident AI