Skip to main content

Required Arguments

Each test case should be a ModelTestCase instance with the following fields:
  • input: The original user query.
  • actual_output: The LLM-generated response based on retrieved context.
  • expected_output: The ideal response based on the context.
  • retrieval_context: A list of strings representing the retrieved context chunks used by the LLM.

Optional Arguments

Usage Example

How It Works

The metric calculates a weighted contextual precision score based on:
  • Whether each context node is relevant to the input and expected output.
  • The ranking of relevant nodes — higher ranks improve the score.
  • Uses an LLM to determine relevance, making the evaluation more aligned with human judgment.