Overview
An evaluation harness is the repeatable runner for LLM tests: it loads cases from a golden-set, calls the system under test, scores each output, aggregates metrics, and reports them. Run it in CI on every prompt, model, or retrieval change so a regression fails a check instead of reaching users.
A minimal harness has five parts: a dataset loader, a runner (with retries and rate limiting), a scorer, an aggregator (mean score, per-category breakdown, pass@k), and a reporter. Define the success metric before looking at results. Start with exact match or regex scoring for classification and extraction, which is cheap and deterministic; add llm-as-judge scoring for open-ended output, checked against a human-graded sample.
Existing options include promptfoo (open source; OpenAI announced its acquisition in March 2026), EleutherAI’s lm-evaluation-harness, Braintrust, and LangSmith.
Example
def run_eval(cases, template):
scores = []
for case in cases:
out = client.messages.create(
model="claude-sonnet-5-5", max_tokens=256,
messages=[{"role": "user", "content": template.format(**case)}],
).content[0].text.strip()
scores.append(out == case["expected"])
return {"accuracy": sum(scores) / len(scores), "n": len(scores)}Related
- golden-set: the test data the harness runs; its quality limits the eval’s validity.
- llm-as-judge: scoring for open-ended output.
- evaluation: metric choice and evaluation strategy.
- prompt-evals: regression testing for prompts.
- hallucination: a metric commonly measured in a harness.