How to Evaluate LLM Inference Quality and Cost
A practical guide to evaluating large language models beyond benchmark scores. It covers a four-metric framework (accuracy, latency, token usage, and cost per 1,000 calls), how to define measurement rules, how to interpret version-to-version changes, why domain-level breakdowns matter more than aggregate scores, how to compare models within the same cost tier, and a checklist for model selection and cost optimization.
1. Why a High Benchmark Score Does Not Mean Production Readiness
When teams evaluate models for enterprise applications, they often run into an awkward situation: a model ranks near the top of a public leaderboard, but once it is wired into a real business workflow, it either responds too slowly or produces a bill that blows the budget. The root cause is that a single accuracy metric cannot describe real service capability. A usable evaluation framework has to answer four questions at the same time:
- Quality: how many questions it gets right on your target corpus;
- Latency: how long a single call takes on average;
- Consumption: how many tokens a single call consumes on average;
- Cost: how much you actually spend per 1,000 calls.
Only when all four categories of metrics sit in the same table can you tell whether a “version upgrade” is a net gain or simply shifts cost onto the business side.
2. Defining the Metrics: Set the Rules Before You Start
Whether an evaluation result is trustworthy depends mostly on how rigorous the definitions are. It is worth locking down the following before you begin:
- Test set size and distribution: the sample must be statistically meaningful (tens of thousands of questions is common) and reflect the real business distribution, rather than cherry-picking easy questions;
- Accuracy: correct answers / total questions, with the scoring method made explicit (exact match, rule-based validation, or model-as-judge);
- Average latency: measured from the moment the request is sent until the full response finishes, including queueing and network overhead;
- Average tokens: the sum of input and output tokens, which reflects inference complexity;
- Measured cost: expressed as “CNY spent per 1,000 calls,” which reflects the real bill better than unit price alone.
A schematic evaluation loop might look like this:
def run_eval(model_client, dataset):total, correct, tokens, latency = 0, 0, 0, 0.0for item in dataset:resp = model_client.call(item.prompt)correct += judge(resp.text, item.answer)tokens += resp.usage.total_tokenslatency += resp.elapsed_secondstotal += 1return {"accuracy": correct / total,"avg_latency": latency / total,"avg_tokens": tokens / total,"cost_per_1k": tokens / total * price_per_token * 1000,}
3. Version Comparison: The Four-Quadrant Shift From a Single Upgrade
Consider two adjacent versions of a model evaluated on the same Chinese benchmark (the numbers illustrate the method and are not a conclusion about any specific product):
| Metric | Previous version | New version | Change |
|---|---|---|---|
| Accuracy | 68.1% | 71.5% | +3.4pp, rank moves from 16th to 5th |
| Average latency | 59s | 96s | roughly +63% |
| Average tokens | 2851 | 3922 | +37.6% |
| Cost per 1,000 calls | CNY 37.6 | CNY 52.5 | roughly +40% |
Three general patterns emerge:
- Quality gains are often bought with a longer chain of thought. The 37.6% rise in token consumption suggests the new version prefers to reason before answering;
- Latency is highly correlated with tokens. Tokens rose by about 40% while latency rose by more than 60%, showing that long outputs amplify wall-clock time even more;
- Cost can go up even when unit price stays flat. With output unit price unchanged, cost still rises linearly with tokens, which is the most easily overlooked billing trap.
4. Domain Breakdown: Capability Structure Matters More Than the Total Score
An aggregate score only reflects an average. What really determines whether a model can go live is whether its fine-grained capabilities match the scenario:
- Reasoning and math: 66.7% → 72.7% (+6.0pp), the most significant gain, suitable for data analysis and logic validation tasks;
- Education: 46.9% → 52.0% (+5.1pp), still in a weak range and to be used cautiously in high-stakes steps such as automated grading;
- Healthcare and mental health: 77.6% → 83.6% (+6.0pp);
- Finance: 77.7% → 84.2% (+6.5pp), the largest increase;
- Language and instruction following: 64.6% → 69.3% (+4.7pp);
- Agents and tool calling: 69.9% → 68.1% (-1.8pp), the only category that declined.
The engineering takeaway is direct: when a model allocates more of its “budget” to internal reasoning, capabilities that require strict formatting and short decision chains, such as tool calling, may get squeezed. If workflow automation is the core of your business, tool-calling accuracy should be a veto metric rather than being judged by the overall ranking alone.
5. Cross-Model Comparison: Only the Same Cost Tier Is Comparable
Comparing accuracy across different cost tiers is meaningless. The right approach is to bucket models by measured cost first, then compare quality and latency within the same tier. For example, in one evaluation two models both landed in the “about CNY 50 per 1,000 calls” tier with the same 71.5% accuracy, and the difference showed up in response time (96s vs. 72s). This means:
- Same score, different speed means a very different experience, so interactive products should favor the lower-latency option;
- Offline batch processing can tolerate high latency, so accuracy and cost should take priority there;
- Rankings (5th vs. 6th) have limited reference value when scores are tied and should not be the main basis for a decision.
6. An Actionable Selection and Optimization Checklist
- Build your own business evaluation set, with size and distribution aligned to production traffic, instead of copying public leaderboards directly;
- Layer the metrics: set separate thresholds for quality metrics (accuracy, per-domain scores), efficiency metrics (latency, tokens), and cost metrics (spend per 1,000 calls);
- Control cost with prompting and decoding strategies: compress context, cap maximum output length, and route simple requests to a smaller model or a cache;
- Introduce a routing mechanism: split traffic to different model sizes by task difficulty to balance the bill and quality;
- Build a regression dashboard: run the same evaluation on every model or prompt change and watch for drift across the four quadrants;
- On Baidu AI Cloud, you can combine monitoring and alerting, log services, and container platforms to host evaluation jobs, enabling scheduled runs and a cost dashboard.
7. Conclusion
Whether a version upgrade is worth shipping depends on whether the quality gain covers the increase in latency and cost. The four-metric framework, domain breakdown, and same-tier comparison described here help teams turn a vague “it feels stronger” into an engineering decision that is quantifiable, reproducible, and auditable.
