Evaluator–Optimizer: let the model critique its own work
Pair a generator with an evaluator in a feedback loop — generate, critique, refine — until the output clears a bar you define. Iteration as an AI workflow.
Humans rarely nail a piece of writing or code on the first draft — we write, review, and revise. The evaluator–optimizer pattern gives an AI workflow the same loop: one LLM generates a solution, a second evaluates it against explicit criteria, and its feedback drives another attempt. The cycle repeats until the output clears the bar or hits a limit.
How it works
Separating the two roles is what makes this work. The generator focuses on producing; the evaluator focuses on judging against a clear rubric — and critiquing is a genuinely easier task than creating, so the evaluator can be reliable. The feedback isn't a thumbs-down; it's specific, actionable notes the generator uses on its next pass.
- Works best when you have clear evaluation criteria the evaluator can apply consistently.
- The feedback must be specific — 'tighten the second paragraph', not 'make it better'.
- Always cap the loop: a max iteration count stops it spinning forever.
let solution = await generator(task);
for (let i = 0; i < MAX_ITERS; i++) {
const verdict = await evaluator(task, solution);
if (verdict.accepted) break;
solution = await generator(task, verdict.feedback); // refine
}
return solution;When to use it
Reach for it when quality matters more than latency and you can articulate what 'good' looks like — literary translation, complex code, anything you'd naturally send back for a second draft. It costs more calls, so it's overkill for simple tasks. But where the bar is high, letting the model critique and refine its own work is remarkably effective.
The model's first draft is rarely its best. Give it a critic and a second chance, and the ceiling goes up.