The Cost per Task: A New Perspective on LLM Inference Evaluation
Beyond public leaderboards, teams need a metric that answers what it actually costs to complete a unit of work. This article explains why cost per task matters, how to break it down into input, output, loop, and human review components, and how a dual-version model strategy enables risk-based routing. It also provides a practical checklist for reducing costs through context governance, prompt layering, structured constraints, caching, observability, and elastic capacity, along with common pitfalls to avoid.
Introduction: Beyond the Leaderboard, There Is a Real Bill
When evaluating a large language model, teams usually focus on public leaderboards: how many more math problems it solved, or how many percentage points its code generation score improved. These metrics are useful, but they answer “can the model do it” rather than “what does it cost to finish one task.” As models move from demos into production, the second question often determines whether scaling is viable.
A cloud vendor recently released a new-generation model with a dual-version strategy: one version targets complex reasoning and professional work, while the other emphasizes response speed, invocation cost, and everyday tasks. Both versions became available through the API and in scenarios such as intelligent coding and office collaboration. Public materials note that in a comprehensive evaluation for agentic tasks, the reasoning version improved by about five percentage points over the previous generation, while the cost of completing a single task dropped to less than one-third of the original—a cost reduction clearly larger than the drop in API unit price.
This mismatch in reduction rates is the technical core of this article.
1. Why Cost per Task Is the Key Metric
Cost per task refers to the total compute cost required to complete one acceptance-ready business task, usually normalized per thousand or per ten thousand tasks. Its relationship with API unit price can be roughly written as:
cost per task ≈ total tokens per task × unit price= (input tokens + output tokens + retry and tool-return tokens) × unit price
Unit price decreases linearly, but total tokens per task fluctuate nonlinearly as model capability changes. An underpowered model often behaves as follows: it fails on the first attempt, so it retries; instruction following is unstable, so it repeatedly sends the entire context back; structured output is unreliable, so post-processing is needed to fix it. All of these can multiply actual token consumption. Therefore, a 30% drop in unit price combined with total cost falling below one-third is mathematically valid—the difference comes from “taking fewer wrong turns.”
It is important to note that this conclusion depends on the specific evaluation scope. Discussing cost without defining the task is meaningless. In engineering, you must first fix the task set and acceptance criteria before comparing models.
2. Breaking Down the Cost: A Reusable Accounting Model
It helps to split cost per task into four segments to locate optimization points:
- Input side: system prompts, retrieved snippets, conversation history, and code repository context;
- Output side: final answers, structured results, and generated code and tests;
- Loop side: retries, self-verification, and tool-call result returns;
- Human side: the labor cost of review, rework, and prompt correction.
Illustrative accounting code:
def task_cost(in_tok, out_tok, retry=0, tool_rounds=0,price_in=1.0, price_out=3.0, unit=1e6):total_in = in_tok * (1 + retry) + tool_rounds * in_tok * 0.5total_out = out_tok * (1 + retry)return (total_in * price_in + total_out * price_out) / unit
Here, retry and tool_rounds are the two most overlooked variables that most affect the bill. Once they are included in the metric, teams will find that “the more expensive reasoning version actually costs less” is not uncommon.
3. Engineering Implications of the Dual-Version Strategy: Tiered Routing
Treat the “strong reasoning” and “fast and cheap” versions as layered compute rather than an either-or choice. A practical approach is risk-based routing by task:
- Low-risk, automatically verifiable tasks (format conversion, summarization, field extraction) go to the lightweight version;
- High-risk, long-chain tasks requiring multiple tool calls go to the reasoning version;
- For the middle ground, set a confidence threshold; low-confidence results are automatically escalated to the reasoning version for review.
The routing layer can be implemented with rules plus a lightweight classifier, with outputs unified as comparable structured results, making it easy to track the actual share and cost of each tier.
4. Implementation Checklist: Six Levers to Reduce Cost
- Context governance: deduplicate retrieved snippets and truncate by relevance to avoid sending the entire repository;
- Prompt layering: fix stable instructions at the system level to reduce per-turn repetition;
- Prioritize structured constraints: use schema constraints on output to reduce retries caused by parsing failures;
- Cache reuse: apply result caching and semantic caching for high-frequency similar requests;
- Observability: include token consumption, retry rate, and rework rate in logging services and monitoring dashboards;
- Capacity and elasticity: pair stateless inference services with container platform autoscaling, schedule batch jobs off-peak, and store cold data in object storage.
5. Common Pitfalls
- Looking only at unit price and ignoring the loop: a single retry can erase the unit price advantage;
- Replacing your own task set with public leaderboards: business distributions usually differ greatly from leaderboard distributions;
- Ignoring human rework: human review cost is often higher than compute cost;
- Switching everything at once: roll out gradually and compare before and after using the same task set.
Conclusion
When evaluating a new-generation large model, the most valuable question is not “how many points higher is it than the previous generation,” but “for the same task, how much did my bill and rework decrease.” Making cost per task a first-class metric, combined with tiered routing and context governance, turns capability upgrades into accountable engineering gains. If an enterprise already uses relevant general capabilities from Baidu AI Cloud (such as container platform, logging service, and monitoring alerts), it can connect the accounting model above directly to the existing observability system to form a continuously improving cost baseline.
