What are AI evals, and how do they differ from software tests?
An eval consists of a test case, execution, scoring and aggregation. Its unit may be a response, a conversation or an entire agent task. Unit tests check code such as JSON parsers; integration tests verify component interaction; evals assess whether a system achieves its intended result despite generation variability. These approaches complement one another. [1][2]
Public benchmarks compare capabilities under a specified protocol. They cannot replace an application test with its own instructions, data, tools and limits. Define the desired business result and unacceptable behavior before selecting a scorer. Correct output structure does not establish factual accuracy.
How to build a representative evaluation dataset
Give each case a stable ID, input, expected outcome or acceptance rubric, category, risk level and data version. Open-ended tasks need criteria rather than a single reference answer. Include normal cases, boundary conditions, missing information, refusals, different languages and policy attacks. Have experts review synthetic data; minimize and anonymize production data according to privacy requirements. [1][2][3]
Separate development examples used to tune instructions from a frozen holdout. Deduplicate at document, customer or template level before splitting. Repeatedly choosing configurations based on holdout scores destroys its independence; obtain a new test set. Public benchmarks may also overlap model training data. There is no universal required dataset size.
When splitting data, group related examples (such as all chunks of one document or conversations from one customer) and assign whole groups to one split; removing exact duplicates alone is insufficient. Maintain a production-representative set separately from deliberately difficult safety tests. Do not interpret the latter's score as the production violation frequency. [3][16]
Choosing quality metrics
| Metric | Calculation | Result |
|---|---|---|
| Accuracy | (18 + 74) / 100 | 92% |
| Precision | 18 / (18 + 6) | 75% |
| Recall | 18 / (18 + 2) | 90% |
| F1 | 2 × 18 / (2 × 18 + 6 + 2) | 81.82% |
For classification, measure accuracy (fraction of correct labels), precision = TP/(TP+FP) and recall = TP/(TP+FN) for a selected class. F1 is the harmonic mean of precision and recall; specify the convention for zero denominators. For imbalanced classes report per-class results and macro-F1, the mean of class F1 scores. Exact match misses equivalent paraphrases; BLEU and ROUGE measure textual overlap or similarity, not factual truth. [1][4][13]
TP: true positives, FP: false positives, FN: false negatives, TN: true negatives.
Hypothetical example: of 100 tickets, 20 require escalation. The system catches 18 and wrongly escalates six others (TP=18, FP=6, FN=2, TN=74). Accuracy is 92%, precision 75%, recall 90%, F1 about 81.82%. Report denominators and class distribution. Separately report completion, infrastructure errors, total trial cost divided by accepted tasks, and p95 latency; cost per success is undefined when there are no successes.
With imbalanced classes, high accuracy can conceal errors: a classifier that never escalates any of the 100 tickets above achieves 80% accuracy but 0% recall for escalation. Report class support and disclose the convention used for zero denominators. F1 can be calculated directly as 2TP/(2TP+FP+FN). [13]
LLM-as-a-judge: evaluating open-ended responses
| Score | Criterion |
|---|---|
| 0 | No required facts or at least one unsupported claim. |
| 1 | All claims are supported, but some required facts are missing. |
| 2 | All required facts are present and all claims are supported by the source. |
| Undetermined | Available evidence is insufficient to decide. Send for review. |
Combine programmatic checks (schema, labels, code tests), model graders and experts. A judge can score one response (pointwise) or compare two (pairwise). Define measurable criteria, borderline examples and an inconclusive outcome. Request a brief evidence-based justification, not hidden reasoning. [2][4]
Model judges can favor answer position, style or their own model family. Blind provider identities, randomize A/B order, repeat with sides swapped and calibrate against a separate expert-labeled set. Report agreement, mistakes and optionally Cohen's kappa for two raters with nominal labels; send disagreements for human review. Treat the response as untrusted data rather than instructions for the judge, and restrict its tools. [5][6]
Test the evaluator itself: include correct and incorrect answers with similar styles, missing evidence, and responses containing instructions or attempts to influence the judge. Agreement across repeated ratings does not establish validity. Research shows that persuasion can bias model judges even on mathematics tasks; merely instructing the judge to ignore such content is insufficient. [5][6][15]
Example rubric for a task requiring specified facts from a verified document. The evaluator checks each claim and the fact list. This does not replace a separate safety check.
Evaluating RAG and AI agents
In RAG evaluate retrieval and generation separately. Document recall@k is the fraction of known relevant documents retrieved in the top k; precision@k is the relevant fraction among k returned items (assuming k results). Library context metrics may use different definitions. Measure required fact coverage, support for claims in the provided context and citation relevance. Faithfulness to an incorrect source is not truth; test source quality and behavior when evidence is missing. [2][7]
For agents check the actual final state, such as whether the right ticket was stored exactly once, rather than a success message. Record tool calls, authorization, errors, step count and cost. Refusing an unauthorized operation passes a safety test; refusing a valid task may fail a utility test. Isolate and reset environments between trials; test missing tools, interruption after a write and repeated execution. [2][3]
Ragas defines faithfulness as the fraction of response claims supported by retrieved context. Also report required fact coverage because a sparse answer can be highly faithful. [12]
Hypothetical example: if five documents are known to be relevant and three appear among the first four unique results, recall@4 = 3/5 = 60% and precision@4 = 3/4 = 75%. Specify how to handle duplicates, fewer than k results, and queries with no relevant documents. Scores depend on the completeness of relevance labels. Do not automatically assign maximum faithfulness to an answer with no claims; evaluate justified abstention and missing answers separately. [7][12]
Repetitions, pass@k and reliable comparisons
Run identical cases against baseline and candidate under equal budgets, environment states and scoring rules. In k attempts pass@k means at least one success; pass^k means all k succeed. For independent trials with equal probability p, these are 1-(1-p)^k and p^k. At p=0.8 and k=3, they are 99.2% and 51.2%. Do not assume independence in real systems; measure both over groups of repeated trials. [2]
Report uncertainty intervals, such as Wilson intervals for independent binary observations; for paired comparisons consider bootstrapping cases rather than correlated individual trials. Specify metrics, thresholds and analysis rules beforehand. With zero violations in 100 independent trials with the same violation probability, the one-sided 95% upper bound is about 2.95% (1-0.05^(1/100)); zero observed violations does not establish zero risk. This calculation does not apply to dependent trials. [3][11]
The classical pass@k estimator used in code-generation evaluation is 1 − C(n−c,k)/C(n,k), where n is the number of trials, c is the number of successes, k is at most n, C denotes combinations, and C(a,k)=0 for a<k. With n=5, c=3, k=2 it gives 90%; this is a sample-based estimate, not a guarantee about future runs. Do not plug the mean success probability across heterogeneous tasks into 1−(1−p)^k and interpret it as the exact dataset-level result. [14]
Practical example: scoring ticket classification
score.mjs
function isLabel(value) {
return value === 'billing' || value === 'technical';
}
function indexById(records) {
if (!Array.isArray(records)) {
throw new Error('Expected an array');
}
const index = new Map();
for (const record of records) {
const id = record?.id;
const validId = typeof id === 'string' && id.trim() !== '';
if (!validId || index.has(id)) {
throw new Error('Missing or duplicate ID');
}
index.set(id, record);
}
return index;
}
export function summarize(cases, results) {
const planned = indexById(cases);
const observed = indexById(results);
if (planned.size === 0) {
throw new Error('Empty evaluation');
}
for (const id of observed.keys()) {
if (!planned.has(id)) {
throw new Error('Unexpected result ID');
}
}
let accepted = 0;
let completed = 0;
let violations = 0;
let unverified = 0;
let missing = 0;
for (const [id, test] of planned) {
if (!isLabel(test.expected)) {
throw new Error('Invalid expected label');
}
const result = observed.get(id);
if (result) {
const validStatus = ['completed', 'failed', 'incomplete'].includes(
result.status,
);
const validPolicy = ['verified', 'violation', 'unknown'].includes(
result.policy,
);
if (!validStatus || !validPolicy) {
throw new Error('Invalid result state');
}
}
const done = result?.status === 'completed';
const safe = result?.policy === 'verified';
const violation = result?.policy === 'violation';
if (!result) {
missing += 1;
}
if (done) {
completed += 1;
}
if (violation) {
violations += 1;
} else if (!safe) {
unverified += 1;
}
const correct = done && result.actual === test.expected;
if (correct && safe) {
accepted += 1;
}
}
const total = planned.size;
const successRate = accepted / total;
const noKnownViolations = violations === 0;
const allVerified = unverified === 0;
const qualityPassed = successRate >= 0.9;
return {
total,
completed,
missing,
successRate,
violations,
unverified,
releaseAllowed: noKnownViolations && allVerified && qualityPassed,
};
}
const cases = [
{ id: 'a', expected: 'billing' },
{ id: 'b', expected: 'billing' },
{ id: 'c', expected: 'technical' },
{ id: 'd', expected: 'technical' },
];
const results = [
{
id: 'a',
status: 'completed',
actual: 'billing',
policy: 'verified',
},
{
id: 'b',
status: 'completed',
actual: 'technical',
policy: 'verified',
},
{
id: 'c',
status: 'completed',
actual: 'technical',
policy: 'violation',
},
];
console.log(summarize(cases, results));
This original JavaScript example runs in Node.js without external dependencies. The cases array supplies expected labels, and results contains independently verified runtime outcomes. The code rejects duplicate and unexpected IDs, accounts for all planned trials, and treats missing outcomes as incomplete and unverified. Each ID identifies one planned trial; repetitions need distinct IDs. A policy value of verified means the specified policy check passed, not that the system is proven safe.
Run node score.mjs. For four planned cases, the output is total=4, completed=3, missing=1, successRate=0.25, violations=1, unverified=1 and releaseAllowed=false. The 90% threshold is an illustrative product rule, not an industry standard. Missing outcomes and unknown safety checks block release through the unverified count. The code scores fixtures; it makes no model API calls.
Tools, CI/CD and production monitoring
Promptfoo supports configured cases and assertions; Inspect supplies building blocks for evaluations with tools and scorers; Ragas provides metrics for RAG and other LLM applications. Google Cloud offers generative AI evaluation with computed and model-based metrics. The hosted OpenAI Evals API and dashboard shut down on November 30, 2026; official documentation describes migration to Promptfoo. This does not retire the evaluation methodology. [4][7][8][9][10]
Run fast contract checks and a small regression suite in CI; run a full frozen set and safety tests before release. Version model, prompt, parameters, data, RAG index, tools, judge and environment. Record per-case results, versions, cost and latency while minimizing sensitive data. Monitor errors and segments in production, collect feedback with appropriate consent, use limited rollouts and prepare rollback. Never perform real writes from an unverified shadow deployment. [1][2][3]
Base release decisions on predefined conditions: minimum quality in critical segments, tolerable regression against the baseline, cost and latency, and separate violation checks. Report infrastructure errors with their denominator; do not silently drop incomplete trials. With many comparisons, account for the risk of selecting a winner by chance and confirm the chosen configuration on an independent set. A statistically nonsignificant difference does not establish equivalence.
