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

> When should an AI eval use a code check and when an LLM judge? A three-layer approach with examples, and how to keep your judge honest. Free lab.

Page: https://datautility.in/blog/deterministic-checks-vs-llm-judge-when-to-use-which
This is the Markdown copy of the page. The tool itself runs in the browser: your files are processed on your own device and are not uploaded.

Published 2026-11-29 · Analyze & protect · llm as a judge vs deterministic, deterministic checks ai evals, when to use llm judge, ai eval best practices, llm judge cost, g-eval vs assertions, how to evaluate llm output

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 tool: [Evals Lab](https://datautility.in/ai-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

```python
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:

```text
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](https://datautility.in/ai-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](https://datautility.in/blog/what-to-test-in-ai-agent-evals-start-from-failures).

## 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.

## Related tool pages

- [LLM as a Judge Playground: Grade AI Answers Free](https://datautility.in/llm-as-a-judge-playground): Try LLM as a judge free on your laptop: write a judge prompt or a DeepEval G-Eval metric, run it on every test question and read a score and a reason for each answer.
- [RAG Evaluation Playground: Test Chunking and Retrieval](https://datautility.in/rag-evaluation-playground): Evaluate a RAG app free on your computer: chunk a document into ChromaDB, test retrieval by meaning, grade every answer and compare chunk sizes side by side in MLflow.
- [DeepEval Playground: Try G-Eval Free on Your Laptop](https://datautility.in/deepeval-playground): Learn DeepEval hands-on, free: a Python IDE with a ready G-Eval project, goldens.csv, your own Gemini, Claude or OpenAI key and MLflow tracking. Runs in Docker.
- [Chunk a Document Into ChromaDB: Free Local Vector DB](https://datautility.in/chromadb-playground): Upload a document, pick a chunking method and see every chunk and vector stored in ChromaDB, free in Docker. Then connect your own AI agent to that database. No API key.

## Also try

- [What to test in agent evals](https://datautility.in/blog/what-to-test-in-ai-agent-evals-start-from-failures)
- [Can you trust an LLM judge?](https://datautility.in/blog/can-you-trust-llm-as-a-judge-check-your-judge)
- [DeepEval G-Eval: write evaluation steps](https://datautility.in/blog/deepeval-g-eval-write-evaluation-steps)

## More guides

- [Data Profiler: Check Data Quality Before You Use It](https://datautility.in/blog/data-profiler-check-data-quality)
- [Compare Two CSV or Excel Files: Find Added, Removed and Changed Rows](https://datautility.in/blog/compare-two-csv-files-find-differences)
- [Data Masking: Hide Emails, Phones and Names Before Sharing](https://datautility.in/blog/data-masking-hide-emails-phones-pii)
