Skip to main content

Required Arguments

Each test case must be a ModelTestCase instance with the following fields:
  • input: The user’s query.
  • actual_output: The LLM-generated response (not used in the score computation, but required).
  • expected_output: The ideal response used to extract ground-truth statements.
  • retrieval_context: A list of strings representing retrieved context chunks.

Optional Arguments

Usage Example

How It Works

  • The metric uses the expected_output to extract statements.
  • For each statement, an LLM determines whether it can be attributed to any node in the retrieval_context.
  • The contextual recall score is calculated as:
Contextual Recall=Number of Attributable StatementsTotal Statements in Expected Output\text{Contextual Recall} = \frac{\text{Number of Attributable Statements}}{\text{Total Statements in Expected Output}} This emphasizes information coverage, ensuring your retriever surfaces everything necessary for a correct and complete answer.

Use Cases

Ideal when you want to:
  • Ensure critical facts from your knowledge base are retrieved.
  • Improve the completeness of your RAG retriever, especially in complex or multi-fact queries.