LLM Evaluation in Practice: A Six-Dimension Framework for Model Selection and Cost Optimization

    A practical guide to building a reliable LLM evaluation system. Learn a six-dimension framework covering logical reasoning, long-context handling, code generation, agent tasks, hallucination control, and multimodal understanding—along with the metrics that distinguish one from another (test_pass_rate vs. pass@1 vs. pass@k vs. best@k). The article also provides cost formulas that account for retries and task completion rates, a scorecard template with three calibration methods, and a step-by-step enterprise rollout process. By the end, you can move from "feels good" to explainable, reproducible, data-driven model selection.

    Introduction: How to Evaluate LLMs Without Getting Burned

    Base models now iterate faster than ever, and vendors ship several tiers at once—high capability, low latency, low cost. When new models are released this densely, evaluation based on subjective impressions alone easily produces skewed conclusions: strong reasoning does not guarantee good coding, good coding does not guarantee a stable agent, and a high capability ceiling does not guarantee cost-effective selection.

    A genuinely usable evaluation system has to satisfy three conditions: reproducible, comparable, and quantified in cost and risk. Building on the original framework, this article refines the metric definitions, fills in the scoring criteria, cost formulas, safety boundaries, and rollout process. The goal is to help teams move from “seems fine” to “explained by data.”

    Part 1: The Six-Dimension Framework—How to Measure Each Dimension and Decide What Passes

    1. Logical Reasoning and Knowledge Application: Look at the Median, Not a One-Off Winner

    Logical reasoning evaluation should include multi-step reasoning problems, constraint problems, and knowledge-integration problems, with emphasis on consistency across long reasoning chains. For scoring, use difficulty stratification + median ranking rather than a simple average. Averages are easily inflated by extreme questions or one-off lucky performance.

    Suggested sample sizes:

    • Three tiers—easy, medium, hard—with at least 30 questions each, for a total of 90–150 questions;
    • In small-sample settings, median scores fluctuate heavily, so report the interquartile range or a bootstrap confidence interval alongside;
    • For the same question set, use a fixed random seed, fixed prompt templates, and fixed judging rules.

    Acceptance criterion: only when the median ranking stays consistent across two independent runs on the same question set, and the confidence intervals do not visibly flip, can the conclusion for this dimension be considered trustworthy.

    2. Long-Context Handling: Supporting a Length Is Not the Same as Using It Well

    Million-token windows are now a common capability among top-tier models, but evaluation cannot stop at “does it fit.” You must separately test position bias. Fix three task types:

    • Needle-in-a-haystack retrieval: insert key information into the front, middle, and back of a long document, and measure recall separately for each;
    • Cross-section integration: the answer requires stitching together information scattered across three or more places;
    • Long-dialogue coreference resolution: after many turns, refer back to an entity mentioned early on.

    Set position at five levels—0%, 25%, 50%, 75%, 100%—and randomize positions for the same question to avoid the model accidentally memorizing a fixed location. Turns can be set at three levels: 20, 50, and 100. If the key information is in the right position but the answer is missing or wrong, count it as a failure.

    Also define the truncation strategy in advance. For example: when the context exceeds the window, do you keep the head and tail and compress the middle, use a sliding window, or place a summary at a fixed position? Different strategies affect fairness, so they must be stated explicitly in the evaluation report.

    Conclusion: don’t look at average recall; look at the recall floor of the “worst position segment.”

    3. Code Generation: Distinguish test_pass_rate, pass@1, and pass@k

    Coding ability should be viewed on two levels: static quality (syntax checking, unit tests, engineering standards) and dynamic delivery (understanding requirements, editing across multiple files, self-testing, and delivering runnable artifacts).

    Here we must correct a common misconception. Many teams call the test-case pass rate “pass@1,” which is inaccurate. Distinguish the following metrics:

    • test_pass_rate: the proportion of passing test cases for a single problem, used to diagnose code quality—not called pass@1;
    • pass@1: task-level single-shot pass—the model generates once; if all tests pass, score 1, otherwise 0;
    • pass@k: task-level pass over k samples—generate k independent samples; if at least one sample passes all tests, the task scores 1;
    • best@k: the highest test pass rate among k samples, indicating the potential ceiling, but it must be explicitly labeled best@k and cannot pass itself off as pass@k.

    Here is a corrected metric example:

    1. from dataclasses import dataclass
    2. @dataclass
    3. class TestResult:
    4. """Return type of test_runner.run: passed is the number of passed
    5. test cases, total is the total number of test cases."""
    6. passed: int = 0
    7. total: int = 0
    8. @property
    9. def test_pass_rate(self) -> float:
    10. """Test case pass ratio, for diagnostics only, not called pass@1."""
    11. return self.passed / self.total if self.total else 0.0
    12. @property
    13. def all_passed(self) -> bool:
    14. """Task-level pass: all test cases pass."""
    15. return self.total > 0 and self.passed == self.total
    16. @dataclass
    17. class Task:
    18. prompt: str
    19. tests: list
    20. class TestRunner:
    21. """Should execute tests inside an isolated sandbox; any exception is
    22. counted as a failure and not propagated upward."""
    23. def run(self, code: str, tests: list) -> TestResult:
    24. ... # Actual implementation requires container isolation,
    25. # least privilege, no external network, and timeouts
    26. def evaluate_code_generation(model, tasks: list, test_runner: TestRunner, k: int = 5, base_seed: int = 0):
    27. if k < 1:
    28. raise ValueError("k must be greater than or equal to 1")
    29. rows = []
    30. for tid, task in enumerate(tasks):
    31. # k independent samples, fixed seed to guarantee reproducibility
    32. results = [
    33. test_runner.run(
    34. model.generate(task.prompt, n=1, seed=base_seed + i),
    35. task.tests
    36. )
    37. for i in range(k)
    38. ]
    39. # pass@1: take the first sample here, representing single-shot task-level pass
    40. pass_at_1 = float(results[0].all_passed)
    41. # pass@k: at least one task-level pass among k samples
    42. pass_at_k = float(any(r.all_passed for r in results))
    43. # best@k: highest test pass rate among k samples, not pass@k
    44. best_test_pass_rate_at_k = max(r.test_pass_rate for r in results)
    45. # average test pass rate, for diagnosing stability
    46. mean_test_pass_rate = sum(r.test_pass_rate for r in results) / k
    47. rows.append({
    48. "task_id": tid,
    49. "pass@1": pass_at_1,
    50. "pass@k": pass_at_k,
    51. "best@k": best_test_pass_rate_at_k,
    52. "mean_test_pass_rate": mean_test_pass_rate,
    53. })
    54. return aggregate(rows)
    55. def aggregate(rows: list) -> dict:
    56. if not rows:
    57. raise ValueError("Task set is empty")
    58. def median(xs):
    59. xs = sorted(xs)
    60. n = len(xs)
    61. if n % 2 == 1:
    62. return xs[n // 2]
    63. return (xs[n // 2 - 1] + xs[n // 2]) / 2
    64. return {
    65. "task_count": len(rows),
    66. "pass@1_median": median([r["pass@1"] for r in rows]),
    67. "pass@k_median": median([r["pass@k"] for r in rows]),
    68. "best@k_median": median([r["best@k"] for r in rows]),
    69. "pass@1_mean": sum(r["pass@1"] for r in rows) / len(rows),
    70. "rows": rows,
    71. }

    The key differences: pass@1 reflects the reliability of a single delivery, pass@k reflects model potential and the value of retries, and best@k reflects the payoff of selection. If pass@1 and pass@k diverge widely, the model relies more on retries and selection, and the engineering cost of production deployment may be higher.

    Safety preconditions must be in place: code under evaluation is untrusted input, so before execution you must ensure container isolation, least privilege, a non-root user, a read-only root filesystem, an emptied capability set, external network denied by default, pinned dependency versions, data desensitization, and per-run timeouts and resource limits. If any of these is missing, the test results should not be used as a basis for selection.

    4. Agent Tasks and Tool Calling: Completion Rate, Efficiency, and Adaptability

    An agent must plan autonomously, call tools, execute multiple steps, and collect results. Evaluate at least three things:

    • Task completion rate: the proportion of end-to-end deliveries that yield usable artifacts;
    • Delivery efficiency: number of steps, token consumption, elapsed time;
    • Task adaptability: whether the model is uneven across unseen task types.

    For agent evaluation, add a failure-type checklist:

    • Parameter-construction errors;
    • Tool permission failures;
    • Tool timeouts or unparseable returns;
    • Lost intermediate state;
    • Duplicate side effects from retries;
    • Cases requiring human takeover.

    Therefore, agent selection should not rest on a single-point capability score, but on “unit task cost under a given budget × completion rate × human-takeover rate.” Some models have a lower unit task cost on specific task sets under a given token budget, but this conclusion must state its applicable boundaries: task-set scope, budget ceiling, whether self-checking is enabled, concurrency scale, and retry strategy. On reasoning-heavy tasks, the advantage may reverse.

    5. Hallucination Control and Factual Consistency: Report Refusal, Self-Consistency, and Self-Check Cost Together

    Hallucination evaluation should be done from two angles:

    • Factuality: when facing unanswerable or out-of-scope questions, does the model honestly refuse or fabricate;
    • Self-consistency: across multiple turns or steps of reasoning, do earlier and later conclusions contradict each other.

    In engineering, adding a self-check step is often used to reduce hallucinations—for example, a code agent self-testing before delivery, or a UI agent doing a visual check before delivery. But self-checking is not free: it cannot catch every defect, and it significantly increases token consumption and task duration, potentially offsetting the efficiency advantage.

    Therefore, hallucination evaluation should record three sets of data:

    1. Hallucination rate and completion rate with self-checking off;
    2. Hallucination rate and completion rate with self-checking on;
    3. The cost increase introduced by self-checking.

    Conclusion: the hallucination rate, refusal accuracy, and the cost increase before and after self-checking must all be reported together.

    6. Multimodal Understanding: Being Overall Right Does Not Mean the Details Are Usable

    Multimodal evaluation should cover OCR accuracy, chart data interpretation, and image-text association Q&A. Often overlooked is the granularity of visual detail: the overall understanding may be correct, but local details can be wrong, and that error propagates to the final artifact.

    For detail-type questions, list error-type labels separately:

    • Character-level errors;
    • Numeric-level errors;
    • Layout-level errors;
    • Spatial-relation errors;
    • Color, icon, or control-state errors.

    This makes it easier to locate a model’s weaknesses and to judge whether human review is needed.

    Part 2: Balancing Cost and Performance—Get the Definitions Right

    Cost evaluation should be orthogonal to the quality dimensions. Quality looks at each dimension’s score; cost looks at price per million tokens, average consumption per unit task, retry overhead, and human-takeover cost.

    Use the following unified definitions:

    • Let r_retry be the number of additional retries, excluding the first call;
    • Let T = 1 + r_retry be the total number of call rounds;
    • Let input_tokens be the average input tokens per single task;
    • Let output_tokens be the average output tokens per single task;
    • Let p_in be the price per million input tokens;
    • Let p_out be the price per million output tokens;
    • Let c_cache be the input cache hit rate;
    • Let b_batch be the average cost discount from batch inference, which can apply to input or output separately.

    The base cost of a single task can be written as:

    1. Base cost per task =
    2. T × [(1 - c_cache) × input_tokens × p_in
    3. + output_tokens × p_out × (1 - b_batch)]
    4. / 1,000,000
    5. + orchestration overhead per task

    If what you have is the total number of call rounds T rather than additional retries, use T directly and don’t multiply by the first call again, to avoid double counting.

    The total cost for a thousand tasks is:

    1. Total cost per 1,000 tasks =
    2. 1000 × Base cost per task
    3. + orchestration, logging, monitoring, and extra retry overhead

    The cost per usable artifact is:

    1. Cost per usable artifact =
    2. Total cost per 1,000 tasks / (1000 × task completion rate)

    Using completion rate as the denominator is what reflects rework cost. For logic-heavy, low-value-density tasks, a high-priced model’s inference cost may far exceed the quality gain; for agent batch-execution scenarios, a mid- or low-cost model may be better due to advantages in delivery efficiency and total cost.

    Concurrency queuing and caching do not directly change token prices, but they affect unit-time cost, P95 latency, and peak cost. So also record:

    • Average latency;
    • P95/P99 latency;
    • Cache hit rate;
    • Batch-processing discount;
    • Scaling cost under peak concurrency.

    Part 3: A Scorecard Template and Threshold Calibration

    The scorecard below can serve as an initial template; weights can be adjusted per business:

    Dimension Core Metric Data Definition Weight Example Threshold
    Logical reasoning Difficulty-stratified median Fixed question set + fixed seed 20% ≥ 0.70
    Long context Worst-position-segment recall Front/middle/back segment statistics 15% ≥ 0.80
    Code pass@1 median, pass@k median Task-level pass inside a sandbox 25% pass@1 ≥ 0.60
    Agent Completion rate, unit task cost Given budget and task set 20% Completion rate ≥ 0.85
    Hallucination Hallucination rate, refusal accuracy Human spot-check + automated judging 10% Hallucination rate ≤ 0.05
    Multimodal OCR and detail error rate Detail errors classified by type 10% Detail error rate ≤ 0.10

    Note: the thresholds above are only examples and must be calibrated per business. Three recommended calibration methods:

    1. Historical-task calibration: establish a baseline from the historical performance of tasks already in production; a new model should not fall below the acceptable range of the historical model;
    2. Human-annotation calibration: have domain experts sample-annotate high-quality outputs and work backward to the minimum usable threshold;
    3. Acceptance-target calibration: work backward from final business metrics—such as customer complaint rate, human rework rate, delivery success rate—and map them to model metrics.

    If the sample size is small, don’t report a single score alone. Report the median, the confidence interval, and failure cases together. When the sample is too small, the median fluctuates easily, and the conclusion can be skewed by a chance question.

    Part 4: Enterprise Rollout—Follow This Order

    Recommended order for LLM evaluation:

    1. Define business constraints: first set the quality floor, cost ceiling, latency requirement, and acceptable failure rate;
    2. Build and freeze the question set: give the set a version number, a hash, or a Git commit ID, and record every change;
    3. Establish a baseline: set thresholds using historical models, human annotations, or acceptance targets;
    4. Fix the evaluation environment: record the image digest, dependency lock file, random seed, model version, and prompt templates;
    5. Small-scale validation: run a small evaluation first, then do human spot-checks and artifact review;
    6. Production monitoring: continuously track hallucination rate, completion rate, unit cost, P95 latency, and human-takeover rate;
    7. Change review: any change to the model, prompt, question set, or evaluation environment should trigger a rerun of the benchmark set.

    Freezing question-set versions and recording changes is critical. Without version freezing, “fixed question set, fixed seed” does not hold; without an image digest, environment differences can make results non-reproducible.

    Part 5: FAQ

    What are common LLM evaluation mistakes?

    Common mistakes include: looking only at the total score and not the weaknesses; passing off the test-case pass rate as pass@1; not accounting for additional retries in cost; not freezing the fixed question set; ignoring long-context position bias; and running code without sandbox isolation.

    How do I choose a model?

    First look at the task type, then at completion rate, worst-case performance, cost per usable artifact, and human-takeover cost. Don’t just pick the top of the leaderboard—pick the model with the lowest risk, controllable cost, and stable delivery in the target scenario.

    How do I get started quickly?

    First pick 20–50 high-value real tasks, freeze the question set and seeds, set up the sandbox and logging, complete one small-scale evaluation, then use human spot-checks to calibrate thresholds. Get the loop working first, then expand the sample size and dimensions.

    Conclusion: From Leaderboard Ranking to Scenario Fit

    There is no one-size-fits-all optimal answer in LLM evaluation—only a rational choice that fits the scenario. Rather than chasing a single leaderboard’s number one, build a multi-dimensional framework covering reasoning, coding, agents, hallucinations, multimodality, and cost, and drive selection with reproducible data. When you can clearly state “which tier of model to use for a certain type of task, at what cost, with what risk,” model capability is truly converted into deliverable business value.