A Practical Methodology for Evaluating and Selecting Large Language Models

    A reusable framework for LLM evaluation and selection: how to build a layered test set, standardize accuracy, latency, token usage, and cost metrics, interpret uneven performance gains across capability domains, calculate cost per correct answer, and combine caching, routing, output constraints, batching, and canary rollback to balance cost and quality.

    1. Why Choosing a Model Gets Harder After Every New Release

    Every few months a vendor ships a new generation of models, and the official messaging is usually some variation of “stronger performance at significantly lower cost” or “outperforms the previous generation on most public benchmarks.” That kind of information has limited value for technical decision-making, for three reasons:

    1. Benchmarks do not match your traffic distribution. The question mix, language style, and answer format on public leaderboards often diverge from real business traffic.
    2. Metrics are compressed. Vendors typically highlight accuracy or a single leaderboard position, while engineering teams care about latency distribution, token consumption, retry and failure rates, and cost per call.
    3. The release is in preview. In the early days of a new version, server load is high and rate-limiting policies are unstable, so measured latency and success rates are not representative.

    So this article does not restate the evaluation results of any specific product. Instead, it abstracts a large-scale head-to-head LLM evaluation — roughly 15,000 questions spanning more than a dozen capability domains — into a methodology, along with engineering practices you can apply directly.

    2. Evaluation Design: Making Data Useful for Decisions

    2.1 Building a Layered Question Set

    The evaluation set should be stratified by capability domain. Common dimensions include education and knowledge Q&A, reasoning and math, finance, healthcare and mental health, code and tool calling, long-context understanding, and multi-turn consistency. Every layer needs to satisfy:

    • Sufficient sample size: when a single domain has fewer than a few hundred questions, percentage swings will mask real differences.
    • A sensible difficulty mix: easy/medium/hard questions should be apportioned close to real traffic ratios, so an all-hard set does not compress every model into the low end of the score range.
    • Automatically judgeable answers: prefer multiple choice, structured extraction, and executable checks to reduce the subjective noise of human review.

    2.2 Standardizing Metric Definitions

    A reproducible evaluation has to fix at least the following:

    • Accuracy: same prompt template, same temperature, same max output length.
    • Latency: separate time-to-first-token from end-to-end completion time, and report P50/P95 rather than the mean alone.
    • Token consumption: count input and output tokens separately; output is usually priced significantly higher than input.
    • Cost: use “cost per 1,000 calls” as the externally comparable figure, and keep “price per million tokens” for your own cost model.
    • Retries and failures: timeouts, rate limiting, and content blocks must all be counted, otherwise cost is systematically underestimated.

    A sketch of the evaluation loop:

    1. def run_eval(model, dataset, cfg):
    2. rows = []
    3. for item in dataset:
    4. t0 = time.time()
    5. resp = call_model(model, item.prompt,
    6. temperature=cfg.temperature,
    7. max_tokens=cfg.max_tokens)
    8. rows.append({
    9. "domain": item.domain,
    10. "correct": judge(resp, item.gold),
    11. "latency": time.time() - t0,
    12. "in_tokens": resp.usage.input_tokens,
    13. "out_tokens": resp.usage.output_tokens,
    14. "retries": resp.retries,
    15. })
    16. return summarize(rows) # accuracy, P50/P95, average tokens, cost per 1k calls

    3. Reading the Results: A Structured Breakdown of a Typical Observation

    Under this framework, a comparison between a previous-generation Flash-tier model and a new-generation Flash-tier preview model typically shows the following structural changes (numbers are illustrative of the trend only and do not represent any specific product):

    • Overall accuracy jumps by roughly ten percentage points, moving the combined ranking from outside the top dozens into the top five.
    • The improvement is uneven: education and knowledge Q&A gains the most, nearly doubling; reasoning and math, healthcare and mental health, and finance also improve by double digits.
    • Latency rises: average completion time goes from about 40 seconds to about 72 seconds. High load right after launch is the main cause, and it usually settles once things stabilize.
    • Cost rises: cost per 1,000 calls goes from about CNY 43 to about CNY 53, the output unit price is raised, and average token consumption increases by about 5%.

    The engineering-relevant point is the uneven improvement. A 10-point gain in the total score may come entirely from closing one or two weak domains. That means selection has to be weighted against your own traffic distribution rather than adopting the overall ranking directly.

    4. Cost Model: Converting Accuracy into Cost per Correct Answer

    Looking at unit price alone leads to wrong conclusions. Introduce “cost per correct answer”:

    1. cost per correct answer = cost per 1,000 calls / accuracy

    Using the illustrative data above: the old version is about 43.2 / 0.606 ≈ CNY 71.3, and the new version is about 53.5 / 0.715 ≈ CNY 74.8. In other words, accuracy improves by 10.9 percentage points, but the cost of obtaining one correct answer actually rises slightly. The conclusion is not “the new version is not worth it,” but rather: if your business is insensitive to the cost of errors (internal summarization, draft generation), the old version is more economical; if errors require human fallback (finance, healthcare consultation support), the manual review cost the new version saves may far exceed the difference in model price.

    Extend this to include self-hosted costs:

    1. monthly cost ≈ call volume × (input tokens × input price + output tokens × output price)
    2. + retry amplification factor × the above
    3. + infrastructure cost for vector retrieval/caching/logging and monitoring

    The retry amplification factor is often overlooked: when P95 latency rises, timeout retries can inflate actual call volume by 10%–30%.

    5. Engineering Practice: Five Optimizations You Can Apply Now

    1. Semantic caching. Build a normalized cache for high-frequency repeated questions (strip whitespace, unify case, remove template noise) and return on a hit; this typically cuts call volume by a double-digit percentage.
    1. key = hashlib.sha256(normalize(prompt).encode()).hexdigest()
    2. if hit := cache.get(key):
    3. return hit
    1. Tiered routing. Use a lightweight model for intent recognition, format conversion, and simple Q&A; escalate only hard cases to the higher-capability model, forming a funnel.

    2. Output length constraints. Output tokens cost more, so lowering max_tokens and requiring short structured answers often saves more than switching models.

    3. Batching and asynchrony. Move offline work to queue-driven batch processing, use a message queue to smooth peaks, and pair it with elastic scaling on a container platform to avoid peak-hour rate limiting.

    4. Canary and rollback. Start a new version at 5% traffic, monitor proxy accuracy metrics (manual spot checks plus rule-based validation), P95 latency, error rate, and cost per 1,000 calls, and roll back automatically if any metric goes out of bounds.

    1. canary:
    2. weight: 0.05
    3. guardrails:
    4. p95_latency_ms: 90000
    5. error_rate: 0.02
    6. cost_per_1k_cny: 60
    7. accuracy_min: 0.70
    8. rollback: automatic

    6. Common Pitfalls

    • Deciding on the total score: ignoring traffic-distribution weighting causes production experience to diverge from the evaluation.
    • Reporting only average latency: the mean hides the long tail, and user perception is driven by P95.
    • Ignoring output token cost: for long chain-of-thought models, the real bill is often two or three times the estimate.
    • Capacity planning on a preview release: rate limits and quota policies are not stable yet, so keep a fallback path.
    • Overlooking data compliance: avoid persisting sensitive raw text in logs and monitoring, and de-identify the evaluation set.

    7. Conclusion

    A new model being “stronger” is a trend judgment, not a selection decision. The reusable approach: build a layered question set with standardized definitions, replace unit-price comparison with cost per correct answer, and combine caching, routing, output constraints, batching, and canary rollback into a cost–quality balancing scheme. If you need managed model services, logging, monitoring and alerting, and a container platform to carry these workflows, the general-purpose capabilities of Baidu AI Cloud can serve as a reference direction when selecting infrastructure.