prev next

Chapter 9.4: Evaluator & Judge Agents

In complex agentic systems, ensuring the quality, safety, and accuracy of generated content or actions is crucial. Evaluator or Judge Agents are specialized agents designed for this purpose. They act as automated critics, assessing the output of other agents against a set of predefined criteria or a learned model of quality. This creates a feedback loop that enables iterative improvement and self-correction.

The Mathematical Basis of Evaluation

An evaluator agent's function can be seen as a scoring or classification problem. Given an output O (e.g., a piece of text, a plan, a piece of code), the evaluator agent computes a score or a set of scores.

Score(O) = f(O, C)

Where:

  • O is the output to be evaluated.
  • C is the set of criteria (e.g., relevance, coherence, safety, correctness).
  • f is the evaluation function, which can be a simple heuristic, a statistical model, or another LLM.

The score can be a single value (e.g., a quality score from 1 to 10) or a vector of scores across different dimensions.

ScoreVector(O) = [score_relevance, score_coherence, score_safety, ...]

Types of Evaluation Criteria

Objective Metrics: Based on verifiable facts. (e.g., Does the code compile? Is the factual claim correct?)
Subjective Metrics: Based on quality and style. (e.g., Is the text well-written? Is the answer helpful?)
Safety & Alignment: Based on ethical guidelines. (e.g., Is the content harmful? Does it align with human values?)

Visualization: The Evaluation Feedback Loop

The D3.js visualization below shows an agent generating a response, which is then passed to an evaluator agent. The evaluator provides a score and feedback, which can be used by the original agent to refine its output.