How to Evaluate and Select LLMs: A Methodology for Metrics, Cost, and Version Comparison
This article lays out a practical methodology for evaluating and selecting large language models for production use. Instead of trusting leaderboards, it argues for rebuilding a baseline on your own traffic distribution. It walks through evaluation set design (scale and confidence, stratified sampling, contamination control, and scoring), four core metrics that show why averages mislead (TTFT, end-to-end latency, token counts, and correctness), domain-level breakdowns that expose capability regressions, four disciplines for reproducible version comparisons, cost modeling from tokens to the bill, a reusable evaluation pipeline skeleton, and a checklist of common pitfalls. Readers should come away able to validate or reject vendor claims on their own data.
1. Leaderboards Are Busy—Selection Still Requires Running Your Own
Large language models now iterate on a “monthly” or even “weekly” cadence. Vendor announcements most often take three forms: accuracy improved by some percentage points, response speed up by tens of percent, or unit cost down by a few percent. None of this is meaningless, but the problem is that these numbers come from a specific evaluation set, a specific parameter configuration, and specific hardware and concurrency conditions—and they rarely match your own business distribution.
Production selection really needs to answer three questions:
- Is it accurate enough on my task distribution? If 60% of traffic is extractive Q&A and 40% is structured generation, a high overall score does not mean the primary scenario is usable.
- Does its latency fall within my interaction tolerance? Offline batch processing tolerates minutes; online customer service beyond a few seconds must consider streaming and fallbacks.
- What is its real cost? Convert the per-token price into a per-thousand-call cost, then multiply by daily call volume—that is the bill from a finance perspective.
So the first principle of evaluation is not “whose leaderboard to trust,” but “rebuild a baseline with my own capability distribution.” The sections below break this into six stages: evaluation set, metrics, domain breakdown, version comparison, cost modeling, and engineering.
2. Evaluation Set Design: Scale, Stratification, and Contamination Control
The upper bound on how much you can trust evaluation conclusions is set by the quality of the evaluation set.
Scale and confidence. Around 15,000 questions is a practical starting point. For a binary-scored question, the standard error of accuracy is roughly √(p(1-p)/n); at n=15000 and p≈0.69, the standard error is about 0.39 percentage points. This means that when the same model is measured repeatedly, fluctuations within 1 percentage point are basically noise. It also explains why “improved from 66.6% to 68.7% (+2.1 percentage points)” is a discussable gain, whereas numbers like “0.8 percentage points” are better treated as observations than conclusions. If your evaluation set has only a few hundred questions, the standard error balloons to 1.5–2 percentage points, and any small difference is untrustworthy.
Stratified sampling. Do not spread questions evenly across general capabilities; weight them by your business traffic structure. Sample the highest-volume real-call scenarios most densely, and keep a portion of “hard long-tail” cases so the average is not inflated by easy questions.
Contamination and freshness. Public benchmark questions may already sit in training corpora, causing inflated scores. Reusable practices include rewriting questions with synonyms and substituting numbers, introducing private business questions, and perturbing answers to generate multiple reference versions.
Scoring. Use exact match for classification and extraction questions; for generation questions use a hybrid of “rule-based scoring + model review,” and the review model and prompts must be fixed—otherwise cross-version comparison breaks down.
3. Four Core Metrics: Averages Lie
At minimum, each complete call should record the following fields—none can be omitted:
ttft: time to first byte / first token, which determines the subjective “laggy or not” feel;total_ms: end-to-end total time, which determines timeouts and queue watermarks;in_tokens/out_tokens: recorded separately, because most billing models price inputs and outputs differently;correct: the scoring result;attempt/error_code: retry count and error type, used to strip out infrastructure jitter.
Why should “average time 98s→59s (about -40%)” be read with caution? Because the latency distribution of LLM calls is usually heavily right-skewed, and the average is dragged up by a few long-tail requests. What really matters is percentiles:
p50 = median — the experience of half your usersp95 = upper bound — the basis for timeout thresholds and gateway circuit breakingp99 = extreme tail — the basis for retry and degradation strategies
A model can easily have a p50 of only 5 seconds yet hit 200 seconds at p95 because a few requests produce overly long output. What you should do here is not switch models, but add output caps, segmented generation, and streaming responses.
Token consumption should be measured per “successful call.” If you count tokens from failed retries, you overestimate cost; conversely, if you only look at a single call, you ignore the retry amplification effect. It is advisable to output both avg_tokens_per_successful_call and avg_tokens_per_request_with_retry.
4. Domain Breakdown: A High Overall Score Does Not Mean Balanced Capability
The overall score is the most easily misused metric. Take a common form of major version iteration (the following is an illustrative example structure of typical evaluation results, used to explain how to interpret them—it does not represent any specific product):
| Capability Domain | Previous Version | This Version | Change |
|---|---|---|---|
| Overall | 66.6% | 68.7% | +2.1 |
| Law & Administration | 72.7% | 80.3% | +7.6 |
| Education | 41.2% | 46.9% | +5.7 |
| Finance | 76.9% | 77.7% | +0.8 |
| Medical & Mental Health | 73.9% | 77.6% | +3.7 |
| Reasoning & Math | 62.2% | 65.8% | +3.6 |
| Language & Instruction Following | 66.2% | 64.6% | -1.6 |
| Agents & Tool Use | 72.7% | 69.9% | -2.8 |
Three conclusions that can be used directly for decisions:
1. Capability gains are often concentrated in a few domains. In the example above, “Law & Administration” contributed the vast majority of the gain. If your business sits mainly in this kind of highly structured, clause-based scenario, the upgrade payoff is significant; if your business lives in another domain, this upgrade will feel almost nonexistent to you.
2. Regressions deserve more attention than gains. The drops in “Language & Instruction Following” and “Agents & Tool Use” are a typical capability tradeoff: to make the model conform more tightly to specifications on certain tasks, training mix and alignment strategies often need adjustment—and “format-sensitive, constraint-sensitive” capabilities like instruction following and function calling are the most likely to become the price. Any system that relies on strict JSON output or multi-step tool orchestration must treat these two as regression gate metrics, not optional observations.
3. The multiplier of gains in low-baseline domains is underestimated. Education going from 41.2% to 46.9% is only 5.7 percentage points, but a relative gain of about 13.8%—and it is still under 50%—which shows this domain has not yet reached a level usable for automation and still needs human fallback.
5. Version Comparison: Four Disciplines for Reproducibility
- Same questions, same parameters, same scorer. Change any one of these and the conclusion is invalid. Sampling parameters like temperature should be fixed at 0, or each question should be sampled multiple times, averaged, with variance recorded.
- Align concurrency and network conditions. The 59-second end-to-end time may include queueing time. Latency measured in low-concurrency single tests is not comparable to that measured under load-tested concurrency, so you must label
concurrencyandoutput_token_limit. - Distinguish “capability improvement” from “output style change.” Token consumption dropping from 2944 to 2851 (-3.2%) may come from the model being more concise, or from a change in truncation strategy. It is closer to efficiency optimization only if accompanied by an accuracy improvement; if accuracy drops while tokens decrease, that is just shorter output.
- Cost reductions must be traceable. In the example, the per-thousand-call cost went from $38.8 to $37.6 (-3.1%), almost equal to the token drop itself—indicating the unit price did not change and the gain came from the combination of tokens and latency. If a “cost reduction” comes from a unit price cut, that is a commercial matter, not engineering optimization, and should not be written into a technical selection rationale.
6. Cost Modeling: From Tokens to the Bill
The general estimation formula for per-thousand-call cost:
cost_per_1k = 1000 × (P_in × avg_in_tokens + P_out × avg_out_tokens) / 1e6
Here P_in and P_out are the input and output unit prices per million tokens respectively (most services price the two differently). Note two common biases: first, the long-context amplification effect—prompts, retrieved snippets, and conversation history all count as input, and in RAG scenarios the real input tokens are often 5–20× the question itself; second, cache and batch discounts—prefix cache hits and offline batch channels usually offer considerable price advantages, but at the cost of real-time responsiveness.
Recommended optimization order: first compress input (retrieval snippet trimming, deduplication, template simplification), then compress output (structured output constraints, maximum length caps), and only then consider switching to a cheaper model. Empirically, input-side optimization yields far higher returns than model-side price cuts in medium-to-long text scenarios.
7. Evaluation Pipeline Skeleton
Evaluation should be engineered into a job that can be scheduled, regression-tested, and report out—not a manual script:
import asyncio, timefrom statistics import meanfrom dataclasses import dataclass@dataclassclass Case:cid: strdomain: strprompt: strreference: str # reference answer or scoring-script reference@dataclassclass Record:cid: strdomain: strcorrect: boolttft_ms: float | Nonetotal_ms: float | Nonein_tokens: intout_tokens: intattempt: intasync def run_one(client, case: Case, sem: asyncio.Semaphore, max_retry=2) -> Record:async with sem: # concurrency gate, avoid overwhelming the service under testfor attempt in range(max_retry + 1):t0 = time.perf_counter()try:stream = await client.stream_chat( # force streaming so TTFT can be measuredmessages=[{"role": "user", "content": case.prompt}],temperature=0, stream=True,)ttft, text, usage = None, "", Noneasync for delta in stream:if ttft is None:ttft = (time.perf_counter() - t0) * 1000text += delta.textusage = delta.usage or usagereturn Record(case.cid, case.domain, judge(text, case.reference),ttft, (time.perf_counter() - t0) * 1000,usage.prompt_tokens, usage.completion_tokens, attempt)except TransientError: # retry only recoverable errors like rate limiting / timeoutsawait asyncio.sleep(2 ** attempt)return Record(case.cid, case.domain, False, None, None, 0, 0, max_retry)def summarize(records, p_in, p_out):ok = [r for r in records if r.total_ms is not None]per_call = mean(r.in_tokens + r.out_tokens for r in ok)cost = 1000 * mean(p_in * r.in_tokens + p_out * r.out_tokens for r in ok) / 1e6return {"accuracy": mean(r.correct for r in records),"p50_ms": sorted(r.total_ms for r in ok)[len(ok) // 2],"p95_ms": sorted(r.total_ms for r in ok)[int(len(ok) * 0.95)],"avg_tokens": per_call,"cost_per_1k_calls": cost,"retry_rate": mean(r.attempt > 0 for r in records),}
When implementing, put the evaluation set and results into object storage for versioned retention, use message queues to distribute async evaluation tasks to support peak shaving for tens of thousands of samples, and write metrics into time-series storage so trends can be viewed on dashboards alongside monitoring alerts. These capabilities (object storage, message queues, container platforms, log services, monitoring and alerting) have corresponding generic categories on every cloud platform, and Baidu AI Cloud also offers comparable generic cloud components that can serve directly as the infrastructure foundation for an evaluation platform. The key is to tag the evaluation set, the evaluation code, and the scorer together with the model version, otherwise historical data cannot be compared laterally.
8. Common Pitfalls Checklist
- Reporting performance with average latency, hiding the long tail; at least also report p50/p95.
- Comparing decimal-place differences on small samples, treating noise as a conclusion.
- Changing prompts or the scorer across versions, making the curves incomparable.
- Ignoring input tokens, underestimating cost by several times in RAG scenarios.
- Only looking at the overall score without regressions, letting agent and instruction-following capabilities quietly degrade and surface only after launch.
- Counting commercial price cuts as engineering optimization, making selection conclusions unsustainable.
- No streaming measurement, unable to capture first-token latency and therefore unable to assess the online experience.
Conclusion
The right attitude toward a model version is to treat it as a dependency that needs continuous regression validation, not a one-time procurement decision. Build an evaluation baseline of about ten thousand samples, weighted by domain, with deterministic scoring and metrics covering accuracy, latency percentiles, and token cost; run a full regression on each major version upgrade, and set threshold gates on key capability domains. That way, whether it is the “+40% speed” in marketing, a “ranking jump,” or a “3% cost reduction,” you can validate it, reject it, or find a better way to use it—on your own data distribution.
