Velamuvi AIAcademy

Lesson 5 of 7 · Patterns

Evaluator-Optimiser

The evaluator-optimiser workflow: one LLM writes, another scores it against a rubric and gives feedback, and the loop repeats. Write rubrics and stopping rules.

  • 5 min read
  • Intermediate
  • Reviewed
In this lesson you will learn
  • Explain the evaluator-optimiser pattern
  • Write an evaluator rubric that gives scores and specific feedback
  • Set stopping rules: target score, no improvement, round limit
  • Recognise tasks where iterative refinement pays off

Two roles, one loop

It's the workflow form of the reflection pattern from the Agent Architecture course, with the evaluator as a separate, clearly defined step. It works best when:

  • there are clear criteria a good output must meet, and
  • feedback measurably helps: a human editor's comments would improve the draft.

Refining a translation

Try it yourselfPython
# ---- Evaluator-optimiser: one model writes, another evaluates against criteria, repeat ----
ATTEMPTS = iter([
    "Bienvenue ! Votre colis arrivera demain.",
    "Bienvenue ! Votre commande n° 4471 arrivera demain avant 18 h.",
])
def optimiser(source, feedback):
    """Stands in for the model that translates (and revises using feedback)."""
    return next(ATTEMPTS)

def evaluator(source, translation):
    """Stands in for an evaluator model with a rubric; returns a score and specific feedback."""
    issues = []
    if "4471" not in translation:
        issues.append("the order number 4471 is missing")
    if "18" not in translation:
        issues.append("the delivery time (before 6 pm) is missing")
    score = 10 - 4 * len(issues)
    return score, issues

source = "Welcome! Your order no. 4471 will arrive tomorrow before 6 pm."
feedback = []
for round_number in range(1, 4):
    translation = optimiser(source, feedback)
    score, feedback = evaluator(source, translation)
    print(f"Round {round_number}: {translation}")
    print(f"   score {score}/10" + (": " + "; ".join(feedback) if feedback else ""))
    if score >= 9:
        print("Accepted.")
        break

The first translation was fluent but dropped two facts. The evaluator's feedback named exactly what was missing, and the second attempt scored 10/10, so the loop stopped. Without the evaluator, a fluent but incomplete translation would have gone to the customer.

Writing the evaluator

A useful evaluator prompt contains:

  • A rubric: numbered criteria, each checkable (“all numbers, dates and names from the source appear in the translation”).
  • A score per criterion or overall, on a fixed scale.
  • Specific feedback: what's wrong and where, not “could be better”.
  • A structured reply (JSON) so code can read the score and decide.

Code checks work as evaluators too, for anything exact: required words, length, valid JSON, passing tests. Use a model only for criteria that need judgement.

Stopping rules

Each round costs an optimiser call and an evaluator call, so set three stops: a target score, a round limit, and no improvement (stop when a round doesn't beat the last one). Track scores across rounds in your logs: if most tasks need several rounds, the first prompt probably needs the rubric built in.

Common mistakes

Practice exercise

Write the stopping rule for an evaluator-optimiser loop, so it doesn't keep revising when it stops improving.

Your solutionPython
scores = [4, 6, 6, 7, 7]     # evaluator scores after each round of revision
target = 9
max_rounds = 5

# Decide when the loop should have stopped: at the first round that reaches the target,
# or at the first round whose score is no better than the round before, or at max_rounds.
# Print one line: Stop after round <n>: <target reached | no improvement | round limit>
Knowledge check

When is an evaluator-optimiser loop most likely to be worth its cost?

Summary

  • An optimiser produces, an evaluator scores against a rubric and gives specific feedback, and the loop repeats.
  • Use code checks for exact criteria and a model for judgement.
  • Stop at a target score, on no improvement, or at a round limit.
  • Calibrate evaluators against human judgement.

Next: a project that combines these patterns into a business automation.

Finished reading? Tick it off to track your progress.