Skip to content
mentoor

Topic 6 of 6 · 5 min read

Turning failure modes into evaluators

Goal: Choose a code-based check, an LLM judge or no evaluator for each failure mode and justify the choice.

For each failure mode, choose the cheapest evaluator that can catch it reliably: a code check first, an LLM judge only when the failure needs judgment, and nothing at all when a fix removes the cause for good. An evaluator is a thing you must maintain, so build only the ones that earn their place.

Check yourself · 1 of 3

A failure mode is "response is not valid JSON". Which evaluator fits?

Choose one answer

Why it matters

After error analysis you have a ranked list. The temptation is to write an LLM judge for every row. Judges cost money on every run, can be wrong, and need their own checking against human labels. Many failure modes do not need one.

How to choose

Ask three questions in order:

  1. Can code decide it? If the failure is checkable by a rule, write a code check: a regex, a schema validation, a string match, a comparison with a known value, a tool-call assertion. It is fast, free and exact. "Reply is not in the user's language" can use a language detector. "Output is not valid JSON" can use a parser.
  2. Does it need judgment about meaning? Tone, faithfulness to a source, or "did it answer the actual question" cannot be captured by a regex. Use an LLM judge, scoped to one failure mode with a binary pass or fail and a short critique. Then compare its verdicts to your own labels on a held-out set before trusting it.
  3. Is a fix enough? If a retrieval change, a schema constraint or a deleted tool makes the failure impossible, no evaluator may be needed. Add a one-time check instead and move on. Keep an evaluator for failures that are costly and could silently return.

Before and after

Mode: quotes the wrong plan price      -> code check: compare quoted price to the pricing table
Mode: replies in the wrong language    -> code check: language detector on input and reply
Mode: invents a feature                -> LLM judge: reply claims vs retrieved docs, pass/fail
Mode: archived page in retrieval       -> fix the index, no evaluator

The weak version would be one general judge scoring "overall quality" across all four. It would be slow, vague and hard to trust.

What goes wrong

  • A judge for everything. It adds cost and noise where a rule works.
  • An unvalidated judge. If you never compare it with human labels, a judge that agrees with you 60 percent of the time looks like a measurement.
  • A vague rubric. "Is the answer good?" gets inconsistent verdicts. One failure mode per judge, with clear pass and fail definitions, gets better ones.
  • Evaluators for fixed problems. Keeping a check for a failure that can no longer happen is upkeep with no benefit.

Examples

Code beats judge

A bot must always return JSON with a "citations" array. A schema validator that runs on every response catches missing or empty arrays in milliseconds. An LLM judge asked "is the format right?" would be slower and sometimes wrong.

A narrow judge

The mode "claims a refund was issued when the tool returned an error" needs judgment over the trace. A judge gets the tool result and the final reply and answers pass or fail with one sentence. The team labels 50 traces by hand and compares verdicts before putting it into CI.

Key points

  • Pick the cheapest evaluator that catches the failure reliably: code check, then LLM judge, or none.
  • Use a code check when a rule, schema or comparison can decide the failure.
  • Use an LLM judge only for failures that need judgment about meaning, one mode per judge, with pass or fail.
  • Validate any LLM judge against human labels before trusting its verdicts.
  • Skip an evaluator when the fix removes the cause, and keep evaluators for costly failures that could return.

Common mistakes

  • Writing an LLM judge for a failure that a regex or schema check could catch.
  • Using one broad "quality" judge across many failure modes.
  • Trusting a judge without checking it against human labels.
  • Maintaining an evaluator for a failure the fix made impossible.

Check yourself · 2 of 3

When does a failure mode call for an LLM judge instead of a code check?

Choose one answer

Check yourself · 3 of 3

Your new LLM judge for "invents a feature" agrees with your own labels on 22 of 40 traces. What should you do?

Choose one answer

Practice items, not counted towards your mastery.

Start here

More for this topic