How to Evaluate and Select Large Language Models: A Practical Four-Dimensional Framework

    A production-ready model evaluation should go beyond accuracy. This guide presents a reproducible framework covering accuracy, latency, token usage, and cost, with domain-level benchmark design, statistical significance checks, agent and tool-calling tests, version regression analysis, and practical guidance for model routing and automated evaluation pipelines.

    1. The Real Problem: Choosing the Right Model, Not the Strongest One

    With budgets under pressure, the objective of model selection has changed. The traditional approach was “prioritize capability and manage cost afterward.” The practical objective today is to select the model with the best latency and cost among candidates that meet the minimum business accuracy requirement.

    This means an evaluation must produce four types of conclusions:

    • Can it be used? Accuracy
    • Is it fast enough? Latency
    • How expensive is it? Token usage and cost
    • Did the model regress after an upgrade? Version comparison

    An evaluation report that measures accuracy alone is rarely useful for production engineering. A highly accurate model that takes nearly 100 seconds per request cannot support an interactive online workflow. A model with acceptable accuracy but several thousand tokens per request can quickly exceed the budget as traffic grows.

    The first step in evaluation design is therefore to break “capability” into measurable engineering metrics.

    2. Defining the Four Dimensions

    Accuracy

    Accuracy is calculated as:

    1. correct answers / valid cases

    The word valid is critical. Timeouts, rate limits, invalid response formats, and samples blocked by safety policies should be excluded from the denominator and reported separately as failure rates. Otherwise, infrastructure or integration failures may be incorrectly treated as model capability deficiencies.

    Latency

    Latency should be reported using three distinct measures. Mixing them is one of the most common sources of misleading evaluation results:

    • Time to first token (TTFT): Determines perceived responsiveness in interactive scenarios.
    • End-to-end latency: Determines timeout and request-chain configuration.
    • Throughput (tokens/s): Determines actual waiting time for long outputs.

    Reporting only “average latency” can hide long-tail behavior. At a minimum, evaluations should include P50, P90, and P99 latency. Long-tail latency is what usually triggers timeouts and circuit breakers in production.

    Token Usage

    Token usage should be separated into:

    • Input tokens
    • Output tokens
    • Reasoning tokens for reasoning-oriented models

    Cached tokens should be measured separately. Otherwise, cost attribution may be inaccurate.

    Per-Call and Per-1,000-Call Cost

    Use a consistent formula to compare models with different pricing structures:

    1. cost_per_call = (in_tokens/1e6)*price_in + (out_tokens/1e6)*price_out
    2. cost_per_1k = cost_per_call * 1000

    If the output price remains unchanged while input token usage decreases, the cost per 1,000 calls will decrease accordingly. This type of efficiency improvement can reduce unit business costs more effectively than a simple price reduction.

    3. Evaluation Sets: Domain Splits Matter More Than the Overall Score

    A single aggregate score provides limited information. In practice, benchmark sets should be divided by business domain, such as:

    • Law and public administration
    • Education
    • Finance
    • Healthcare and mental health
    • Reasoning and mathematical computation
    • Language understanding and instruction following
    • Agents and tool calling

    Each domain should ideally contain at least several hundred cases. A total dataset in the tens of thousands is generally needed for a one- or two-percentage-point difference to have meaningful statistical significance.

    Domain-level segmentation helps expose structural regressions. For example, a model’s overall score may increase by two percentage points and its ranking may improve significantly, while its performance in one domain falls by two or three percentage points. These outcomes can occur at the same time.

    If domain-level results are hidden by the aggregate score, important model-selection risks may be missed.

    For a domain with sample size n, the significance of an accuracy difference Δ between two versions can be approximately assessed with a two-proportion test. When:

    1. Δ < approximately 2√(p(1-p)/n)

    the result should generally not be described as an improvement.

    4. Execution Framework: Making Evaluations Reproducible

    An evaluation script must address more than API invocation. It must ensure fairness and observability.

    1. # Pseudocode: shared evaluation execution skeleton
    2. async def run_one(case, client, cfg):
    3. t0 = time.perf_counter()
    4. try:
    5. resp = await asyncio.wait_for(
    6. client.chat(model=cfg.model,
    7. messages=case.prompt,
    8. temperature=cfg.temperature, # fixed, usually 0
    9. max_tokens=cfg.max_tokens),
    10. timeout=cfg.timeout)
    11. except (TimeoutError, RateLimitError) as e:
    12. return Record(case.id, ok=False, err=type(e).__name__)
    13. ttft = resp.first_token_at - t0
    14. total = time.perf_counter() - t0
    15. return Record(case.id, ok=True, ttft=ttft, total=total,
    16. in_tok=resp.usage.prompt_tokens,
    17. out_tok=resp.usage.completion_tokens,
    18. reasoning_tok=resp.usage.get("reasoning_tokens", 0),
    19. answer=resp.text, cost=price(resp.usage))

    The following variables must remain fixed across candidates and versions:

    • Temperature and sampling parameters
    • Maximum output length
    • System prompt
    • Context-injection strategy
    • Retry count
    • Concurrency

    The following data should be recorded for every case:

    • Raw model output
    • Token usage
    • Latency
    • Error type

    Store raw outputs in object storage, metadata in a logging service, and metrics in monitoring and alerting systems. This makes per-case diff analysis possible after a model or prompt update.

    Concurrency can significantly affect latency measurements. Cross-version comparisons must therefore use the same concurrency level. A separate single-concurrency baseline should also be measured.

    5. Agents and Tool Calling Require a Separate Evaluation Track

    Tool-calling capability cannot be measured adequately with ordinary question-answering accuracy. It should be evaluated using dedicated cases in three categories:

    1. Single-tool selection accuracy: Given a set of candidate tools, does the model select the only correct tool?
    2. Multi-step task completion rate: Does the model reach the target end state within the permitted number of turns?
    3. Parameter validity: Can the generated structured parameters pass schema validation?

    The evaluation should also introduce:

    • Average interaction turns
    • A composite score based on task success rate and turn efficiency

    A model may improve on question-answering tasks while regressing on tool calling. This can happen when a longer reasoning chain causes tool-selection drift. Such trade-offs must be made explicit during model selection rather than being hidden by an aggregate score.

    Long-context capability should also be evaluated separately. For example, when the supported context expands from roughly one hundred thousand to two hundred thousand tokens, use “needle in a haystack” retrieval tasks together with multi-hop reasoning tasks. Measure the effective context length, not only the advertised context window.

    6. Interpreting Results: Turn Trade-Offs into Decisions

    A complete evaluation report should contain four categories of conclusions:

    • Capability: Overall and domain-level changes, with statistically significant improvements clearly identified.
    • Performance: P50, P90, and P99 latency, together with throughput and whether the results meet the request-chain timeout budget.
    • Cost: Cost per 1,000 calls and a monthly budget projection based on the estimated daily request volume.
    • Risk: Domain-level regressions, failure rates, long-tail latency, and whether domain-specific model routing is required.

    In production, domain-based routing is often a more reliable approach. High-value and difficult requests can be sent to a more capable candidate, while frequent and simpler requests can use a lower-cost model. Routing can be implemented with rules or a small classifier.

    This approach helps preserve accuracy in critical scenarios while reducing the overall cost per business request.

    7. Common Mistakes

    • Replacing domain-level evaluation with an overall ranking
    • Comparing latency data collected at different concurrency levels
    • Including timeouts and rate limits in the accuracy denominator
    • Ignoring the measurement differences between reasoning tokens and cached tokens
    • Running only one evaluation pass and mistaking random variation for a trend
    • Using the advertised context window as a substitute for effective context length
    • Using an evaluation set that does not reflect the real business distribution, resulting in offline gains with no visible online improvement

    8. Implementation Recommendations

    Turn evaluation into a pipeline rather than a one-off script:

    • Version the benchmark set
    • Version the evaluation configuration
    • Version the results
    • Trigger regression tests automatically after every model or prompt change
    • Connect metric dashboards to monitoring and alerting
    • Block releases when regression exceeds the defined threshold

    Cloud environments can provide the general infrastructure required for this workflow:

    • Object storage for benchmark samples and raw outputs
    • Message queues for smoothing task bursts
    • Container platforms for concurrent load testing
    • Logging and monitoring services for observability and alerts

    Baidu AI Cloud provides corresponding capabilities in these general infrastructure categories, which can be selected according to a team’s existing technology stack.

    The conclusion is straightforward: the core advantage in model selection is not knowing which model is the strongest. It is having a reliable measurement framework of your own.

    When accuracy, latency, token usage, and cost can all be measured consistently and reproducibly, budget constraints become not merely limitations, but engineering parameters that can be optimized.