The Evaluator-Optimizer pattern is a design approach in AI agent systems that enables iterative improvement. In this workflow, one component—the evaluator—assesses the output of another—the optimizer—and provides feedback, which the optimizer uses to refine its results. This loop continues until the output meets a predefined quality threshold.
How It Works
- Optimizer: Generates an initial output (e.g., text, code, or decision).
- Evaluator: Analyzes the output against criteria (correctness, relevance, tone) and returns scores or suggestions.
- Feedback Loop: The optimizer incorporates the evaluation to produce a revised version.
- Iteration: Steps 2 and 3 repeat until the evaluator signals acceptance.
Key Benefits
- Higher quality: Multiple passes reduce errors and improve coherence.
- Adaptability: The same pattern can be used for writing, coding, or planning tasks.
- Transparency: Each iteration provides a clear record of improvements.
Example Use Cases
- Content creation: An LLM writes a draft; a separate evaluator checks for factual accuracy and style.
- Code generation: A model writes code; an evaluator tests it and suggests fixes.
- Dialogue systems: A chatbot refines its responses based on a sentiment evaluator.
The Evaluator-Optimizer pattern is a core building block for building reliable, self-correcting AI agents.