Zero Labs
Industry News / AI

The Anatomy of an AI Eval

Source · Towards AI By Ejiro Onose

From the publisher’s feed, collected in the ZeroLabs newsroom.

AI Evals Explained: The Anatomy of an AI EvalAn AI evaluation, or eval, is a structured way to measure whether an AI system behaves as expected. It defines what the system is supposed to do, tests it against a collection of cases, and assesses its outputs against specific criteria.Evaluating AI systems requires more than checking whether an answer is correct. Their outputs can vary, and a response can sound convincing while still being inaccurate, incomplete or irrelevant. An evaluation needs to account for these differences and provide a consistent way to judge performance.A well-structured eval has six building blocks: the task, dataset, test cases, evaluator, scoring criteria and thresholds. Each serves a distinct purpose, and understanding how they fit together is essential to building evaluations that produce useful results.The Six Components of an AI Eval1. Task: What are you evaluating?The task defines what the AI system is expected to do. It establishes the scope of the evaluation and gives the other components a clear objective.This matters because an evaluation cannot measure performance meaningfully without first defining what good performance looks like. The task should describe the expected behaviour, the boundaries of the system and what it should do when it cannot complete a request.A request enters a defined task scope. Requests it can’t complete are declined.A clearly defined task also helps prevent evaluations from measuring the wrong thing. An evaluation designed to assess information retrieval, for instance, should not rely solely on whether the final generated response is well written.2. Dataset: What will you test?A dataset is the collection of inputs used to evaluate an AI system. It provides the material against which the system’s performance is measured.An evaluation dataset should represent the range of conditions the system is likely to encounter. This includes straightforward inputs, ambiguous requests, edge cases, adversarial inputs and requests outside the system’s intended scope.A dataset containing simple, ambiguous, edge case, adversarial and out-of-scope inputs.A dataset made up entirely of simple, predictable inputs can give a misleading picture of performance. It may show that a system handles familiar requests well while revealing little about how it behaves when the input is unclear or unexpected.Evaluation datasets are often referred to as golden datasets, particularly when they contain carefully reviewed examples and expected outcomes. They should also be kept separate from the data used to train or tune a system where possible. Otherwise, repeated exposure to the same cases can make evaluation results look better than performance on unfamiliar inputs.3. Test cases: What does each evaluation check?A test case is an individual record within an evaluation dataset. While the dataset provides the collection and its coverage, each test case defines a specific condition the system must handle and what the evaluation should check.A test case can contain an input, an expected outcome or reference answer, a category, and tags that describe the behaviour being tested. Depending on the task, it may also include relevant context or other expected outputs.One test case with an input, expected outcome, category and tags.It is important to distinguish between what a system receives and what it is expected to produce. In retrieval evaluations, a test case may specify which information or document should be retrieved. In generation evaluations, it may provide the context the model should use and define what a satisfactory response should contain.These checks should not be treated as interchangeable. A system can retrieve the right information but generate an inaccurate answer from it. Equally, a response may appear correct without being supported by the retrieved material.4. Evaluator: Who or what judges the output?The evaluator determines whether the system’s output meets the requirements of a test case. It applies the evaluation method to the output and produces a judgment or score.An output judged by a code-based, model-based or human evaluator.There are three common approaches:Code-based evaluators use deterministic checks. They suit anything with an exact value or clear rule, such as whether the output is valid JSON, or whether a required field is present.Model-based evaluators use another language model to assess an output against a rubric. This is often called LLM-as-a-judge, and it suits qualities that exact matching can’t capture, such as whether an answer is supported by its source.Human evaluators review outputs and judge qualities that may require domain knowledge or human interpretation.Each approach has its limitations, code-based checks are reliable for clearly measurable conditions but cannot easily assess every aspect of a natural-language response. Human evaluation provides direct judgment but can be expensive and difficult to scale. Model-based evaluation scales better, but the judge can introduce biases, including preferences for longer answers, certain response positions, or outputs similar to what it would produce itself.Research by Zheng et al., Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena, examines these limitations. In practice, model-based evaluators should be tested against human judgements on a representative set of outputs before their scores are treated as reliable.5. Scoring criteria: What makes an output good?Scoring criteria define the qualities an evaluation measures. They translate the task’s expectations into specific requirements that an evaluator can assess.The right criteria depend on the type of system being evaluated. For retrieval-augmented generation (RAG), relevant measures include context precision, context recall, faithfulness and answer relevance. For classification tasks, accuracy, precision, recall and F1 score may be more appropriate. Agent evaluations may examine whether the agent completes a task, selects the correct tools and executes actions properly.Scoring criteria for RAG, classification and agent systems, with binary or scaled scores.It is also useful to distinguish between a scoring criterion and a metric. A criterion describes what matters, such as whether an answer is supported by its source material. A metric provides a way to measure that quality.Evaluations can use binary scores, where an output passes or fails, or scaled scores that measure performance across several levels. The choice depends on what is being assessed and how much detail is needed from the result.Frameworks such as Ragas provide metrics for evaluating RAG systems, while other evaluation tools support different tasks and system types.6. Thresholds: What counts as acceptable?A threshold defines the minimum performance an AI system must achieve to pass an evaluation. It gives meaning to the scores produced by the evaluator and scoring criteria.A system might achieve a high average score while still failing on an important requirement. For this reason, not every criterion should necessarily have the same threshold. The acceptable level of performance depends on the task and the consequences of getting it wrong.In high-stakes settings, some failures should be treated as hard failures rather than averaged into an overall score. For example, exposing private information or fabricating critical facts may be unacceptable even if the system performs well on other measures.Thresholds also need to account for the size and coverage of the evaluation dataset. A high score on a small number of test cases does not establish that a system will perform consistently across a wider range of inputs. Results should be interpreted alongside the number and variety of cases tested.Bars showing one criterion passing, one failing, and a private data leak as a hard failure.Once thresholds are defined, teams can use them to compare different versions of a system and decide whether a change has improved performance, introduced regressions, or failed to meet the required standard.How the Six Components Work TogetherThe task says what the system should do. The dataset provides the inputs, while its test cases define the individual checks. The evaluator assesses the outputs against the scoring criteria, and thresholds determine whether the results meet the required standard.The five components run in an evaluation harness, then results lead to investigation and a rerun.In practice, an evaluation harness automates this. It runs every test case, captures outputs and traces, applies the evaluators and records the results, so you can inspect failures, compare versions and repeat the process whenever the model, prompt, retrieval setup or application logic changes.Evaluations can also happen at different stages.Offline evals run a fixed dataset before deployment, giving controlled comparisons between versions.Online evals examine behaviour in production, using sampled interactions, user feedback or other monitoring signals. They reveal problems no prepared dataset anticipatedBoth are useful because offline evaluations provide controlled comparisons, while online evaluations help reveal issues that may not appear in a prepared dataset.The results should lead to further investigation, not just a pass or fail decision. When an evaluation identifies a weakness, teams need to understand what caused it, improve the relevant part of the system or evaluation, and run the tests again.ConclusionAn AI eval is more than a score attached to a model’s output. It is a structured process built around a defined task, a representative dataset, individual test cases, an evaluator, scoring criteria and thresholds.Understanding these components helps teams build evaluations that measure the behaviour they actually care about. It also makes results easier to interpret, compare and use when improving an AI system.The Anatomy of an AI Eval was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.