Skip to main content

Context Metric

The Context metric evaluates how well an AI assistant’s responses align with the provided system context. It accumulates context_awareness scores across all interactions in a session and emits one session-level result, with optional uncertainty quantification via Bayesian mode. The interactions list preserves per-QA scores for debugging.

Overview

  • Context Awareness: How closely the response follows the given context (0.0–1.0)
  • Session aggregate: Weighted mean across all interactions
  • Per-interaction detail: Each QA pair’s score accessible via interactions
  • Bayesian mode: Bootstrapped credible interval around the session mean

Installation

Basic Usage

Required Parameters

Optional Parameters

Statistical Modes

Returns the weighted mean of per-interaction scores. CI fields are None.

Interaction Weights

Each Batch can carry an optional weight to control its contribution to the session aggregate:

Output Schema

ContextMetric

ContextInteraction

Complete Example

LLM Provider Options

Best Practices

A session with 3 interactions gives a very uncertain mean. Bayesian mode expresses this with a wide CI, preventing overconfident conclusions.
Include specific, actionable instructions:
Provide ground_truth_assistant for better evaluation:
If some QA pairs test more important context rules, give them higher weights:

Next Steps

Statistical Modes

Frequentist vs Bayesian approaches

Conversational Metric

Evaluate dialogue quality with Grice’s maxims

Regulatory Metric

Compliance against a regulatory corpus