Benchmarking Cost and Quality of Multiple LLMs on a Unified Scale
This article explains how to evaluate and select large language models by measuring both quality and cost on a unified scale. It covers defining cost metrics, designing horizontal comparison tests, and executing three specific test tasks: long document extraction, reimbursement validation tool generation, and web search briefing.
1. Why Model Selection Requires Measurement
Once multiple models are connected to a shared quota pool, the question shifts from “Can it complete the task?” to “Which model completes it more cost-effectively?” Variations in model capabilities, billing multipliers, and quota consumption methods make experience-based judgments prone to error.
Two common biases exist in model selection. The first is choosing solely by the lowest unit price, which increases rework and ultimately raises total costs. The second is defaulting to the most powerful model, ignoring that many tasks do not require advanced capabilities. The solution is to place quality and cost into a single metric and test them using the same set of tasks.
Platform multipliers, off-peak discounts, and free-tier rules should be based on official documentation. Before testing, verify three fields: multiplier, discount time window, and free-tier conditions, and take screenshots for future review.
2. Cost Metrics: Defining the Baseline
The formula for the cost per unit of qualified output is as follows:
Cost per qualified output = Average quota consumed per task ÷ First-pass success rate
The specific metrics are defined below:
- Average quota consumed per task: Execute the same task N times, record the actual quota deducted each time, and take the arithmetic mean. If fluctuations are high, report the standard deviation simultaneously.
- First-pass success rate: Successful executions ÷ total executions for that model. “Success” means the output can be used directly without human modification.
- Rework: Outputs that fail require human editing. This article does not convert rework into quota costs but separately logs human modification minutes to compare alongside quota costs.
- Auto-select mode: Bill based on the model actually routed by the system, recording the actual model each time to avoid attributing auto-mode results to the wrong model.
- Models with a zero percent success rate cannot compute this metric and should be marked as unavailable.
3. Test Design: Horizontal Comparison Using the Same Tasks
Horizontal comparison requires three conditions: first, identical input materials and prompts; second, objective pass/fail criteria for each output; third, sample coverage of varying difficulty levels.
This article designs three task types. Each task uses three fixed models and the auto-select mode once, totaling four runs per task type and twelve runs overall. Since single executions are affected by randomness, it is recommended to repeat each configuration at least three times to observe fluctuations before drawing conclusions.
The test log should include the following fields:
| Field | Description |
|---|---|
| Task ID | Task 1, Task 2, or Task 3 |
| Mode | Fixed model or Auto-select |
| Actual Model | The model actually called by the system in auto mode |
| Execution No. | The execution sequence number for the same configuration |
| Quota Consumed | The actual value deducted from the quota pool |
| Pass/Fail | Judged based on the evaluation criteria for this task |
| Rework Minutes | Time spent on human modification for failed outputs |
The summarized results can use the following table:
| Model | Avg. Quota Consumed per Task | First-pass Success Rate | Cost per Qualified Output |
|---|---|---|---|
| TBD | TBD | TBD | TBD |
4. Task 1: Long Document Extraction and Structuring
The material for this task is a mock financial report of about twenty pages. The task is divided into two parts. Part 1 is a summary of no more than 800 words, covering business performance, reasons for revenue and profit changes, profit quality, cash flow and accounts receivable risks, and significant post-report events. Part 2 is a key metrics table, including operating revenue, net profit attributable to shareholders, non-recurring net profit, net cash flow from operating activities, R&D investment and its percentage of revenue, and accounts receivable. Each item must list two years of figures, YoY changes, and original page numbers.
During evaluation, check the following four criteria item by item. All four must pass for the output to be considered qualified:
- Number accuracy: Check against the original text item by item; values, units, and years must not be mismatched.
- Page traceability: Page numbers must match the original text so readers can quickly verify.
- Word count constraint: A summary exceeding 800 words is unqualified.
- Inference boundary: Reasons not explicitly stated in the original text must be marked as inferences.
In the sample test for this article, multiple models met all requirements. When quality converges, cost becomes the main differentiator. For structured tasks that can be mechanically verified, low-multiplier models are usually sufficient, so there is no need to default to high-tier models. Readers should still base decisions on their own test data.
5. Task 2: Reimbursement Validation Tool
The difficulty of this task lies in rule design and amount handling, while the interface is relatively simple. The core design includes four parts:
- Amount representation: Store amounts as integer cents to avoid floating-point rounding errors. Inputs should only accept strings with a maximum of two decimal places.
- Rule configuration: Category limits and approval thresholds should be written into a configuration table, not scattered within the judgment logic.
- Duplicate detection: If an invoice number exists, use it for deduplication; otherwise, use the combination of “date, merchant, amount”.
- Audit trail: Record the input, rule version, and conclusion for each validation to facilitate post-event traceability.
The following example can be run directly, but it is for demonstration purposes only. The values do not represent any corporate policy or tax regulations.
import copyfrom decimal import DecimalRULE_VERSION = "demo-2026.11"# Example configuration, values are for demonstration onlyRULES = {"dining": {"daily_limit_cents": 30000, "single_approval_threshold_cents": 50000},"transport": {"daily_limit_cents": 50000, "single_approval_threshold_cents": 100000},}def to_cents(text: str) -> int:"""Convert amount string to integer cents, rejecting negative numbers and inputs with more than two decimal places."""value = Decimal(text)if value < 0 or value != value.quantize(Decimal("0.01")):raise ValueError(f"Invalid amount format: {text}")return int(value * 100)def dedup_key(item: dict) -> tuple:"""Deduplicate by invoice number if available, otherwise by date, merchant, and amount combination."""if item.get("invoice_no"):return ("invoice", item["invoice_no"])return ("combo", item["date"], item["merchant"], item["amount_cents"])def check_claim(items: list, audit_log: list | None = None):"""Validate a reimbursement claim, return (passed, errors), and optionally write to audit log."""errors = []seen = set()daily_totals = {}for idx, item in enumerate(items, start=1):category = item["category"]if category not in RULES:errors.append(f"Item {idx}: No rules configured for category {category}")continuetry:cents = to_cents(item["amount"])except (ValueError, ArithmeticError) as exc:errors.append(f"Item {idx}: {exc}")continuerule = RULES[category]if cents > rule["single_approval_threshold_cents"]:errors.append(f"Item {idx}: Exceeds single approval threshold, manual approval required")key = dedup_key({**item, "amount_cents": cents})if key in seen:errors.append(f"Item {idx}: Possible duplicate {key}")seen.add(key)day_key = (item["date"], category)daily_totals[day_key] = daily_totals.get(day_key, 0) + centsfor (day, category), total in daily_totals.items():if total > RULES[category]["daily_limit_cents"]:errors.append(f"{day} {category}: Daily total exceeds limit")passed = not errorsif audit_log is not None:audit_log.append({"rule_version": RULE_VERSION,"input": copy.deepcopy(items),"passed": passed,"errors": errors,})return passed, errorsif __name__ == "__main__":log = []claims = [{"category": "dining", "date": "2026-11-20", "merchant": "Example Restaurant","amount": "123.40", "invoice_no": "A001"},{"category": "dining", "date": "2026-11-20", "merchant": "Example Restaurant","amount": "123.40", "invoice_no": "A001"},]ok, errs = check_claim(claims, log)print(ok, errs)
Note the following before using this code:
- The demo code cannot be used directly in production. Before deployment, test cases must be added to cover boundary amounts, cross-day totals, missing fields, and illegal strings.
- Official reimbursement standards should be based on corporate financial policies and current tax regulations. The configuration table should be confirmed by the finance lead.
- Invoices and reimbursement data contain personal and merchant information. Audit logs must be desensitized and have access permissions configured.
- Amount calculations must only use integer cents. Convert to dollars/yuan only for display; do not use floating-point numbers for accumulation.
6. Task 3: Web Search Briefing
This task requires the model to generate a briefing based on specified public sources. Before testing, fix a set of web pages and save snapshots; otherwise, page updates will make results from different executions incomparable.
The task requires generating a briefing of no more than 500 words. Each conclusion must be accompanied by a source link and publication date, and must distinguish between factual statements and opinions. The criteria are as follows:
- The source is accessible and its content supports the corresponding conclusion.
- The cited date matches the original text.
- Conclusions without sources are directly marked as failed.
- When there are conflicts among sources, they must be explicitly flagged rather than arbitrarily adopting one.
Web task results are highly susceptible to the search path. In auto-select mode, both the actual model and search results may change for the same task, so the number of repetitions for this category of tasks should be appropriately increased.
7. Tiered Selection Checklist
- Layer by task structure: For tasks that can be mechanically verified, test low-multiplier models first; for tasks requiring comprehensive judgment, proceed with further evaluation based on higher-tier models.
