Deterministic Checks vs an LLM Judge: When to Use Which in AI Evals

Short answer: use a plain code check whenever code can decide pass or fail, and use an LLM judge only for qualities that need understanding, such as correctness of meaning or faithfulness to a source. Run the cheap checks first. Then calibrate the judge against a few answers you graded yourself. This keeps evals cheap, stable and honest.

Open the Evals Lab

Three layers

| Layer | What it checks | Example | Cost | |---|---|---|---| | 1. Deterministic | Anything code can decide | Valid JSON, required field present, no forbidden text, right tool called | Almost free, same result every time | | 2. LLM judge | Meaning and quality against a rubric | Is the answer correct? Is it supported by the retrieved text? | A model call per case, and the score can vary | | 3. Human review | A sample, to check layers 1 and 2 | Read 10 answers and the judge's reasons | Your time |

Layer 1: write the checks you can

import json

def check_answer(raw: str) -> list[str]:
    """Return a list of problems. An empty list means the answer passes the cheap checks."""
    problems = []
    try:
        data = json.loads(raw)
    except json.JSONDecodeError:
        return ["not valid JSON"]
    if "answer" not in data:
        problems.append("missing the answer field")
    if "password" in raw.lower():
        problems.append("mentions a password")
    if len(raw) > 2000:
        problems.append("too long")
    return problems

These run in milliseconds and never disagree with themselves. If an answer fails here, do not send it to the judge: you save a model call and you get a clearer reason.

Layer 2: a judge for what code cannot decide

A judge is a model that reads the question, the expected answer and the actual answer, and returns a score and a reason. Give it a rubric written as facts:

Score from 1 to 5.
5 = every key fact matches the expected answer and nothing is invented
3 = partly correct, or a key fact is missing
1 = wrong, or the question is not answered
Reply with JSON only: {"score": <1-5>, "reason": "<one sentence>"}

Ask for a reason on every score. The reason is how you find out whether the judge is reading the answer or just being generous.

Keep the judge honest

1. **Plant a wrong answer.** Put a deliberately wrong expected answer in your test set. A judge that passes it is not measuring anything.

2. **Grade a few yourself.** Grade 10 to 20 answers by hand and compare them with the judge. Where you disagree, fix the rubric. Some guides suggest a larger set of 30 to 200 pairs for a production judge.

3. **Run it twice.** The same judge prompt can give different scores on a vague criterion. If two runs disagree a lot, tighten the rubric.

4. **Watch for leniency.** A judge that gives almost everything full marks is a warning sign. Read the reasons.

A simple rule

If you can write the check as an `if` statement, write the `if` statement. Use the judge for what is left. Then repeat the judged cases a few times, because the judge is a model too.

Practise it free

The Evals Lab lets you do both in Docker on your own computer: add Python checks to `run_eval.py`, write judge criteria with DeepEval G-Eval in `eval_criteria.py`, run it, and compare runs in MLflow. You bring your own Gemini, Claude or OpenAI key, and nothing is uploaded to Data Utility.

For the failure-first method that decides what goes in each layer, read what to test in AI agent evals.

Open the Evals Lab

Related tool pages

Also try

How to use the Evals Lab: step by step

  1. List what your app must always do
  2. Write plain checks for everything code can decide
  3. Write a rubric for the rest and add a reason to every score
  4. Plant a wrong answer and compare the judge with your own grades

When to use the Evals Lab

  • Deciding which checks need a model
  • Cutting the cost of an eval suite
  • Making judge scores more stable
  • Explaining evals in an AI engineer interview

Example

Input: northwind_support_handbook.txt, chunked and stored in ChromaDB

Output: A score and a reason for every answer, and each run logged in MLflow

Frequently asked questions

When should I use an LLM judge instead of a code check?

When the quality needs understanding, such as whether an answer is correct in meaning or supported by a source. If code can decide pass or fail, use a code check.

Why run deterministic checks before the judge?

They are free and stable, and they remove answers that are plainly broken, so you spend fewer judge calls and get clearer reasons.

How do I know if my LLM judge is any good?

Plant a wrong answer and see that it fails, grade a few answers yourself and compare, run the judge twice to check it is stable, and read the reasons.

Tip: Run the deterministic checks first and only judge the answers that pass them. You pay for fewer judge calls and get clearer failures.