LLM Model Selection: A Dual-Track Approach and Task-Level Cost Optimization
Choosing an LLM is not about picking the single highest-scoring model. This article explains how to decompose workflows into observable stages, classify them by reasoning depth, context size, and failure cost, and route each stage to either a deep-reasoning or efficiency-first tier. It also covers a token-based cost model that separates uncached input, cached input, and output, plus a gradual adoption path, acceptance records, and common anti-patterns for building a measurable, reversible evaluation pipeline.
1. The Starting Problem: Model Rankings Cannot Replace Task-Level Evaluation
As generative model capabilities iterate quickly, a common mistake is treating selection as “pick the model with the highest overall score.” In real engineering scenarios, a task is never a single action. It is a chain: understand the requirement, retrieve information, modify code or generate content, run verification, and fall back to retry based on failure messages. Each stage in the chain demands different capabilities. Some stages rely on long-range reasoning and context retention, while others are simply high-frequency, short-lived structured transformations.
A more reasonable approach is task-level decomposition: first split a workflow into several independently observable stages, then set acceptance criteria and cost ceilings for each stage. This answers “which capability tier should this step use” rather than “which model should we use overall.”
2. Two Capability Tiers: Deep-Reasoning and Efficiency-First
The industry usually groups models into two orientations. One targets complex programming, research reasoning, and professional work that requires sustained progress over long periods, emphasizing consistency in long contexts, complex constraint satisfaction, and self-correction. The other targets everyday coding and multi-step tasks, emphasizing output per unit of time and per unit of cost.
Notably, in evaluations focused on real codebase modifications, the score gap between the two tiers at their highest configurations can be very small (for example, less than half a point), while the efficiency tier may complete the same task at roughly one-fifth of the cost of the deep tier. The engineering implication is that capability gaps are not always reflected linearly in the bill. Many routine stages only need to be “good enough,” and paying the deep-tier premium for them is not worthwhile.
The evaluation criteria themselves also matter. An evaluation aimed at “whether a patch meets the maintainer’s merge standard” examines patch correctness and mergeability. Tasks such as cross-service fault localization and reconstructing an evidence chain from large volumes of material test hypothesis generation, cross-validation of evidence, and long-range consistency, and must be re-tested on your own data.
3. Breaking Tasks into Stages: A Reusable Classification Framework
Tag each stage along three dimensions:
- Reasoning depth: whether multi-hop reasoning and cross-module constraint solving are required;
- Context size: the amount of material that must be loaded at once and the duration it must be retained;
- Failure cost: whether an error leads to a low-cost retry or causes irreversible side effects.
This yields a stable division of labor: stages with high reasoning depth, long context, and high failure cost go to the deep-reasoning tier; high-frequency, short-context, quickly verifiable stages go to the efficiency-first tier.
The routing logic can be expressed as configuration rather than hard-coded:
routing:- stage: requirement_parse # short context, structured outputtier: efficientmax_retries: 2- stage: repo_patch # long context, cross-file constraintstier: deepmax_retries: 4- stage: test_and_report # verifiable, low failure costtier: efficient
4. The Cost Model: Three Token Types Must Be Accounted Separately
The key to budget accounting is to measure tokens in three separate categories: uncached input, cached input, and output. Their unit prices usually differ significantly. Cached input is often only a small fraction of the regular input price, while output is the most expensive.
This means the cost structure is determined by “repetition.” When repeatedly processing the same material (a long system prompt, a fixed knowledge base, the same codebase context), the cache hit ratio is high and actual input cost drops sharply. When every call reads a new set of material, nearly all input is billed at full price, and the cost curve is completely different.
A simplified model:
cost per call = uncached input × P_in+ cached input × P_cache+ output × P_outtotal cost = Σ (cost per call per stage × call count) + retry overhead
Three practical optimizations: place stable, unchanging prefixes (specifications, interface conventions, directory descriptions) first to improve cache hits; compress returned content to avoid stuffing entire logs into the output; and set retry limits, because retry overhead is often the most overlooked cost item.
5. A Gradual Adoption Path: Compare Three Common Tasks
Do not replace the entire workflow at the start. Pick three high-frequency tasks for an A/B comparison: fix a known bug, answer several verifiable questions based on an old document, and run a multi-step task that requires tool calls. Record three metrics: whether the result is correct, how many rounds of human edits were needed, and the final cost.
The recommended order is to first run the routine parts with the efficiency-first tier, then hand the steps where it repeatedly gets stuck to the deep-reasoning tier, forming a hybrid chain. This makes benefit attribution clear and makes it easier to gradually expand the use of the deep tier.
Acceptance can be recorded with the following structure:
{"task": "fix_known_bug","correct": true,"human_edits": 1,"cost": {"input_uncached": 12000, "input_cached": 48000, "output": 3500}}
6. Common Anti-Patterns
- Comparing only overall scores and not stages, leading to overpaying for simple stages;
- Counting only unit prices and not retries and human rework, appearing cheaper on paper but actually more expensive;
- Ignoring cache prerequisites and applying the cost advantage of high-hit scenarios to entirely new material scenarios;
- Lacking a regression set, making it impossible to tell whether a model capability update is an improvement or a regression.
7. Conclusion
The right approach to model selection is “stage-based + measurable + reversible.” In engineering practice on platforms such as Baidu AI Cloud, combined with logging services, monitoring and alerting, and containerized canary releases, the comparison experiments above can be solidified into a routine evaluation pipeline, so that every capability upgrade is backed by data rather than replaced on a hunch.
