Knowing If It WorksLesson 45 of 76

Contents

Knowing If It Works

Lesson 45 of 76. Sign in to keep your place.

Module 5 · Automating judgement

The checks that cost nothing and catch most of it

8 min read

Three tiers of checking, four orders of magnitude apartHuman reviewtwo to five minutes and real money; the only tierthat settles a new questionModel judgeabout a second and a fraction of a penny; repeatableto within its own noiseDeterministic codemicroseconds, free, perfectly repeatable; runs firston everythingRun from the bottom up, and let each tier filter for the one above it. A judge asked about an outputthat is not valid JSON has spent a call to learn what json.loads knew for free.
Run from the bottom up, and let each tier filter for the one above it. A judge asked about an output that is not valid JSON has spent a call to learn what json.loads knew for free.

Figure

Order your checks by price

There are three tiers of checking, and they differ by four orders of magnitude in cost:

  • Deterministic code. Microseconds, free, perfectly repeatable.
  • Model judge. Roughly a second and a fraction of a penny per call, repeatable to within its own noise.
  • Human. Two to five minutes and real money, and the only one that can settle a new question.

Run them in that order and let each tier filter for the next. A judge asked to assess the quality of an answer that is not valid JSON has burned a call to tell you something json.loads knew for free.

Most teams build the middle tier first, because it is the interesting one. Then they discover their judge’s most common verdict is “the output was truncated”.

What code can check

More than people expect. Every item here is a real production failure mode, and every one is a few lines:

  • Structure. Does it parse as JSON? Validate against a JSON Schema, in jsonschema or Pydantic. Are all required fields present, of the right type, and is every enum value in the allowed set?
  • Grounding, cheaply. Every quoted span the model claims to have taken from the source is a substring of the source. Every cited document id exists. Every URL is one from the supplied context, not one the model composed.
  • Numbers. Sums add up. Line items total the stated total. Dates are valid, in range, and in the right order. A percentage is between 0 and 100. VAT is what the arithmetic says.
  • Language. The output language matches the input’s, via langdetect or fasttext: a free 900-language model that runs in milliseconds.
  • Leftovers. No [INSERT NAME], Lorem ipsum, As an AI language model, TODO, or the system prompt echoed back.
  • Bounds. Length between a floor and a ceiling. Truncation detection: did it stop because it finished, or because it hit the token limit? The finish reason is in the API response and going unchecked is one of the most common silent failures in production.
  • Privacy. No email address, phone number or card-shaped digit string that was not in the input.
  • Repetition. The same sentence three times, or a trailing loop: a cheap n-gram check catches degeneracy that a judge often rates as “thorough”.

Write them as ordinary tests. pytest over a JSONL file is a perfectly good eval harness for this tier, it runs in CI, and it is free.

The first number to get

Before any quality work, measure what fraction of outputs fail a structural check. It is a ten-minute job and it is routinely much higher than the team’s guess: the guess is usually near zero, because the team has only ever looked at outputs that rendered.

When that number is meaningful, fix it before anything else, and fix it in the right place. Structured-output or JSON-mode support from the provider, a constrained decoder such as outlines or guidance, or one retry on a parse failure will each do more for your quality metric than a week of prompt rewriting. And they are boring, which is why they get skipped.

Assertions live next to the data

Keep the checks per item, not per suite. Some items have specific expectations: this invoice’s total is 4,320; this query must return the Delhi office’s address; this refusal must not name a competitor. Store them with the item:

JSON Lines
{"id": "inv-041",
 "input": "...",
 "assert": [{"type": "json_field", "path": "total", "equals": 4320},
            {"type": "not_contains", "value": "approximately"},
            {"type": "language", "equals": "input"}]}

This is exactly how promptfoo models an eval, and if you want the pattern without writing it, promptfoo is MIT-licensed, runs from a YAML file, and takes about twenty minutes to get running. Inspect from the UK AI Safety Institute is the more programmable free option. DeepEval wraps the same ideas around pytest. Commercial platforms (Braintrust, Langfuse’s paid tiers, LangSmith) add hosted dashboards and team features on top of the same fundamentals.

Start with a JSONL file and a for-loop anyway. You will understand what any platform is doing, and moving 200 items into a tool later is an hour’s work, while adopting a platform before you know what you are measuring shapes your evaluation around the tool’s opinions.

The rule of thumb

Before adding any judge call, ask whether code could decide it. If the answer is “code could decide it if the output were structured”, change the output to be structured. Every check you move down a tier makes your evaluation faster, cheaper, perfectly repeatable, and immune to the judge drifting under you.

Every lesson here is open. Your progress is recorded once you pass the Shipping It exam.

Check your understanding

A team’s LLM judge reports that 18% of their extraction outputs are “low quality”. What should they check before tuning the prompt?

Pick the one you would defend. Your answer stays private.

Next lesson · 9 minChecking an answer against the passages it was given

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘The checks that cost nothing and catch most of it’, in Knowing If It Works. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/evaluating-ai/cheap-checks-first (Accessed: 13 October 2026).