LLM Model Selection: A New Approach Based on Per-Stage Evaluation and Cost Optimization

    Choosing a single "best" LLM from a leaderboard is often a poor fit for enterprise workflows. This article explains why composite tasks, non-linear token costs, and hidden rework costs make per-stage evaluation more practical. It covers a three-dimension evaluation framework (effectiveness, rework, and cost), how to calculate costs separately for input, cache-hit input, and output tokens, how to run controlled A/B experiments on common tasks, and how to roll out model tiers progressively. It also lists engineering practices for sustainable evaluation and common pitfalls to avoid.

    1. The Problem: Why “Pick the Strongest Model” Often Falls Short

    In enterprise applications and complex engineering workflows, large language models are no longer just a fallback for single-turn Q&A. They are embedded deeply in real processes such as code repair, document retrieval, evidence-chain reconstruction, and multi-step tool calling. When selecting models, many teams first look at aggregate leaderboard scores, then pick the top-ranked model and replace every model call across the entire pipeline. In engineering practice, this approach usually yields limited returns, for three reasons.

    First, real tasks are composite. A single “fix a bug” action often involves locating the issue, reproducing it, modifying code, running tests, and writing an explanation. A single “answer a question from an old document” action involves retrieval, extraction, verification, and organizing the response. Different stages place completely different demands on model capabilities. Using one model for every stage amounts to asking general-purpose ability to cover every specialized need.

    Second, the cost structure is not linear. Under token-based billing, the unit prices for input, cache-hit input, and output differ significantly, and the proportion of these three varies widely across stages. Scenarios that repeatedly process the same material naturally have a higher cache hit rate; scenarios that read new material every time and produce long outputs see output costs rise sharply as a share of the total.

    Third, manual rework is a hidden cost. When a model’s output is unusable on the first try and a person has to revise it over several rounds, that time often costs more than the token fees. Looking only at unit price or only at scores misses this entirely.

    A more reasonable approach is therefore to break a complete task into several independently verifiable stages, and for each stage set separate acceptance criteria, track costs separately, and decide separately which model tier to use.

    2. The Framework: Three-Dimension Evaluation and Per-Stage Selection

    Break evaluation into three dimensions rather than a single aggregate score.

    • Effectiveness: whether key results are correct and meet a standard that is mergeable or deliverable. Note that metrics such as a “mergeable standard” assess the quality of changes in a real codebase, not single-point Q&A accuracy.
    • Rework: how many rounds of manual modification were needed and whether expert intervention was required. The number of rework rounds is the metric closest to real cost.
    • Cost: separately tally the consumption of input tokens, cache-hit input tokens, and output tokens, then multiply each by its unit price.

    On top of these three dimensions, build a “stage table” with one row per stage. Columns include: stage goal, acceptance criteria, candidate model tiers, measured effectiveness, average rework rounds, and cost per run. The selection conclusion belongs in this table, not on some leaderboard.

    It is worth stressing that tasks such as cross-service fault localization and reconstructing an evidence chain from a large body of material are assessed differently from routine code modification. They must be re-tested with your own tasks; you cannot directly transplant someone else’s evaluation conclusions.

    3. Cost Accounting: Calculate the Three Token Types Separately

    The most common mistake in budget estimation is multiplying all tokens by a single average unit price. The correct approach is to keep three separate accounts:

    1. Cost per run = input tokens × input unit price
    2. + cache-hit input tokens × cache-hit unit price
    3. + output tokens × output unit price

    The cache-hit unit price is usually far lower than the regular input unit price. So in scenarios where “the same material is referenced repeatedly,” the hit ratio becomes the decisive variable. In engineering, you can raise the hit rate through stable prefixes, fixed system prompts, and placing long documents in reusable positions, but note that the hit rate depends on the specific platform implementation and should be based on the actual bill.

    A simplified comparison approach:

    1. def estimate(input_tok, cached_tok, output_tok, p_in, p_cached, p_out):
    2. assert 0 <= cached_tok <= input_tok
    3. return (input_tok - cached_tok) * p_in + cached_tok * p_cached + output_tok * p_out
    4. # Scenario A: repeatedly processing the same long material, high hit rate
    5. cost_a = estimate(20000, 18000, 800, 8.0, 0.4, 40.0)
    6. # Scenario B: reading new material each time, almost no hits, longer output
    7. cost_b = estimate(20000, 0, 4000, 8.0, 0.4, 40.0)

    With the same 20,000 input tokens, the two scenarios can differ in cost by several times. This shows that “which model is cheaper” is a false question; the right question is “which is cheaper given my token distribution.”

    4. Controlled Experiments: Run Three Common Tasks First

    Do not replace the entire pipeline from the start. First pick three high-frequency, verifiable tasks for A/B comparison:

    1. Fix a known bug: the acceptance criterion is whether the patch passes existing tests and meets the maintainer’s merge standard; record whether localization was accurate and how many rework rounds were needed.
    2. Answer several verifiable questions based on an old document: the acceptance criterion is whether answers are supported by the document’s original text; record whether citations are verifiable.
    3. Run a multi-step task that requires tools: the acceptance criterion is whether the final output is complete and intermediate steps are replayable; record at which step failures get stuck.

    Key points for experiment design:

    • Fix inputs and randomness settings to ensure reproducibility;
    • Repeat each task several times and take the median rather than the single best result;
    • Record all three token consumption types and manual minutes at the same time;
    • Write conclusions only as “which tier is more cost-effective for which stage,” not “a certain model is stronger across the board.”

    5. Progressive Replacement: Routine First, Hard Cases Later

    The recommended rollout order is “layered responsibility”: let the efficiency-first tier handle routine, repetitive, verifiable parts; hand steps that repeatedly get stuck to a more capable tier better suited for long-running progress. The benefit is visible returns and easy rollback.

    1. Pipeline: retrieve → extract → generate → verify → summarize
    2. Tier: routine routine hard routine routine

    When a stage fails repeatedly several times in a row, upgrade it to a hard stage; when a stage passes stably, try downgrading it to save cost. This “upgradable and downgradable” strategy is more resilient than locking in a single model all at once.

    6. Engineering Support: Make Evaluation Sustainable

    • Observability: write each call’s stage identifier, three token consumption types, latency, and rework rounds into a logging service, with thresholds set alongside monitoring and alerting.
    • Separate data and state: put long material in object storage and task state in a message queue or database, avoiding repeatedly stuffing large chunks of context into prompts.
    • Containerized deployment and canary release: run a new tier at small traffic on a container platform first, then scale up once metrics meet targets.
    • Prompt and context governance: stable prefixes, structured output, and clear acceptance criteria can reduce both rework and cost.
    • If you use general cloud capabilities, you can combine categories such as object storage, message queues, container platforms, logging services, and monitoring and alerting. Platforms like Baidu AI Cloud typically offer such general infrastructure; refer to the official documentation for specific billing and quotas.

    7. Common Pitfalls

    • Replacing scenario testing with aggregate leaderboards: leaderboard tasks differ from your task distribution, so conclusions cannot be transferred directly.
    • Comparing only unit prices without comparing token distributions: in high- and low-hit-rate scenarios, conclusions can be completely opposite.
    • Ignoring rework costs: the cost of one unusable output is often higher than its token fees.
    • Replacing everything at once: risk is concentrated, attribution is difficult, and the payoff is hard to explain.
    • Not recording a baseline: without comparison data, no later optimization can be proven effective.

    8. Conclusion

    The right way to select LLM models is to break tasks into stages, break costs into three types, and break evaluation into three dimensions, then replace models gradually through small controlled experiments. What you get is not the empty phrase “the strongest model,” but an executable, reviewable, and continuously optimizable per-stage selection table.