LLM Selection Framework: Building an Evaluation System and Optimizing Inference Costs with Tiered Routing

    The hardest part of choosing a large language model is no longer finding one that works, but finding the one with the best cost-performance ratio for your own workload. This article argues that "which model is strongest" is the wrong question and offers a practical framework instead: a layered evaluation approach that combines an aggregate intelligence index, per-capability benchmarks, and scenario tests on real traffic; a guide to anonymous double-blind arena evaluation with the statistical traps to avoid (win-rate confidence intervals, position and length bias, and leaderboard-versus-business relevance); a cost model showing how parameter growth, output tokens, and cache hit rates flow through to your bill; and a tiered routing architecture that sends only flagship-worthy requests to flagship models. It closes with a deployment checklist.

    1. Why “Which Model Is the Strongest” Is the Wrong Question

    Over the past year, large language models have improved at a remarkable pace: open-weight models have reached the trillion-parameter scale, while closed-source flagship models keep topping benchmark after benchmark. For developers, the hard problem is no longer whether a usable model exists, but which model offers the best cost-performance ratio under your own workload distribution.

    Requests for guidance are usually phrased as “how do I evaluate a newly released model?” From an engineering standpoint, though, this question bundles three independent sub-questions:

    1. Horizontal positioning: Where does this model sit on the general-intelligence scale?
    2. Per-capability performance: How does it do on the dimensions I actually care about — long-context understanding, structured generation, data analysis, code generation, and so on?
    3. Engineering fit: Can its latency, throughput, concurrency quota, unit price, and stability handle my traffic?

    Selection based on the first question alone almost always fails in production. There are three reasons:

    • Benchmark contamination: Questions and answers from public evaluation sets easily leak into pretraining data, inflating scores and detaching them from your real distribution.
    • Score gaps fall within noise: Top models’ aggregate scores are often tightly clustered, and differences of a few points are frequently smaller than the confidence interval of a single evaluation run — not enough to support a “who’s stronger” conclusion.
    • Workload mismatch: Leaderboards measure average general capability, while real workloads concentrate on a handful of tasks; strength or weakness in long-tail capabilities barely affects the overall experience.

    The sensible approach, then, is to build a combined method — layered evaluation + scenario testing + cost accounting + scheduling strategy — rather than hunt for an absolute number one.

    2. Three Layers of Evaluation

    2.1 Aggregate Intelligence Index: A Horizontal Anchor

    The industry commonly weights and aggregates a large set of benchmarks (reasoning, math, code, knowledge QA, instruction following, multi-turn dialogue, and more) into a single “aggregate intelligence index.” Its value is to place a coordinate quickly: has the new model closed in on the frontier, or does it still trail by a clear generation gap?

    Two cautions when using this layer. First, the aggregation weights are subjective; different leaderboards weight the same raw scores differently, so rankings shift accordingly. Second, a high aggregate score does not mean good performance on your scenario — a model that leads on math benchmarks may not lead at generating frontend pages. The aggregate index is best for initial screening, narrowing a candidate pool from a dozen or so down to three or four.

    2.2 Per-Capability Performance: Ordering the Candidate Set

    What really decides selection is per-capability performance. On your candidate set, break evaluation down as follows:

    Capability dimension What to examine Typical evaluation method
    Long context & document understanding Effective context length, cross-paragraph reference, detail recall Needle-in-a-haystack, multi-document summarization and QA
    Content writing Structural completeness, tone consistency, factual consistency Human double-blind scoring + fact-checking
    Data analysis Table parsing, metric computation, chart-code correctness Executable verification, result comparison
    Structured output JSON validity rate, field-adherence rate, schema constraints Automated validators
    Code & frontend generation Runnability, visual fidelity, interaction completeness Sandbox execution + screenshot comparison + crowdsourced battles

    “Long context” in particular needs a clear distinction between the nominal window and the effective window. The nominal window is only an upper bound set by memory and positional encoding; actual performance depends on the attention implementation, the proportion of long-text data seen during training, and any retrieval-based compensation mechanisms. A reliable rule of thumb: place key information at the beginning, middle, and end of the context and test recall for each. If mid-context recall drops sharply, the effective window is smaller than the nominal value.

    2.3 Scenario Testing: Let Real Traffic Be the Final Judge

    Draw a stratified sample from your own historical data and construct a golden test set of 300–800 examples, covering three categories: high-frequency, long-tail, and adversarial. Score against an explicit rubric rather than a “does it feel good” impression — for example, split frontend generation into five items (structural completeness / style fidelity / responsiveness / interactivity / code readability), each scored 0–2. Once built, this set becomes a regression baseline for every model upgrade, preventing the “we swapped the model, quality dropped, and nobody noticed” failure.

    3. Anonymous Double-Blind Arena Evaluation: How It Works and Where the Statistical Traps Are

    Arena-style evaluation is one of the methods closest to real user experience today. The flow is simple: the same prompt goes to two anonymous models, a user picks which output is better without knowing the source, and the votes are used to compute relative rankings.

    3.1 Advantages

    • Eliminates brand priors: Anonymity removes the bias where “the big-name model wins by default.”
    • Realistic distribution: Prompts come from real users, with far broader coverage than curated benchmarks.
    • Fine-grained comparability: Pairwise comparison is more stable than absolute scoring; humans are more reliable at ranking two answers relative to each other than at assigning absolute scores.

    3.2 Ranking Algorithm

    The mainstream approach uses the Elo or Bradley-Terry model. Elo’s core idea: the winner “takes” points from the loser in proportion to the expected win rate.

    1. import math
    2. def expected_score(rating_a: float, rating_b: float) -> float:
    3. """Expected win rate of A against B; a 400-point gap corresponds to roughly a 10x win-rate ratio"""
    4. return 1.0 / (1.0 + 10 ** ((rating_b - rating_a) / 400.0))
    5. def update_elo(rating_a, rating_b, score_a, k=24):
    6. """score_a: 1 means A wins, 0.5 means a draw, 0 means A loses"""
    7. exp_a = expected_score(rating_a, rating_b)
    8. new_a = rating_a + k * (score_a - exp_a)
    9. new_b = rating_b + k * ((1.0 - score_a) - (1.0 - exp_a))
    10. return new_a, new_b

    The K factor controls how aggressively ratings update; use a larger value when samples are sparse to speed convergence.

    3.3 Three Traps You Must Watch For

    Trap 1: Looking only at average scores, ignoring win rates and confidence intervals. Average rank (Elo) and pairwise win rate are two views of the same thing. Win rate is more intuitive, but it must come with a confidence interval; otherwise a claim like “76% vs. 63%” is meaningless when the sample is small. The Wilson interval is more reliable than the normal approximation when n is small:

    1. def wilson_interval(wins: int, n: int, z: float = 1.96):
    2. """Returns the (lower, upper) bounds of the win rate. n is the total number of matches; z=1.96 corresponds to 95% confidence"""
    3. if n == 0:
    4. return 0.0, 1.0
    5. p = wins / n
    6. denom = 1 + z * z / n
    7. centre = p + z * z / (2 * n)
    8. margin = z * math.sqrt(p * (1 - p) / n + z * z / (4 * n * n))
    9. return (centre - margin) / denom, (centre + margin) / denom

    The bar is simple: if two models’ intervals overlap substantially, you cannot claim a real difference exists.

    Trap 2: Position bias and length bias. If a double-blind matchup always puts “A on the left, B on the right,” it introduces a position preference, so you need to randomize display order and correct for it statistically. Length bias is more insidious — human voters naturally favor longer, more formatted answers, which systematically inflates the ranking of verbose models. Mitigations include length-normalization cues in the UI and treating response length as a covariate in the statistics.

    Trap 3: Leaderboard-versus-business relevance. An arena’s prompt distribution is the union of all users — strong on generality, weak on vertical depth. If your business is code or frontend generation, you must look at the same-distribution sub-leaderboard: it is entirely possible for one model to rank top-five on the general leaderboard and first on the code leaderboard, because the two measure non-overlapping capabilities. Conversely, a model that tops a vertical sub-leaderboard only proves it has matched or exceeded the frontier in that vertical — it cannot be extrapolated to all tasks.

    This matters especially for judging domestic model alternatives: when a domestic model first overtakes an overseas frontier model on a given vertical sub-leaderboard, the correct conclusion is “the gap in that scenario has been closed,” not “it has achieved across-the-board superiority.” The former is a fact the evaluation data can support; the latter requires evidence across every dimension.

    4. Cost Modeling: How Rising Parameter Counts Flow Through to the Bill

    The capability gains from larger parameter counts show clear diminishing returns. Mixture-of-Experts (MoE) architectures decouple total parameters from actual compute per token via sparse activation, so “more parameters” does not necessarily mean “more expensive inference” — the two must be considered separately.

    Four things truly determine cost: input token price, output token price, cache hit rate, and average output length. In practice, the most commonly underestimated factor is the cost of output tokens — output prices are usually several times input prices, because the generation phase cannot be parallelized as fully. A task that outputs 2,000 tokens can cost more than a long-document task that consumes 20,000 input tokens.

    1. def estimate_cost(in_tokens: int, out_tokens: int,
    2. in_price: float, out_price: float,
    3. cache_hit_ratio: float = 0.0,
    4. cache_discount: float = 0.1) -> dict:
    5. """
    6. Price unit: currency units / million tokens.
    7. cache_hit_ratio: fraction of input tokens that hit the prompt cache.
    8. cache_discount: discount factor for cache hits (0.1 means billed at 10% of the price).
    9. """
    10. cached = in_tokens * cache_hit_ratio
    11. fresh = in_tokens - cached
    12. input_cost = (fresh * in_price + cached * in_price * cache_discount) / 1e6
    13. output_cost = out_tokens * out_price / 1e6
    14. return {
    15. "input_cost": round(input_cost, 6),
    16. "output_cost": round(output_cost, 6),
    17. "total": round(input_cost + output_cost, 6),
    18. }
    19. # Illustration only; prices must follow actual commercial quotes
    20. FLAGSHIP = (3.0, 15.0) # Flagship tier: (input price, output price)
    21. MIDTIER = (0.8, 2.4) # Mid tier
    22. LIGHT = (0.1, 0.4) # Light tier
    23. def compare(volume_per_day: int = 50_000,
    24. in_tok: int = 1_200, out_tok: int = 800) -> None:
    25. for name, (p_in, p_out) in [("Flagship", FLAGSHIP), ("Mid", MIDTIER), ("Light", LIGHT)]:
    26. per_call = estimate_cost(in_tok, out_tok, p_in, p_out)["total"]
    27. daily = per_call * volume_per_day
    28. print(f"{name} tier: ${per_call:.5f}/call | daily ${daily:.2f} | monthly ${daily*30:.2f}")

    Run this table and the selection discussion shifts from “which model is better” to “which portion of traffic deserves the expensive model” — the right starting point for an engineering decision. You also need to fold non-token costs into the accounting: the rise in time-to-first-token that long contexts bring, retry amplification, wasted consumption from failed requests, and queueing losses under quota limits.

    5. Tiered Routing: Let Flagship Models Do Only Flagship Work

    The natural conclusion of cost modeling: do not use the same tier of model for every request. A sound production architecture usually has three-tier routing.

    1. from typing import Literal
    2. Tier = Literal["light", "mid", "flagship"]
    3. SIMPLE_TASKS = {"classify", "extract", "rewrite", "translate", "tag"}
    4. HARD_TASKS = {"frontend_codegen", "complex_reasoning", "multi_doc_analysis"}
    5. def route(task: dict) -> Tier:
    6. """Static routing based on task type: first split by deterministic, decidable features"""
    7. kind = task["type"]
    8. if kind in SIMPLE_TASKS and task["max_out_tokens"] <= 800:
    9. return "light"
    10. if kind in HARD_TASKS or task["input_tokens"] > 60_000:
    11. return "flagship"
    12. return "mid"
    13. def cascade(task: dict, client, gate) -> tuple[str, Tier]:
    14. """
    15. Cascade strategy: start with the cheaper tier, then escalate if the quality gate fails.
    16. gate.check should return (passed, confidence), used to track escalation rates later.
    17. """
    18. plan = route(task)
    19. result = client.chat(plan, task["messages"])
    20. if plan == "flagship" or gate.check(task, result):
    21. return result, plan
    22. upgraded = client.chat("flagship", task["messages"])
    23. return upgraded, "flagship"

    Layer four optimization techniques on top of this structure and you can typically achieve a 30%–70% cost reduction without a perceptible loss in quality:

    1. Prompt caching: Put stable system prompts, tool definitions, and few-shot examples at the prefix; once the cache hits, this portion of input is billed at a discount.
    2. Context compression: For retrieval scenarios, rerank and deduplicate first, then feed the model; keeping useless tokens out is more effective than switching to a cheaper model.
    3. Confidence-based routing: Have the model emit structured results along with a self-assessment score or verification fields (JSON validity rate, schema pass, unit tests passing); escalate if the bar is not met.
    4. Async and batching: Send offline tasks through the batch channel, moving peak load off the interactive path.

    The accompanying observability is just as important: log each call’s model tier, input/output token counts, latency, quality-gate result, and escalation reason to a unified logging service, then track trends in per-call cost, escalation rate, and gate pass rate with monitoring and alerts. An abnormal rise in escalation rate usually means the light-tier prompt needs tuning, not that the flagship model has gotten stronger. If you deploy this pipeline in the cloud, you can generally reuse common building blocks — model serving, object storage, message queues, logging, and monitoring/alerting. On Baidu AI Cloud, for example, evaluation datasets and call logs can land in object storage and the logging service respectively, while evaluation jobs run periodically as batch jobs, forming a continuously running regression loop.

    6. Deployment Checklist

    • Candidate models: no more than 4, from aggregate-index initial screening
    • Golden test set ≥ 300 examples, from stratified sampling of real traffic
    • Each dimension has an automatically judgeable rubric, not a subjective score
    • Double-blind matchup display order randomized; win rates reported with confidence intervals
    • Cost table accounting for input / output / cache / retries as four separate items
    • At least 60% of traffic on the light tier, with a quality gate as backstop
    • Escalation rate, per-call cost, and gate pass rate on a monitoring dashboard
    • Full regression on every model upgrade, with results recorded and retained

    7. Conclusion

    New model releases routinely bring a “change at the top,” and that is the norm, not a selection criterion. The value of an evaluation system is to turn a one-off curiosity into a sustainable, regression-capable engineering capability: use the aggregate index to locate the waterline, per-capability performance to filter candidates, double-blind matchups to calibrate real experience, the cost model to bound your investment, and finally tiered routing to spend budget where a strong model is genuinely needed.

    A trend worth watching: the gap between domestic models and the global frontier is closing fast, and in some vertical scenarios a reversal has already appeared. The sensible strategy for a technical team is therefore not to wait for some “all-around strongest” model to appear, but to build your own evaluation baseline and routing architecture early — because when model capabilities converge, what determines business outcomes will no longer be which model you pick, but how you use it.