LLM Selection: Building an Evaluation Framework and Managing Costs
A practical guide to selecting large language models using task-specific evaluation rather than leaderboard rankings. Learn how to interpret benchmark scores, compare hosted and self-hosted deployment, build a repeatable evaluation pipeline, measure cost per successful task, and implement tiered routing with fallbacks.
1. Ask the Right Question: “The Three Best Models” Is an Answer That Expires
Questions such as “Which three LLMs are the best this year?” contain three implicit assumptions in an engineering context: capabilities can be reduced to a single score, rankings remain stable throughout the year, and the top-ranked model is the best choice for a business. None of these assumptions holds reliably.
Public evaluations generally show that the gaps between leading models are narrowing. In recent results from one comprehensive Chinese-language evaluation, the difference between first and second place was less than one point, with third and fourth also closely matched. Under these conditions, ranking changes may reflect evaluation variability more than meaningful capability differences. Question sampling, prompt templates, evaluator-model preferences, and decoding parameters—temperature, top_p, and maximum output length—can shift total scores by one or two points. Selecting a model by aggregate ranking alone therefore offers a poor signal-to-noise ratio.
A better question is: For my task distribution, which model delivers the best combination of quality, latency, cost, and control—and can that advantage be reproduced consistently?
The rest of this guide addresses that question.
2. Four Sources of Evidence—and Their Limits
Model selection requires cross-checking multiple sources of evidence. Four common categories provide distinct signals, each with clear limitations.
Standardized Capability Benchmarks
Knowledge and reasoning benchmarks offer broad coverage, reproducibility, and convenient comparisons over time. However, their tasks may differ substantially from real business workloads. They also face data contamination risks: if evaluation questions appear in training data, scores can be systematically inflated.
Use these benchmarks for initial screening, not the final decision.
Blind Human Preference Evaluations
Anonymous A/B comparisons ask reviewers to choose between two outputs without knowing the model identities. Statistical methods, such as Bradley–Terry models, then convert these preferences into ratings and confidence intervals.
These evaluations better reflect subjective user experience, but they are expensive and susceptible to reviewer preferences—for example, a bias toward longer, more verbose answers. Pay attention to confidence interval widths. Models with substantially overlapping intervals should generally be treated as belonging to the same performance tier.
Actual Usage Volume
Usage reflects developers’ practical choices and provides a strong signal of ecosystem activity and engineering usability.
Weekly data from one API aggregation platform showed that a single cost-effective small model accounted for roughly 30% of platform traffic and held first place for several consecutive weeks. However, usage volume indicates that a model is affordable, adequate, and easy to integrate—not that it can handle the hardest tasks.
Spending by Task Category
Spending distribution is often overlooked, yet it can be particularly useful for selection decisions.
On the same platform, spending on code implementation tasks was concentrated among a few expensive models, with one leading model accounting for more than 20% of that category. Meanwhile, the model leading in request volume was largely absent from the spending leaderboard.
The distinction is important: traffic concentrates in low-cost, high-frequency workloads, while spending concentrates in difficult, lower-frequency workloads.
These signals are not contradictory. They describe different parts of the market. Treating them as interchangeable leads to the familiar complaint that a leaderboard winner performs poorly in practice.
3. What Does a 0.8-Point Score Difference Mean?
Engineering teams need an actionable decision rule, not simply a score that “looks slightly higher.” A two-step approach is useful.
First, inspect confidence intervals. If two models’ score intervals overlap substantially, treat them as being in the same tier for practical screening and move on to cost and engineering considerations.
Second, run a paired significance test. Evaluate both models on the same questions, using the same prompts and decoding settings, then test the per-question score differences. Options include a paired t-test when the sample size and assumptions support it, a Wilcoxon signed-rank test for suitable non-normal data, or bootstrap resampling to estimate the distribution of the score difference.
import numpy as npdef bootstrap_gap(a, b, n=10000, alpha=0.05):"""a, b: Equal-length arrays of per-question scores.Returns the mean score difference and its confidence interval."""a, b = np.asarray(a), np.asarray(b)diffs = a - bidx = np.random.randint(0, len(diffs), size=(n, len(diffs)))means = diffs[idx].mean(axis=1)lo, hi = np.quantile(means, [alpha / 2, 1 - alpha / 2])return diffs.mean(), (lo, hi)# If the interval includes zero, it does not establish that A outperforms B.
As a practical rule, if the 95% interval includes zero, or the score difference is smaller than the evaluation’s standard error, treat the models as having no demonstrated difference for selection purposes. Give more weight to cost and latency.
4. Hosted Services vs. Self-Hosted Open-Weight Models
A recurring pattern in global blind-evaluation leaderboards is that proprietary hosted models lead the overall rankings, while Chinese-developed models frequently occupy the top positions in open-weight rankings. This reflects different deployment and development approaches, rather than a simple division between capable and incapable models.
Hosted services reduce operational overhead, scale elastically, and provide rapid access to capability improvements. Their trade-offs include data leaving your controlled environment, usage charges that scale with volume, and possible silent model updates that shift your evaluation baseline.
Open-weight models support private deployment, fine-tuning, and version pinning. Their per-unit costs can decrease as infrastructure utilization rises. However, they require an inference cluster, GPU memory management, and concurrency tuning. Their capability ceiling is also typically below that of contemporary flagship models.
Open weights should not automatically be equated with an open-source license; deployment choices remain subject to the model’s licensing terms.
Three criteria help make the decision concrete:
- Data compliance: Can requests leave your controlled environment?
- Daily token volume: Is usage high enough to spread the fixed costs of self-hosting across sufficient workload?
- Task profile: Are requests frequent, moderately difficult, and solvable with a smaller model plus workflow constraints?
The third criterion is especially important: many business requests do not require a flagship model.
5. Turn Rankings into a Repeatable Evaluation Pipeline
Leaderboards can narrow the candidate list, but the final decision must use your own data.
Step 1: Sample Real Requests
Extract requests from the previous 30 days of production logs, using logging tools for de-identification and sampling where appropriate. Group requests by intent and retain 200–500 representative examples that include long-tail cases.
Create a fixed, versioned evaluation dataset and store it in object storage.
Step 2: Define Separate Scoring Dimensions
Do not rely on one aggregate score. At minimum, evaluate:
- Correctness
- Instruction following
- Format compliance
- Factual consistency
- Latency
- Unit cost
For coding tasks, prioritize executable checks, such as unit-test pass rates, over subjective scoring.
Step 3: Fix Decoding Settings
Keep temperature, top_p, maximum output length, and system prompts consistent. Otherwise, cross-model comparisons become confounded.
Step 4: Combine Offline Evaluation with a Limited Online Rollout
Use offline evaluation to select two or three candidates. Then run a small-traffic rollout and A/B testing, using message-queue-driven asynchronous tasks where appropriate.
Track real conversion outcomes and manually review sampled responses.
Step 5: Establish a Regression Baseline
Rerun the evaluation dataset whenever a model version or prompt changes. This helps prevent unnoticed capability regressions.
# Illustrative evaluation framework skeletondef run_eval(client, cases, rubric):rows = []for c in cases:r = client.chat(c["prompt"], temperature=0.0, max_tokens=c["max_out"])rows.append({"id": c["id"],"score": rubric(r.text, c["gold"]), # Rule checks or model judging"in_tok": r.usage["prompt_tokens"],"out_tok": r.usage["completion_tokens"],"latency_ms": r.latency_ms,})return aggregate(rows) # Dimension-level means, confidence intervals, and cost
6. Evaluate Cost Alongside Quality: Cost per Successful Task
Token prices alone can be misleading. A more useful metric is cost per successful task: the expected expenditure required to complete a task that passes validation.
def cost_per_success(in_tok, out_tok, p_in, p_out, pass_rate):"""p_in/p_out: Prices per million tokens.pass_rate: First-attempt task pass rate."""cost = in_tok / 1e6 * p_in + out_tok / 1e6 * p_outreturn cost / max(pass_rate, 1e-6)
This simple metric exposes a common trap: a cheap model with a low pass rate may require repeated attempts and human intervention, making it more expensive in practice than a higher-priced model.
A complete cost assessment should account for retries, repeated context transmission, and human review time—not just the token charges captured in the example.
For self-hosted inference, container platforms can run the serving infrastructure, while monitoring and alerting track P95 latency, failure rates, and token consumption. Together, these provide an operational feedback loop for cost management.
7. Use Tiered Routing to Control Costs
Because request volume and spending concentrate in different workloads, the best solution is often not a single model. Instead, use difficulty-based routing: send frequent, simple requests to a low-cost small model and complex reasoning or code generation to a stronger, more expensive model. Maintain fallback paths for service failures.
def route(task):if task.kind == "code_generation":return ["strong_model", "mid_model"] # Primary and fallbackif task.tokens_est > 60_000:return ["long_ctx_model", "mid_model"]if task.risk == "high": # Compliance-sensitivereturn ["private_deploy_model"]return ["cheap_model", "mid_model"]def call_with_fallback(task, clients):for name in route(task):try:return clients[name].chat(task.prompt)except (TimeoutError, RateLimitError):continueraise RuntimeError("all candidates failed")
The routing example is illustrative; compliance restrictions must govern which deployment paths are permitted.
Combined with caching—including reuse of shared prompt prefixes—batch processing, and output-length limits, tiered routing can substantially reduce overall costs while preserving quality on critical tasks.
8. Common Selection Mistakes
- Replacing business-specific evaluation with aggregate leaderboard rankings, while ignoring confidence intervals and standard errors.
- Comparing models without fixing decoding settings and system prompts.
- Counting token prices but excluding retries, human review, and repeated context transmission.
- Ignoring baseline drift caused by silent provider updates, without version pinning or regression evaluation.
- Comparing open-weight rankings directly with overall rankings without considering deployment differences.
- Assessing data compliance too late, resulting in avoidable rework.
9. Conclusion
There is no stable answer to “Which three models are best?” There is, however, a repeatable method for determining which models best fit your workload.
Use standardized benchmarks for initial screening. Use blind preference evaluations and confidence intervals to identify performance tiers. Treat usage volume as evidence of ecosystem adoption and engineering practicality, and examine spending by task category to understand where users find value.
Make the final decision using a task-specific evaluation dataset and cost per successful task. Then operationalize that decision through tiered routing, fallback paths, and regression testing.
General-purpose cloud capabilities—object storage, message queues, container platforms, logging, monitoring, and alerting—can support this evaluation and governance pipeline. These capabilities are available across mainstream cloud platforms, including Baidu AI Cloud, subject to the relevant service and regional availability. The goal is to turn model selection from a one-time subjective judgment into a continuously reproducible engineering process.
