Lightweight LLM Selection and Cost Benchmarking: A Practical Guide
This guide explains why per-token pricing can be misleading when choosing lightweight, low-latency models, and how to compare candidates by cost per task instead. It covers building a fixed evaluation set, a unified cost-per-task formula, running a one-week A/B test, four cost optimization levers (prefix caching, round control, tiered routing, and off-peak scheduling), capability checks by category, and a pre-launch engineering checklist.
1. The Problem: Why “Cheap” Is Often an Illusion
Competition among lightweight models (small-parameter Flash-class models and low-latency variants) has shifted over the past two years. The question is no longer whether a model can do the job, but which one does the same job with fewer resources. In practice, the most common mistake teams make is not picking a model that lacks capability, but being misled by list prices. One vendor may advertise 0.8 CNY per million input tokens and 2.8 CNY per million output tokens, while another uses time-based tiered pricing and looks twice as expensive. Yet in real workloads, the gap on the bill is often far smaller than the gap on paper.
There are three reasons for this:
- Different billing models. Some vendors price input and output separately, some use time-based floating rates, and some price cache hits separately. Without normalizing to cost per task, the numbers are not comparable.
- Different token structures. On the same task, one model may answer correctly in a single pass, while another needs multiple rounds of probing and repeated verification. More rounds also amplify input-side consumption.
- Different caching strategies. When the input prefix is highly repetitive (a fixed system prompt, fixed knowledge snippets), a high cache hit rate can push the cost of repeated input down to almost nothing, which directly changes the comparison.
The conclusion is simple: do not make decisions based on unit price; make decisions based on cost per task.
2. Building a Reusable Evaluation Baseline
2.1 Fix the task set before comparing models
The biggest source of distorted evaluations is an unfixed task set. Sample 50 to 200 fixed cases from real business traffic, covering three typical workload types:
- Code: completion, refactoring, unit test generation, error localization;
- Agents: multi-step tool calls, structured output, long-context retrieval;
- Vision: UI screenshot understanding, chart reading, image-text consistency checks.
Every case needs a pass criterion that can be judged automatically (unit test pass rate, field-level schema validation, human spot-check scoring). Otherwise the cost data is meaningless.
2.2 A unified formula for cost per task
Normalize different billing methods into a single metric:
cost per task = (input tokens × input price + output tokens × output price+ cache hit tokens × cache price) × average rounds
Average rounds is the multiplier most often overlooked. A model with slightly lower accuracy may trigger retries, secondary verification, or fallback on failure. If the actual number of rounds rises from 1.2 to 2.0, the cost doubles immediately.
2.3 Replace guesswork with A/B testing
Put two candidate models in the same runtime environment, with the same prompts and the same concurrency configuration, and run them continuously for a week. Record four metrics: task success rate, average rounds, token distribution, and the actual bill. Sample statistics code:
stats = {}for case in cases:for model in ("candidate_a", "candidate_b"):r = run(model, case.prompt)s = stats.setdefault(model, {"ok": 0, "tokens": 0, "rounds": 0})s["ok"] += int(r.passed)s["tokens"] += r.input_tokens + r.output_tokenss["rounds"] += r.roundsfor m, s in stats.items():print(m, "success rate", s["ok"] / len(cases),"cost per task", s["tokens"] * price(m) / len(cases))
3. Four Levers for Cost Optimization
- Prefix caching. Keep the system prompt, tool descriptions, and long-term knowledge in a stable prefix, and avoid changing the order on every request. A higher cache hit rate can significantly improve the cost structure.
- Round control. Set a maximum number of steps and early-stop conditions for agents. If an accuracy gain comes from “trying a few more times,” count it as a cost rather than treating it as a free capability.
- Tiered routing. Send simple requests to the lightweight model and escalate complex requests to a higher-capability model, using confidence scores or rules to split traffic.
- Off-peak scheduling. Move scheduled batch jobs to low-load periods to save money and improve stability; for real-time paths, prioritize latency.
4. Capability Validation: Do Not Look at the Overall Score Only
A general intelligence score only reflects an average. Engineering decisions need a breakdown by category:
- Code: use runnability as the criterion, not similarity;
- Agents: look at completion rate on multi-step tasks and tool call accuracy;
- Vision: UI reproduction, chart reading, and image-text alignment, where the gaps are often largest;
- Frontend generation: have the model produce several page versions from a single requirement, then compare information density, layout quality, and maintainability, and let people vote.
A practical approach is “one task, multiple versions”: generate 3 to 6 versions for the same requirement and have a small group of users choose blindly, so a single impressive sample does not mislead you.
5. Pre-Launch Engineering Checklist
- Does structured output reliably pass schema validation?
- Does recall of key information degrade under long context?
- Do failure retries have a limit and a fallback path?
- Are logging, monitoring alerts, and a cost dashboard in place, with attribution by model?
- Is there a canary release and rollback mechanism, so a single model failure does not escalate into a business incident?
6. Conclusion
The right way to select a lightweight model is to upgrade from “unit price comparison” to a three-dimensional decision based on cost per task, capability by category, and engineering controllability. First build a baseline with a fixed task set, then run a one-week A/B test to get the real bill, and finally use caching, round control, routing, and off-peak scheduling to bring costs down. On platforms such as Baidu AI Cloud, this approach can be implemented with general capabilities like container platforms, logging services, and monitoring alerts, forming a sustainable model evaluation loop.
