QA Interview Hub · Knowledge base · Quizzes · Українська

AI › How to test an LLM agent

Eval set, metrics and LLM-as-judge

An eval is an automated run of a set of examples through the system with scoring, working as regression tests for LLM features. A golden dataset is built from real logs, known bugs and negative cases. Free text is scored by an LLM-as-judge with a narrow rubric, on a different model; the judge is calibrated on human labels by the share of bad answers it rejects. Results are read per category.

AI for QA · Testing AI

A new prompt "looks better" on three examples. How do you prove it on a hundred examples instead of the same three?

A developer changed the system prompt, glanced at three answers, and they became neater. Someone thinks this is better, while on real requests the share of errors might have grown. Without a set of examples and metrics every such change stays an opinion. The lesson covers evals, the golden dataset, metrics and a judge that can score free text.

How it works and why. An eval (evaluation) is an automated run of a set of examples through the system with scoring of the results. It plays the role of regression tests for LLM features: a change of prompt, model or RAG is compared with a baseline on the same set. The components: a set of examples, running the system with a pinned configuration, scoring, a report.

An eval run from set to report

Golden datasetinput, expected behaviour, tagsSystem: model + prompt pinnedversions in the run reportScoring: checks and a judgerubric, binary scalesReport against the baselinepass rate by category, cost
Figure 1. The model and prompt are pinned and go into the report, so the difference between two runs can be explained.

Golden dataset. A curated set of cases: input, expected behaviour (not necessarily exact text) and tags (category, difficulty). Sources: real logs and tickets (anonymised), edge cases, known bugs (every found bug becomes a case), synthetic examples generated by a model and checked by a person. The set also covers negative scenarios: refusals, ambiguous requests, attempts to bypass rules, questions with no answer in the base. Part of the examples is kept apart from those used to tune the prompt, otherwise the metric reflects fitting, not quality.

LLM-as-judge. For free text the score is given by another model according to a rubric. To make it usable, some practices are followed. One narrow rubric per score instead of "rate the quality". A binary or short scale. Ask for the explanation before the verdict. Assign a different model as the judge than the tested one, because a model tends to prefer its own answers (self-preference). Pin the versions of the judge and its prompt. Set temperature zero where the model accepts it, and it does not guarantee identical scores. Account for the tendency to prefer longer answers and a certain position in a pairwise comparison.

A vague scale or a narrow rubric

Typical

Rate the quality from 1 to 10

The scale is vague, the score depends on the mood of the prompt and the answer length. Two scores cannot be compared.

Better

A narrow rubric with reasoning

One question per score: does the answer rely only on the provided documents. A short explanation first, then yes or no.

Figure 2. A narrow question with reasoning gives a score that can be checked and calibrated.

Example: a rubric and judge calibration. A rubric for checking that an answer of a RAG bot relies only on documents:

You grade an assistant answer.
Documents: {{docs}}
Answer: {{answer}}

Does every claim in the answer rely only on the documents?
First explain briefly, then give a verdict.
Reply as JSON: {"reason": "...", "grounded": true|false}

The judge can be wrong too, so it is calibrated: a sample of answers is labelled by hand (acceptable or not) and compared with the judge verdicts.

// human[i] and judge[i]: is answer i acceptable
function calibrate(human: boolean[], judge: boolean[]) {
  const agree = human.filter((h, i) => h === judge[i]).length / human.length;
  const badIdx = human.flatMap((h, i) => (h ? [] : [i]));
  // share of bad answers that the judge also called bad
  const caught = badIdx.filter((i) => !judge[i]).length / badIdx.length;
  return { agree, caught };
}

agree shows overall agreement, but for quality caught matters more: what share of bad answers the judge actually rejected. A judge that agrees with people 95% of the time but lets half of the defects through is unfit for regression control. If agreement is low, change the rubric, add examples to the judge prompt or take another model, then calibrate again. Calibration is repeated when the judge model changes.

Metrics. Pass rate by category and tag, not one average, because an average hides a failure in one category. The refusal rate (and refusals where they are inappropriate). Average and p95 of tokens, cost and latency per case. Unstable cases: those that do not always pass. Every change of prompt, model or RAG is compared with the baseline on the same set, taking the noise of repeats into account.

Limits and alternatives. A judge does not replace people: it is a fast cheap filter, while hard and disputed cases stay with manual labelling. An eval measures what is in the set: new kinds of requests are absent from it, so the set is topped up from production (see the lesson on evals in CI). For small tasks with a clear correct output (classification, field extraction) a judge is not needed: an exact comparison is enough.

Common mistakes.

  • A "1 to 10" score with no rubric. Consequence: unstable, incomparable scores.
  • A judge of the same model as the tested one. Consequence: inflated scores for its own answers.
  • Not calibrating the judge. Consequence: the metric looks good while defects pass.
  • Tuning the prompt to the cases of the set. Consequence: the metric grows, real quality does not.
  • One average over the whole set. Consequence: a failure in one category is invisible.

Check yourself

A judge agrees with people 90% of the time, but of 20 labelled bad answers it called only 11 bad. Is it fit as regression control?

Answer

No. Overall agreement is high because most answers are good, but the judge misses 9 of 20 defects (45%). For quality control the share of caught defects matters. The rubric or the judge is changed and calibrated again.

The pass rate on the set rose from 84 to 87%, but in the "refusals" category it fell. What do you do?

Answer

Look by category, not at the average. A drop in the "refusals" category may be a safety regression that the average hid. The decision is made by the risk of the category, not by the overall number.

Why is the judge not the same model that answers?

Answer

A model tends to prefer its own style and wording (self-preference), so scores are inflated. Take another model with a pinned version and calibrate it on human labels.

In an interview. Junior: An eval is an automatic run of a set of examples through the system with scoring. LLM-as-judge scores free text by a rubric. Middle/Senior: I build the set from real logs, known bugs and negative cases, and make the judge a narrow rubric with reasoning before the verdict, on another model, calibrated on human labels by looking at the share of caught defects. I read results by category, and compare every change with a baseline on the same set.

More articles in this chapter