Context Metric
The Context metric evaluates how well an AI assistant’s responses align with the provided system context. It accumulatescontext_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
Parameters
Required Parameters
Optional Parameters
Statistical Modes
- Frequentist
- Bayesian
Returns the weighted mean of per-interaction scores. CI fields are
None.Interaction Weights
EachBatch can carry an optional weight to control its contribution to the session aggregate:
Output Schema
ContextMetric
ContextInteraction
Interpretation
Context Awareness Score
Complete Example
LLM Provider Options
Best Practices
Use Bayesian Mode for Small Sessions
Use Bayesian Mode for Small Sessions
A session with 3 interactions gives a very uncertain mean. Bayesian mode expresses this with a wide CI, preventing overconfident conclusions.
Provide Clear Context
Provide Clear Context
Include specific, actionable instructions:
Include Ground Truth
Include Ground Truth
Provide
ground_truth_assistant for better evaluation:Weight Critical Interactions
Weight Critical Interactions
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