A Practical Guide to LLM Evaluation: Building a Reproducible Benchmark Instead of Choosing by Gut Feeling
Choosing between top large language models based on screenshots and personal preference does not hold up in engineering. This article explains how to run a reproducible model evaluation: designing a layered evaluation set sampled from real traffic, controlling variables such as temperature and context limits, combining automated metrics with a blind human scorecard, normalizing cost and latency, and turning the results into a regression baseline and a selection checklist. It also covers reusable prompt templates and common pitfalls that invalidate comparisons.
1. Why “Choosing a Model by Feel” Fails in Engineering
In real projects, model selection discussions often degrade into a few social media screenshots plus personal preference. The problem is that model output is stochastic: a single session cannot separate a genuine capability gap from sampling variance. On top of that, different products ship different default parameters, context windows, and billing models, so a direct comparison is a race run under unequal conditions.
A more reliable approach is to treat selection as a reproducible experiment: fix the inputs, fix the constraints, fix the scoring rubric, sample multiple times, and look at the distribution rather than individual examples.
A rigorous comparison usually has six steps: define the business scenario and acceptance criteria, build a layered evaluation set, standardize call parameters and prompts, define automated metrics and a human scorecard, control cost and elapsed time, and produce a regression baseline. Skip any one of them and the conclusion is easy to distort.
2. Evaluation Set Design: Make Samples Represent Real Traffic
Do not draw conclusions from ten hand-written questions that “feel hard.” Sample from real request logs and stratify by task type, for example: extraction and structured output, long-document summarization, multi-turn tool calling, code generation and repair, math and logical reasoning, cross-language translation, and refusal plus safety boundaries. Then split each layer by difficulty so you cover both high-frequency and long-tail cases.
Example evaluation set structure (YAML sketch)- task: structured_extractionweight: 0.25cases: 120checks: [schema_valid, field_f1]- task: long_doc_summaryweight: 0.20cases: 80checks: [rouge, fact_consistency, citation_coverage]- task: tool_callingweight: 0.20cases: 100checks: [plan_valid, arg_schema_ok, task_success]- task: code_fixweight: 0.20cases: 100checks: [unit_tests_pass, lint_pass]- task: safety_refusalweight: 0.15cases: 60checks: [policy_hit, over_refusal]
Sample size has to balance statistical significance against budget. As a rule of thumb, at least 50 cases per layer and at least 300 overall are needed to push noise into an acceptable range; sample each case 3 to 5 times and record the mean and variance.
3. Variable Control: Remove Unfair Comparisons Up Front
Standardize temperature, maximum output length, system prompt, tool descriptions, and timeouts. For scenarios that support structured output, require every model to return the same JSON Schema. Truncate context at the same upper limit so no side “sees more.” When billing models differ, normalize with “total cost per thousand successful tasks” and “P95 latency” instead of comparing unit prices alone.
# Pseudocode: a unified evaluation harnessdef run_eval(model_client, cases, k=3):rows = []for c in cases:for _ in range(k):out = model_client.call(messages=c.messages,temperature=0.0,max_tokens=c.max_tokens,response_schema=c.schema,timeout=30,)rows.append(score(c, out)) # returns a dict of metricsreturn aggregate(rows) # mean, variance, failure rate
4. Metrics: Automated Scores as the Base, a Human Scorecard as the Tiebreaker
Automated metrics provide scale; human scoring provides business fit. For structured tasks, look at field-level F1 and schema validity. For summarization, look at factual consistency (whether conclusions appear that are absent from the source) and citation coverage. For tool calling, look at plan validity and task success rate. For code, look at unit test pass rate and static checks. For safety, look at policy hit rate and over-refusal rate.
A human scorecard scored from 1 to 5 should cover correctness, completeness, executability, clarity of expression, and style consistency. To reduce subjective bias, use blind review, randomized order, two independent raters, and spot checks on inter-rater agreement.
| Dimension | Weight | Description |
|---|---|---|
| Correctness | 0.35 | Whether conclusions and facts hold |
| Completeness | 0.20 | Whether constraints and edge cases are covered |
| Executability | 0.20 | Whether code or steps can be applied directly |
| Clarity | 0.15 | Structure, terminology, readability |
| Consistency | 0.10 | Whether the given style and format are followed |
5. Prompt Template: A Reusable Evaluation Baseline
You are a senior engineer. Answer using only the given material; do not introduce outside assumptions.Your output must be valid JSON with the fields: answer, evidence[], risks[].If the material is insufficient, set answer to null and describe the gap in risks.Material: <<<CONTEXT>>>Question: <<<QUESTION>>>
Pair it with three constraints: state the conclusion before the evidence; declare uncertainty explicitly; and tag every citation with the source snippet number. This decouples “writing style” from “correctness” and makes scoring more stable.
6. Cost, Latency, and Stability
Break cost into four parts: input, output, retries, and sunk cost of failures. Break latency into time to first token and total completion time. Measure stability by error rate, number of rate-limit hits, and timeout ratio. In engineering, a “quality-cost” curve is commonly used to find the inflection point: below it, quality gains outweigh the added cost; past it, more budget buys only marginal improvement.
7. Putting Conclusions to Work: Scorecard and Selection Checklist
Combine automated metrics and human scores with weights, then output a radar chart and a set of failure cases. The selection checklist should include task success rate, P95 latency, cost per thousand successful tasks, over-refusal rate, structured output validity rate, and regression pass rate. If the business demands high stability, a “primary model plus fallback model” routing strategy works well: split traffic by task type and set degradation thresholds.
In related practice at Baidu AI Cloud, a common approach is to bring the evaluation set and scorecard into continuous integration, and to pair them with logging services, monitoring and alerting, and a container platform for canary releases and regression testing. Model capabilities are then treated as general categories, such as text generation, structured extraction, vector retrieval, and intelligent coding tools, avoiding lock-in to a single implementation.
8. Common Pitfalls
First, looking only at the average and ignoring variance. Second, using development-environment data instead of real traffic. Third, inconsistent prompts, so an apparent “model difference” is really a “prompt difference.” Fourth, ignoring over-refusal on the safety dimension. Fifth, treating a one-off evaluation as the finish line and having no regression baseline. Avoid these and a model comparison actually carries decision value.
