Skip to main content
Evaluators are functions that run after an evaluation completes, adding additional scores based on the result.

Basic Evaluator

An evaluator receives an EvalResult and returns a score dictionary:

Multiple Evaluators

Chain evaluators for multiple automated checks:

Evaluator Patterns

Reference Comparison

Semantic Similarity

LLM-as-Judge

Content Safety

JSON Validation

Reusable Evaluator Collections

Create evaluator sets for different use cases:
Use them:

Async Evaluators

Evaluators can be async:

Returning None

Return None to skip adding a score:

Evaluator vs In-Function Scoring

  • The check is reusable across many evaluations
  • You need post-processing after all data is set
  • External API calls that should be separate from main logic
  • Standard checks (format, length, safety) that apply broadly
  • The scoring logic is specific to this evaluation
  • You need access to intermediate computation
  • The score depends on test-specific context
  • Simple one-off checks

Best Practices

  1. Keep evaluators focused: One evaluator, one metric
  2. Return meaningful notes: Help debug failures
  3. Handle edge cases: Check for None values
  4. Make them reusable: Parameterize thresholds
  5. Group related evaluators: Create logical collections