LLM Selection: Balancing Capability, Speed, and Cost

    This article explains how teams can choose among mid-tier large language models by evaluating capability, speed, and cost in a structured way. It covers how to convert token unit prices into cost per successful task, how to interpret benchmark results responsibly, and how to operationalize selection through custom evaluation sets, tiered routing, canary rollouts, rollback plans, and cost monitoring. It also highlights common pitfalls that can lead to unreliable model-selection decisions.

    1. Why Mid-Tier Models Become the Selection Focus

    When several models are available within the same capability range, the question shifts from “Can we use it?” to “Which one is more cost-effective?” Flagship models are more capable but have higher unit prices. Lightweight models are cheaper but are more likely to make mistakes on complex reasoning and multi-step tasks. Mid-tier models usually cover needs such as code generation, multi-step task planning, and analytical reasoning, so they often become the default choice for many business use cases.

    The difficulty is that differences among mid-tier models are often subtle. A few benchmark points of lead in one metric may not translate into business value. Evaluation needs to be broken down into quantifiable dimensions and then validated item by item against the actual scenario.

    2. Three Core Evaluation Dimensions

    2.1 Capability

    General benchmark scores can reflect a model’s approximate level, but their relevance to a specific business context needs separate validation. Differences in sub-scores for coding, long-document understanding, tool calling, and mathematical reasoning are often more informative than a composite score. During selection, first list the three to five most common task types in the business, then compare models for each type.

    2.2 Speed

    User-perceived responsiveness mainly depends on two metrics:

    • Time to First Token (TTFT): the time from sending a request to receiving the first output character. This determines the “instant feel” in interactive scenarios.
    • Output throughput (tokens generated per second): this determines the total time for long answers and is more important for tasks such as batch processing and report generation.

    The two metrics should be measured separately and sampled under concurrency levels and network conditions close to those of the production environment. A single test can produce large fluctuations, so it is advisable to take the median and percentiles across multiple requests.

    2.3 Cost

    LLM billing is usually divided into three parts: regular input tokens, cached input tokens, and output tokens. The unit prices of the three differ significantly, and output tokens often have the highest unit price. Therefore, for the same request volume, the longer the answer, the faster the bill grows. When calculating cost, do not look only at a single “price per million tokens”; instead, add up the three parts separately.

    3. Convert Unit Prices to Cost per Task

    Unit prices alone cannot be compared directly. They should be converted into “the cost of completing a typical task.” The recommended steps are:

    1. From production logs, calculate the average number of input tokens, cached-hit tokens, and output tokens for typical tasks.
    2. Calculate the per-call cost using each tier’s unit prices.
    3. Combine this with the task success rate to derive the “cost per successful task.” Retries after failures add to actual overhead, and ignoring this item will underestimate total cost.

    The following example shows how to perform the calculation in code. The unit prices are illustrative assumptions and do not represent any real pricing.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class PriceTier:
    4. name: str
    5. input_per_m: float # Price per million input tokens (CNY)
    6. cached_per_m: float # Price per million cached input tokens (CNY)
    7. output_per_m: float # Price per million output tokens (CNY)
    8. def cost_per_call(tier: PriceTier, input_tokens: int,
    9. cached_tokens: int, output_tokens: int) -> float:
    10. """Calculate the cost per call in the same currency as the unit prices."""
    11. return (
    12. input_tokens / 1_000_000 * tier.input_per_m
    13. + cached_tokens / 1_000_000 * tier.cached_per_m
    14. + output_tokens / 1_000_000 * tier.output_per_m
    15. )
    16. def cost_per_success(tier: PriceTier, success_rate: float,
    17. input_tokens: int, cached_tokens: int,
    18. output_tokens: int) -> float:
    19. """Calculate cost per successful task by success rate, assuming failures retry in the same way."""
    20. if not 0 < success_rate <= 1:
    21. raise ValueError("success_rate must be in the range (0, 1]")
    22. per_call = cost_per_call(tier, input_tokens, cached_tokens, output_tokens)
    23. return per_call / success_rate
    24. if __name__ == "__main__":
    25. tiers = [
    26. PriceTier("Tier A", input_per_m=3.0, cached_per_m=0.15, output_per_m=15.0),
    27. PriceTier("Tier B", input_per_m=2.0, cached_per_m=0.10, output_per_m=10.0),
    28. ]
    29. # Illustrative task profile: 3,000 input tokens, 2,000 cached hits, 800 output tokens
    30. for tier in tiers:
    31. single = cost_per_call(tier, 3000, 2000, 800)
    32. real = cost_per_success(tier, success_rate=0.92,
    33. input_tokens=3000, cached_tokens=2000,
    34. output_tokens=800)
    35. print(f"{tier.name}: {single:.4f} CNY per call, {real:.4f} CNY per successful task")

    The key point in this code is that the success rate amplifies cost differences. If two tiers have similar unit prices but significantly different success rates, their final unit costs may differ notably.

    4. Interpreting Benchmark Results Correctly

    Benchmark tests are an important input for model selection, but several points require attention when interpreting them:

    • Confirm the data source. Vendor-published test results and independent third-party evaluations may use different methodologies. They should be cross-checked, and a single source should not be relied on alone.
    • Confirm the evaluation version and inference parameters. The same model with a longer reasoning budget will change both scores and latency. Settings must be consistent for comparison; otherwise, the conclusion does not hold.
    • Judge whether the score gap exceeds evaluation noise. When scores are close, the difference may be random fluctuation. Use the mean and confidence intervals across multiple runs.
    • Distinguish capability from cost-effectiveness. A higher score does not mean a lower unit cost. Scores should be compared in the same table as the speed and cost data from Sections 2 and 3.

    5. Implementation Practices

    5.1 Build Your Own Evaluation Set

    General benchmarks cannot fully represent your own business. It is advisable to sample a set of real requests from production logs, covering both high-frequency scenarios and edge cases. The sample size can start with a few hundred requests, and each request should have a reference answer or executable scoring rule. The evaluation set should be updated regularly to reflect business changes.

    5.2 Tiered Routing

    Not all requests need the strongest model. Requests can be routed to different tiers based on task type, input length, or historical failure rate:

    1. def pick_tier(task_type: str, prompt_tokens: int) -> str:
    2. """Select a model tier based on task type and input length; rules are illustrative only."""
    3. if task_type in {"classify", "extract"} and prompt_tokens < 2000:
    4. return "small"
    5. if task_type in {"code_gen", "multi_step"}:
    6. return "mid"
    7. return "large"

    Routing rules should be based on evaluation set results. After the rules go live, continuously check the success rate and cost of each tier and adjust thresholds in a timely manner.

    5.3 Canary Rollout and Rollback

    When replacing a model, first send a small amount of traffic (for example, 5%) to the new model and compare three metrics: success rate, latency, and cost per successful task. After all three meet expectations, gradually increase the percentage. If quality drops significantly, it should be possible to switch back to the original model with one click. The rollback path needs to be tested in advance; it should not be verified for the first time when a production issue occurs.

    5.4 Monitoring and Cost Alerts

    Every call should record the number of input tokens, cache hits, output tokens, latency, and result status, and be aggregated daily. Abnormal cost fluctuations usually have clear causes, such as prompts being unexpectedly lengthened, outputs having no length limit, or a feature getting stuck in a retry loop. Setting daily cost threshold alerts can help detect such issues earlier.

    6. Common Pitfalls

    • Looking only at composite scores and ignoring actual performance in business scenarios.
    • Comparing only unit prices and ignoring the impact of output length and retry count on cost.
    • Using test data from a single source directly as the basis for launch.
    • Ignoring context length limits, causing long-document tasks to be truncated and results to be incomplete without an error.
    • Using prompts and inference parameters in evaluation that are inconsistent with production, making offline conclusions impossible to reproduce.

    The key to avoiding these pitfalls is to treat model selection as a repeatable engineering process: define metrics, validate with your own data, switch a small amount of traffic, and monitor continuously.