LLM Version Evaluation and Selection: A Practical Guide
This article explains how to evaluate and select new large language model (LLM) versions using a repeatable methodology rather than leaderboard rankings alone. It covers task requirement breakdown, offline evaluation set construction, scoring function design, statistical comparison, cost and latency accounting, canary release, rollback planning, and a final decision checklist. Readers will learn how to compare candidate and existing model versions against real business workloads and make upgrade decisions supported by quality, cost, latency, and statistical evidence.
1. Why New Version Evaluation Needs a Methodology
Large language models iterate quickly. Each release typically comes with leaderboard rankings, capability descriptions, and demos. This information is useful, but it is mostly based on general scenarios and may not cover a team’s actual business workload. If engineering teams decide whether to upgrade based only on leaderboards, two common problems arise: the new version regresses in critical scenarios, or overall costs increase without a corresponding gain in benefits.
Evaluation should therefore start from business requirements and use the same methodology to compare candidate versions with the current version.
2. Break Down Task Requirements
Before evaluation begins, clarify three things.
- Task type: classification, information extraction, summarization, code generation, multi-turn dialogue, tool calling, and so on. Different tasks have different sensitivity to reasoning depth, context length, and output format.
- Quality floor: which errors are unacceptable, such as missing required fields, factual errors, or unauthorized calls. The quality floor must be translated into automatically detectable rules.
- Constraints: latency ceiling, cost per call, concurrency, and data compliance requirements.
The table below shows example metrics for a ticket classification scenario. The values are illustrative only; actual values must be determined by the business owners.
| Dimension | Metric | Example target |
|---|---|---|
| Accuracy | Macro-average F1 per class | Not lower than 0.90 |
| Latency | P95 response time | Not higher than 2 seconds |
| Cost | Cost per 1,000 successful calls | Not higher than 1.2× the current solution |
| Format | Valid structured output rate | Not lower than 99.5% |
3. Build an Offline Evaluation Set
The evaluation set is the foundation of the entire assessment. Follow these principles.
- Samples should come from de-identified real traffic and cover both high-frequency and long-tail scenarios.
- Keep at least several hundred samples for each task type, with gold answers or scoring rubrics.
- Strictly isolate training and tuning data from evaluation data. Otherwise, a candidate version may score artificially high because it has seen similar samples.
- Regularly add new samples to prevent the evaluation set from being repeatedly targeted and losing its discriminative power.
Below is a generic evaluation execution framework. Here, client is a model invocation interface wrapped by the team itself and does not depend on any specific vendor.
import jsonfrom dataclasses import dataclass@dataclassclass EvalCase:prompt: strexpected: strdef load_cases(path: str) -> list[EvalCase]:cases = []with open(path, encoding="utf-8") as f:for line in f:item = json.loads(line)cases.append(EvalCase(item["prompt"], item["expected"]))return casesdef run_eval(client, cases, model_name, checker):passed = 0for case in cases:output = client.generate(model=model_name, prompt=case.prompt)if checker(output, case.expected):passed += 1return passed / len(cases)
4. Design Scoring Functions
Scoring functions determine whether evaluation results are trustworthy. There are four common approaches.
- Exact match: suitable for classification, enums, and fixed-format outputs; simple and stable to judge.
- Rule validation: checks format, field completeness, numeric ranges, and so on; suitable for structured outputs.
- Model-as-judge: uses another model to score against a rubric; suitable for open-ended text. However, the judge model has its own biases, so it must be calibrated with human-labeled samples and the agreement rate between the two must be reported.
- Human spot checks: sample reviews for areas that automatic scoring cannot cover; typically a certain proportion of samples is drawn from each batch.
The following example shows a combination of rule validation and exact match.
import jsondef format_ok(output: str) -> bool:try:obj = json.loads(output)except json.JSONDecodeError:return Falsereturn isinstance(obj, dict) and "label" in objdef label_match(output: str, expected: str) -> bool:if not format_ok(output):return Falsereturn json.loads(output)["label"] == expected
Here, format errors are counted directly as failures so that format problems are not masked.
5. Comparison Methods and Statistical Significance
A fair comparison requires the following conditions.
- The candidate and current versions use the same prompts, decoding parameters, and evaluation samples.
- For outputs with randomness, run each sample multiple times and use the average or majority result.
- Report confidence intervals, not just point estimates.
When the evaluation sample size is limited, small score differences may be only random fluctuation. You can use bootstrap resampling thousands of times to calculate the confidence interval of the score difference. If the interval includes zero, you should not conclude that the new version is better.
6. Cost and Latency Accounting
The unit price per call does not directly represent usage cost. Success rate, retry count, and output length all change the final cost. A more practical metric is cost per successful task:
Cost per successful task = cost per call ÷ task success rate
For example, a plan with a cost of CNY 1 per call and a success rate of 0.7 has a cost per successful task of about CNY 1.43. Another plan with a cost of CNY 1.2 per call and a success rate of 0.95 has a cost per successful task of about CNY 1.26. The plan with the lower unit price is actually more expensive, and this only becomes clear after converting by success rate.
def cost_per_success(unit_cost: float, success_rate: float) -> float:if not 0 < success_rate <= 1:raise ValueError("success_rate must be in (0, 1]")return unit_cost / success_rate
Latency also needs to be examined by percentile. Average latency easily hides long-tail requests, so P50, P95, and P99 should be reported together.
7. Canary Release and Rollback
After offline evaluation passes, the candidate still needs to be validated on real traffic. The recommended process is as follows.
- Shadow traffic: send some requests to both the old and new versions at the same time, return only the old version’s results, and record the new version’s outputs for offline comparison.
- Small-percentage canary: for example, switch 5% of traffic first and monitor business metrics, error rate, and latency.
- Gradual rollout: after metrics stabilize, expand the percentage in stages, with clear stop conditions for each stage.
- Fast rollback: switch versions through feature flags or a configuration center without relying on redeployment.
Prompts and model versions should both be included in version management so that every online result can be traced back to a specific configuration.
8. Decision Checklist
Before making a replacement decision, confirm the following questions one by one.
- Does the evaluation set come from real business traffic and is it isolated from tuning data?
- Do quality, latency, and cost all meet the predefined targets?
- Do the confidence intervals support the conclusion rather than indicating noise?
- Is the agreement rate between automatic scoring and human review at an acceptable level?
- Is the cost per successful task lower than that of the current solution?
- Is there a canary plan and an executable rollback plan?
Only when all these questions have clear answers is the replacement worth pursuing. The evaluation methodology itself should also evolve continuously as the business changes so that it remains reliable over time.
