Understanding LLM Evaluation: Metrics, Cost, and Stability
Learn how to read LLM leaderboard scores correctly, the five dimensions for evaluating general language capability, engineering practices for agentic coding benchmarks, how to calculate per-task cost, and how to handle timeouts and retries. This guide helps teams build their own model selection benchmarks based on real business data rather than public rankings alone.
How to Read Leaderboard Scores
A leaderboard ranking is an aggregate of scores across multiple sub-tasks. Different evaluation sets vary in question distribution, scoring rules, and difficulty weighting, so two models with similar total scores may perform very differently in a specific business scenario. Many benchmarks also define a tolerance range—for example, scores within one point of each other are treated as a tie. This means rankings carry measurement error and should be treated as a coarse filtering signal, not a final verdict.
Version updates also change conclusions. Between two runs of the same model, the question set, scoring scripts, or inference parameters may have been adjusted. Before comparing two results, confirm the evaluation date, question set version, output length limit, and whether reasoning mode was enabled. When these conditions differ, any apparent improvement is not comparable.
Five Dimensions for Evaluating General Language Capability
1. Complex Reasoning
Complex reasoning focuses on the correctness of multi-step logical chains. Common question types include mathematical proofs, constraint solving, and cross-paragraph information integration. Evaluation should distinguish between a correct final answer and a correct derivation process. Looking only at the answer can hide lucky guesses, especially in multiple-choice and true/false questions.
2. Software Engineering
Engineering capability shows up in code generation, bug fixing, and API comprehension—closer to day-to-day development work than algorithm puzzles. Evaluation requires runnable test cases rather than a human reviewer deciding the code “looks right.”
3. Hallucination Control
Hallucination means the model confidently outputs information that does not exist or cannot be verified. Evaluation typically includes factual Q&A, recognition of fabricated entities, and whether the model proactively states uncertainty when information is insufficient. For business systems, the ability to decline to answer is sometimes more valuable than answering more, because a confident wrong answer propagates directly into downstream decisions.
4. Long-Context and Multimodal Understanding
Long-context capability tests whether a model can locate key information in lengthy material and stay consistent throughout. Multimodal capability covers image understanding, UI element recognition, and action planning. When evaluating these, fix the input material and record the distribution of input lengths, so length differences between samples do not distort conclusions.
5. Agentic Planning
Agentic planning refers to the ability to break a goal into subtasks, select tools, and adjust steps based on feedback. Failures often occur in intermediate steps, such as incorrect tool parameters or repeated looping calls. Evaluation should therefore log the full sequence of calls at each step, not just the final result.
Engineering Practices for Agentic Coding Evaluation
The main challenge in agentic coding benchmarks is environment stability. Running the same task on different machines or dependency versions produces interfering results. Recommended practices:
- Use containers to pin the runtime environment and dependency versions;
- Set a uniform execution time limit and resource cap for each task;
- Use test case pass rates as the judging criterion instead of manual scoring;
- Count timeouts, crashes, and truncated output separately from wrong answers.
Timeouts need their own count. A timed-out task neither passed nor produced a valid conclusion. Treating timeouts as failures versus excluding them from the denominator yields two very different scores. Whichever convention you adopt, state it explicitly in the report.
Below is a simplified statistics example: timed-out tasks are excluded from the pass count but included in the timeout rate and cost:
from dataclasses import dataclass@dataclassclass EvalRecord:completed: bool # Whether the task finished within the time limitpassed: bool # Whether all test cases passedinput_tokens: intoutput_tokens: intdef summarize(records, price_in, price_out):"""price_in / price_out are per-million-token prices; fill in according to the provider's published pricing rules."""if not records:raise ValueError("Empty evaluation records")n = len(records)timeout_rate = sum(not r.completed for r in records) / npass_rate = sum(r.completed and r.passed for r in records) / ntotal_cost = sum(r.input_tokens * price_in / 1_000_000+ r.output_tokens * price_out / 1_000_000for r in records)return {"pass_rate": round(pass_rate, 4),"timeout_rate": round(timeout_rate, 4),"cost_per_task": round(total_cost / n, 6),}
How to Calculate Per-Task Cost
LLM services typically bill input and output tokens separately. Per-task cost can be estimated as:
Per-task cost = (input tokens × input unit price + output tokens × output unit price) ÷ unit conversion factor
Three points require attention in practice.
First, the intermediate reasoning content generated by reasoning models is usually billed as output tokens. Ignoring it underestimates actual cost.
Second, retries consume tokens repeatedly. The cost of reruns after timeouts should be included in the total, otherwise per-task cost is systematically understated.
Third, cost comparisons are only meaningful under the same task set and the same output limit. Pricing should follow the provider’s latest published rules; this article does not cover specific prices.
Timeout and Stability Management
Timeout issues in evaluation also exist in production. Common mitigations include setting request timeouts, applying exponential backoff retries for failed requests, limiting concurrency, and switching to a fallback option when the primary model is unavailable.
The following example shows retry logic with backoff:
import randomimport timedef call_with_retry(fn, max_retries=3, base_delay=1.0):"""For idempotent requests only. Confirm that retrying a non-idempotent operation will not cause duplicate side effects."""for attempt in range(max_retries + 1):try:return fn()except TimeoutError:if attempt == max_retries:raisedelay = base_delay * (2 ** attempt) + random.uniform(0, 0.5)time.sleep(delay)
Note that retries only apply to idempotent requests. For operations that write to a database, send messages, or trigger deployments, you must confirm that retrying will not cause duplicate side effects.
Building Your Own Selection Benchmark
Public leaderboards are good for narrowing down candidates; the final decision should rely on your own data. Recommended steps:
- Extract 200 to 500 representative samples from real business scenarios, covering both common cases and edge cases;
- Define automatically verifiable criteria for each sample, such as test cases, field validation, or reference answer comparison;
- Fix the evaluation scripts, runtime environment, and parameter configuration so results are reproducible;
- Record quality metrics, timeout rate, latency, and per-task cost together—do not rely on a single dimension;
- Run each candidate model multiple times and track the mean and variance, so a single lucky or unlucky run does not mislead you;
- Re-run the benchmark regularly after model or business requirement changes to keep it in sync with reality.
Common Pitfalls
Pitfall one: treating leaderboard rank as business performance. Benchmark questions and business data usually have different distributions; a rank only reflects performance on a specific task set.
Pitfall two: looking at a single run. LLM outputs are stochastic, and the randomness of one run can exceed the real gap between models.
Pitfall three: ignoring unfinished tasks. If timed-out or truncated samples are quietly dropped, the average score looks better while actual usability is worse.
Pitfall four: looking only at unit price. A low-priced option with verbose outputs and frequent retries may not have lower per-task cost. Evaluate total per-task cost together with the cost per successful task.
Practical Recommendations
For model selection, follow the order of “coarse filtering, hands-on testing, then rollout.” In the filtering stage, use public leaderboards to narrow the candidate list. In the testing stage, evaluate with your own samples while recording quality, timeouts, and cost. In the rollout stage, keep a fallback plan and continuously monitor timeout rates and sampled checks for hallucinations. This approach leverages public information while grounding decisions in your team’s own data.
