Stop Choosing LLMs by Leaderboard Scores: Start with Cost per Successful Task

    Leaderboard scores are useful for narrowing down model candidates, but they rarely reflect real-world performance. This article explains how to evaluate models with internal task samples, calculate cost per successful task, build a practical evaluation set, route requests by difficulty, manage context and caching, and control regression risks during model upgrades.

    1. Why Leaderboard Scores Often Do Not Match Real-World Performance

    Public leaderboards typically measure accuracy on fixed benchmark datasets. The questions are curated, and the input format is usually consistent. In production, however, prompts can vary significantly. Contexts may contain previous conversations, retrieved content, and tool outputs, while tasks may require multi-step reasoning and external actions. These differences can cause the same model to receive very different evaluations in benchmark and production environments.

    To determine whether a model is suitable for a specific business task, use your own task samples as the primary reference. Leaderboards can help narrow down the candidate pool, but the final decision should be based on internal data.

    Common sources of evaluation bias include:

    • Different prompt styles: Internal prompts are often longer and include extensive formatting constraints.
    • Different reasoning settings: The same model can have significant differences in latency and cost under different reasoning levels.
    • Different acceptance criteria: Developers may care whether generated code passes tests, while product teams may focus on whether the output follows a required specification.
    • Different failure modes: Some models occasionally produce completely incorrect answers, while others repeatedly make small but important mistakes. These failure patterns can have very different business impacts.

    2. Move from List Price to Cost per Task

    Model pricing is usually quoted per million tokens, with separate rates for standard input, cached input, and output. A lower unit price does not necessarily mean a lower total cost. If a model requires more reasoning steps and longer outputs to complete the same task, its cost per task may be higher. Retries after failures also increase spending, so success rate must be included in the calculation.

    The estimated cost per successful task is:

    1. Cost per successful task = Cost per attempt / Success rate

    The cost of a single attempt consists of three components:

    • Input tokens not served from cache multiplied by the standard input price
    • Cached input tokens multiplied by the cached input price
    • Output tokens multiplied by the output price

    The following code demonstrates the calculation. The caller must provide the pricing parameters; the code does not contain any real pricing data.

    1. from dataclasses import dataclass
    2. @dataclass
    3. class Price:
    4. input_per_m: float # Price per million standard input tokens
    5. cached_per_m: float # Price per million cached input tokens
    6. output_per_m: float # Price per million output tokens
    7. @dataclass
    8. class TaskStats:
    9. input_tokens: int # Input tokens not served from cache
    10. cached_tokens: int # Input tokens served from cache
    11. output_tokens: int # Output tokens
    12. success_rate: float # A value between 0 and 1
    13. def cost_per_success(price: Price, stats: TaskStats) -> float:
    14. if stats.success_rate <= 0:
    15. return float("inf")
    16. single = (
    17. stats.input_tokens * price.input_per_m
    18. + stats.cached_tokens * price.cached_per_m
    19. + stats.output_tokens * price.output_per_m
    20. ) / 1_000_000
    21. return single / stats.success_rate

    When using this function, collect token usage and success rates for each model on the same type of task, then compare the results. A model with a higher unit price may still have a lower cost per successful task if it produces more concise outputs and succeeds more often. Conversely, a lower-priced model may cost more in practice if it generates verbose responses and requires repeated retries.

    3. Build Your Own Evaluation Set

    An evaluation set should be the foundation of model selection. A practical process includes the following steps:

    1. Sample production data: Draw stratified samples from real business logs by task type. Keep at least several dozen samples for each type to reduce the effect of random variation.
    2. Define acceptance criteria: For tasks that can be checked automatically, use unit tests, schema validation, or key-field matching. For tasks that cannot be fully automated, define scoring guidelines and conduct manual spot checks.
    3. Control variables: Keep prompts, sampling parameters, and reasoning levels fixed to ensure a fair comparison across models.
    4. Record metrics: Track token usage, latency, retry counts, and failure types. Categorize failure causes rather than recording them as a single undifferentiated metric.
    5. Summarize the results: Report success rate, cost per successful task, and tail latency.

    The following is a simplified evaluation framework. model_client is a unified interface implemented by the team, and validator is the acceptance function for the relevant task type.

    1. import time
    2. def summarize(results):
    3. n = len(results)
    4. latencies = sorted(r["latency"] for r in results)
    5. return {
    6. "success_rate": sum(r["ok"] for r in results) / n,
    7. "p95_latency": latencies[min(n - 1, int(n * 0.95))],
    8. "avg_input_tokens": sum(r["input_tokens"] for r in results) / n,
    9. "avg_cached_tokens": sum(r["cached_tokens"] for r in results) / n,
    10. "avg_output_tokens": sum(r["output_tokens"] for r in results) / n,
    11. }
    12. def run_eval(model_client, cases, validator):
    13. results = []
    14. for case in cases:
    15. start = time.perf_counter()
    16. resp = model_client.generate(case["prompt"])
    17. latency = time.perf_counter() - start
    18. results.append({
    19. "ok": validator(case, resp.text),
    20. "latency": latency,
    21. "input_tokens": resp.usage.input_tokens,
    22. "cached_tokens": resp.usage.cached_tokens,
    23. "output_tokens": resp.usage.output_tokens,
    24. })
    25. return summarize(results)

    Evaluation results should be reported separately by task type. Overall averages can hide significant weaknesses in a particular category.

    4. Route Requests to the Right Model

    Most businesses handle tasks with widely varying levels of difficulty. Lightweight models are often sufficient for classification, summarization, and format conversion. More capable models should be reserved for complex tasks such as multi-step reasoning, large-scale code changes, and specialized technical writing. Using the most powerful model for every request often wastes money on tasks that could be completed reliably at a lower cost.

    A common approach is to introduce a routing layer:

    • Prefer rule-based routing: Route requests using deterministic conditions such as task type, input length, and whether tool calls are required. This approach is inexpensive and easy to explain.
    • Escalate after failure: If a lightweight model produces an output that fails validation, automatically send the task to a more capable model. Set a limit on escalation attempts to prevent repeated or circular calls.
    • Use confidence as a supporting signal: If a model can provide a reliable self-evaluation signal, it may be used to trigger escalation. Its effectiveness should first be verified against the evaluation set.

    Routing itself introduces overhead. A classifier may require an additional model call or computation, so routing is worthwhile only when the savings exceed its own cost.

    5. Manage Context and Caching

    Context management directly affects both cost and latency. The following practices are especially important:

    • Place stable content in the prefix: Put system instructions, tool definitions, and policy documents at the beginning of the prompt, followed by dynamic content. A stable prefix can improve cache hit rates.
    • Limit retrieved content: Deduplicate retrieval results, rank them by relevance, and truncate the list so that only directly useful content remains.
    • Do not treat a long context as unlimited storage: Longer contexts increase cost and latency, while also making important information easier to overlook. For critical facts, design read-back or citation-validation steps.
    • Constrain output length: Specify the required response structure and approximate length in the instructions, and set an output token limit. Excessively verbose responses are a common cause of uncontrolled costs.

    6. Regression Risks During Model Upgrades

    A model version change can affect response style, format compliance, and tool-calling behavior. Even when the API remains unchanged, business performance may fluctuate. Before and after an upgrade, follow these steps:

    • Run regression tests: Test the old and new versions on the same evaluation set. Pay particular attention to success rate, format error rate, and retry rate.
    • Use a gradual rollout: Send a small percentage of traffic to the new version first, then compare manual edit rates, user feedback, and operational alerts.
    • Maintain a rollback path: Store the model version as a configuration value instead of hard-coding it across multiple parts of the codebase, so the previous version can be restored quickly if problems occur.

    AI agent applications that can call external tools require additional safeguards:

    • Follow the principle of least privilege and expose only the operations required to complete the task.
    • Require human confirmation for high-risk actions such as deletion, sending messages, or making payments.
    • Log model tool calls and operation results in full for later auditing.
    • A model’s claim that an action was “completed” is not proof of completion. Verify the result through the external system.

    7. Implementation Checklist

    • Use an internal evaluation set to measure success rate and cost per successful task instead of relying on leaderboard scores alone.
    • Model standard input, cached input, and output pricing separately, then calculate costs together with success rate.
    • Set default values for each reasoning level and require approval or impose usage limits for high-cost levels.
    • Establish routing, gradual rollout, and rollback mechanisms to keep model changes under control.
    • Re-evaluate models regularly because prices, capabilities, and service terms change over time.