LLM Selection Methodology: Evaluation Criteria and Cost Governance

    This article presents a practical methodology for selecting large language models under real production constraints rather than relying on a single public leaderboard. It covers task profiling, the different questions asked by capability, usage, and spend rankings, a reusable evaluation framework for capability, stability, and cost, cost per successful request, and a controlled rollout with shadow traffic, canaries, routing, and fallbacks. It also summarizes common pitfalls in model selection and cost governance.

    1. “Best” Is a False Premise: Measurement Choices Determine the Conclusion

    In engineering, “Which model is best?” is a question without enough constraints. The answer is determined not by the model list itself but by three things: the evaluation task distribution, metric definitions, and the cost basis. The same set of models can have different relative rankings across four task types—code completion, long-document summarization, structured extraction, and multi-turn tool calling—and weighting their scores differently can change the winner.

    The first step in model selection is therefore not reading leaderboards. It is measuring the actual distribution of requests in your own business and producing a task profile. Without this profile, any ranking is simply someone else’s conclusion.

    2. Why the Top Names on Three Types of Leaderboards Rarely Overlap

    Public statistics in the industry can generally be grouped into three categories, each answering a different question:

    • Capability leaderboards: answer “Who performs better on a fixed problem set?” They are heavily affected by benchmark contamination, prompt sensitivity, and the scoring method (human review, model-as-judge, or unit-test pass rate).
    • Usage-volume leaderboards: answer “Who is used most?” They mix price, default configuration, ecosystem inertia, free quotas, SDK usability, and other factors. Their correlation with capability is weak.
    • Spend leaderboards: answer “Where is the money going?” They equal usage volume × token consumption per call × unit price. Long contexts, reasoning-heavy requests, and multi-turn retries can significantly amplify per-request cost.

    The lack of overlap is a structural consequence, not a data anomaly. A model can lead in usage because of a low unit price and default integration, yet produce higher total spend because requests have long contexts and high retry rates. Conversely, a model with a higher unit price can keep total spend under control if it has a high first-pass rate and few retries. Using a single leaderboard to make a decision replaces all constraints with one dimension.

    3. Building a Reusable Evaluation Framework

    3.1 Task Stratification and Sample Construction

    Sample from production logs and stratify by task type. Keep a sufficient number of real samples in each stratum, use them after de-identification, and add a set of hard samples: very long contexts, ambiguous instructions, requests that require multi-step tool calls, and requests whose outputs must strictly conform to a schema. These hard samples may account for a small share of traffic, but they are often the most discriminative.

    3.2 Metric Design: Capability, Stability, and Cost

    • Capability: task-level pass rate (unit tests, schema validation, human scoring), not a vague “good” or “bad” judgment.
    • Stability: result variance across repeated samples of the same input, timeout rate, format-violation rate, and refusal rate.
    • Cost: the comprehensive cost per successful request. Note that the denominator is “successful” requests, not “initiated” requests.

    3.3 Example Weighted Score

    1. from dataclasses import dataclass
    2. @dataclass
    3. class TaskWeight:
    4. name: str
    5. share: float # share of production traffic for this task
    6. weight: float # weight of metrics within this task
    7. def score(candidate, tasks) -> float:
    8. total = 0.0
    9. for t in tasks:
    10. m = candidate.metrics[t.name]
    11. # Combine capability, stability, and cost; inverse cost means lower is better
    12. s = (0.5 * m.pass_rate
    13. + 0.2 * m.stability
    14. + 0.3 * (1.0 / (1.0 + m.cost_per_success)))
    15. total += t.share * t.weight * s
    16. return total

    The key point is that share must come from real traffic, and cost_per_success must use successful requests as the denominator. If either is guessed, the conclusion loses its meaning.

    4. Cost Metrics Must Be Calculated per Successful Request

    The cost per request can be approximated as:

    1. cost_per_success = (input_tokens * p_in + output_tokens * p_out) * attempts / success_rate

    Here, attempts is the average number of attempts or retries, and success_rate is the first-pass success rate. This formula explains a common counterintuitive result: a model with a lower unit price can end up with a higher total cost because it needs more retries to produce a usable result.

    Common engineering methods for reducing cost (these are general industry practices; specific billing rules are subject to the official documentation of the cloud provider being used) include:

    • Stabilizing prompt prefixes and using context-caching capabilities to reduce billing for repeated input.
    • Sending batch or asynchronous jobs through an offline queue, separating non-real-time requests from real-time requests.
    • Constraining output length and schema to reduce wasted tokens.
    • Using retrieval-augmented generation (RAG) instead of stuffing the entire corpus into the context, thereby controlling input size.

    When deploying on a cloud platform, a common setup combines object storage for corpora and samples, message queues for traffic peak shaving and asynchronous processing, a container platform to host the inference gateway, and logging plus monitoring and alerting for quality and cost observability.

    5. From Leaderboards to Production: Shadow Traffic, Routing, and Fallback

    A model-selection decision should not be a one-time replacement. It should be a gradual process that can be rolled back:

    1. Shadow traffic: The new model receives mirrored requests only and does not affect users. Compare pass rate and cost.
    2. Small-percentage canary: Ramp traffic by user or tenant, and monitor the success-rate, latency, and cost curves.
    3. Routing tiers: Send simple requests to low-cost models and escalate hard requests to higher-capability models, using rules or a small classifier.
    4. Fallback and degradation: Automatically switch to a backup model when the primary model times out or violates format requirements, preserving availability.

    Pseudocode for the routing layer:

    1. def route(req):
    2. if req.estimated_tokens < 2000 and req.task_type in SIMPLE:
    3. return cheap_model
    4. if req.task_type in HARD or req.retry_count > 0:
    5. return strong_model
    6. return default_model

    6. Common Pitfalls

    • Using public leaderboards instead of an in-house evaluation set, while ignoring differences in business distribution.
    • Comparing only unit price, not the cost per successful request.
    • Ignoring output-format compliance rate, causing downstream parsing failures to be misdiagnosed as model capability problems.
    • Switching all traffic at once, without canary releases or fallbacks.
    • Failing to govern prompts and context, and attributing all cost problems to model selection.

    7. Conclusion

    In engineering, a question such as “What are the three best models this year?” cannot have a unique answer. What can have a unique answer is: “Under my traffic distribution, quality threshold, and budget constraints, which combination is optimal?” When the evaluation set, cost metrics, and canary mechanism are made solid, the benefits of model iteration can be captured consistently instead of requiring a new bet with every version. If you need managed capabilities such as an inference gateway, logging, and monitoring, you can build them from general-purpose products offered by cloud platforms such as Baidu AI Cloud; consult the official documentation for specifications and billing.