LLM Model Selection and Task Routing: An Engineering Playbook
A practical guide to treating large language model selection as a continuous routing and evaluation problem rather than a one-time purchase. Learn how to build layered evaluation sets for document, code, and batch workloads, why all-constraints pass rate and real billing cost matter more than leaderboard scores, and how to implement a routing layer with fallback policies, observability, and cost dashboards.
1. The Problem: Why Model Selection Becomes an Engineering Task During Dense Release Cycles
The large language model space has entered a period of dense releases: within roughly ten days, multiple vendors shipped seven new models. For developers and enterprise users, the real question is no longer “which model is the strongest,” but “which combination is the cheapest and most stable for my workload.”
The most valuable lesson from hands-on experience is simple: do not pick one model — use them separately. Abstracted further, this leads to a more general conclusion: model selection is not a one-time procurement decision, but a continuously running routing and evaluation problem. It is governed by three variables:
- Task type (generation, reasoning, execution, batch processing);
- Quality constraints (whether human rework is acceptable, and how costly errors are);
- Cost structure (not the sticker price, but the bill).
Note that this article does not benchmark any specific product. All scores, rankings, and benchmark names mentioned are background information only; the focus is on the method itself.
2. Define Metrics First: Why Leaderboard Scores Cannot Drive Decisions Directly
Third-party aggregate leaderboards typically report a single composite score — for example, one model at 70.2 ranked first, another at 68.3 ranked second, a third at 68.0 ranked fourth, and another at 64.4 ranked thirteenth. The gaps are generally within a few points.
The problem with these composite scores:
- Invisible weights: Leaderboards blend reasoning, code, math, and multi-turn dialogue into one weighted score, while your business may rely on only one of them.
- Saturation effect: Differences among top models on general tasks are compressed to noise level; a few points is often smaller than the variance between two runs of the same model.
- Missing deliverable definition: Most leaderboards score “roughly correct answers,” whereas real delivery requires “all constraints satisfied simultaneously.”
The recommendation is to treat leaderboards as a coarse filter, used only to narrow the candidate set from dozens to three or five. The final decision must rely on a self-built evaluation set.
3. Layered Evaluation Sets: Split the Business into Three Task Types
A directly reusable split is to divide the workload into three categories, each with its own dataset and its own scoring.
| Task Layer | Typical Scenarios | Cost of Error | Key Metrics |
|---|---|---|---|
| Document | Proposals, first drafts of contracts, analysis reports | Very high (one wrong number is an incident) | All-constraints pass rate, citation accuracy |
| Code | Refactoring legacy projects, writing scripts, agents running tests | Medium-high (can be caught by tests) | Unit test pass rate, first-compile success rate |
| Batch | Hundreds of copy items, summaries, classifications per day | Low (sampling inspection is enough) | Cost per item, throughput, format compliance rate |
The evaluation sets do not need to be large: 30–50 real historical samples per layer is enough, but you must retain the original inputs and human acceptance criteria, otherwise results cannot be reproduced.
4. Document Layer: All-Constraints Pass Rate Is the Only Valid Metric
In hands-on testing, the same twenty-plus-page cooperation agreement and the same prompt produced a clear divergence between two models: one aligned risk points by clause number, provided before-and-after comparisons, and proactively flagged items as “uncertain, requires human decision”; the other had good structure and language but mixed up two clause numbers and wrote a repealed older formulation into the output as if it were current.
Errors like these show that the scoring function for document tasks cannot be “similarity”; it must be all-constraints pass rate — a result passes only if all of the following hold:
- Every cited number maps one-to-one to the source text;
- No invalidated or outdated wording is introduced;
- Uncertain items are explicitly flagged rather than “completed” by the model;
- The output structure can enter downstream workflows directly.
In commonly used legal deliverable benchmarks, pass rates under a strict all-constraints definition are often only in the single digits to low teens (for example, on the order of 15.0% versus 7.2%). This contrasts sharply with the subjective impression that “everything looks well written,” and explains why the document layer must be evaluated separately.
A lightweight checker can automate this kind of metric:
def check_document_delivery(citations, source_map, uncertain_flags):# 1. Every citation must exist in the source and match its contentfor cid, text in citations.items():if source_map.get(cid) != text:return False, f"citation mismatch: {cid}"# 2. Citations to clauses marked as invalidated are not allowedif any(cid in source_map["deprecated"] for cid in citations):return False, "deprecated clause cited"# 3. Uncertain items must be declared explicitly, not filled in by the modelif uncertain_flags < 1 and len(citations) > 5:return False, "no uncertainty declared"return True, "pass"
5. Code Layer: Let Tests Score, Not Gut Feeling
Code tasks have a natural advantage: an objective judge exists. The recommended evaluation flow:
- Prepare a runnable repository snapshot with a locked dependency file;
- Have the model produce a patch using a fixed prompt;
- Run the build and unit tests inside an isolated container;
- Record first-pass rate, average repair rounds, and the number of “out-of-scope operations” when an agent runs autonomously.
For scenarios such as “let the model operate a computer / run an agent autonomously,” the extra focus is on permission boundaries: whether it reads and writes only within the working directory, whether it triggers irreversible commands, and whether timeouts and rollbacks exist. These are security design concerns, independent of model strength, but they directly determine whether the system can go to production.
6. Batch Layer: The Bill Is the Real Cost
The most counterintuitive and most important point in the original text: the reason to keep a model is not that its sticker price is lower, but that its bill is lower. In batch tasks, cost is the product of four factors:
total cost ≈ calls × avg input tokens × input price+ calls × avg output tokens × output price+ rework rounds × cost per call+ hidden cost of failed retries and rate-limit waiting
A model with a higher unit price but a high first-pass rate is often cheaper than a low-priced model that needs two rounds of rework. Therefore the batch layer must record both quality and bill; optimizing only one of them leads to wrong decisions.
Illustrative accounting logic:
def evaluate(task, model):out = model.run(task.prompt)ok = task.verify(out) # objective verification, not visual inspectioncost = model.usage_cost() # input/output tokens and call countreturn {"pass": ok, "cost": cost, "latency": model.last_latency}
7. Routing Architecture: Turn the Conclusions into Runnable Components
Solidifying the evaluation results into a routing layer is the final engineering form of this method:
- Entry classifier: Perform lightweight intent recognition first, tagging requests as document / code / batch;
- Primary and backup strategy: The document layer routes to the model that prioritizes rigor, the code layer to the model that prioritizes tool calling and execution ability, and the batch layer to the model with the lowest unit cost and compliant formatting;
- Fallback and escalation: Low-confidence requests are automatically escalated to a stronger model or handed to a human;
- Observability: Connect logging services and monitoring alerts, with dashboards and threshold alerts for pass rate, rework rate, and cost per task;
- Elasticity and data plane: Use a message queue to smooth peaks for batch tasks, store intermediate artifacts in object storage, and run evaluation and inference on a container platform for easy horizontal scaling.
Pseudocode:
def route(req):kind = classifier(req) # document / code / batchplan = POLICY[kind] # primary model + fallback model + thresholdsr = plan.primary(req)if not r.confident and r.risk == "high":r = plan.fallback(req) # escalate to a stronger modelif kind == "batch":queue.put(r) # async peak shaving, accountable costlog(r, plan) # feed monitoring and billing dashboardsreturn r
8. Common Pitfalls
- Replacing evaluation with leaderboards: A few points of difference is often swallowed by noise in real tasks.
- Comparing unit price instead of the bill: Rework and retries are the main sources of the bill.
- One model for everything: The optimal choice differs per task layer, and routing costs far less than trial and error.
- Ignoring uncertainty expression: A model that “says it knows when it does not” is the highest-risk failure mode in document and compliance scenarios.
- No objective judge: Code relies on tests, documents on checkers, batch on sampling inspection; missing any one of them is unsustainable.
9. Implementation Checklist
- Prepare 30–50 real samples and acceptance scripts per layer;
- Establish three core metrics: all-constraints pass rate, first-pass rate, and cost per task;
- Launch the routing layer and fallback strategy, starting with a 10% canary of traffic;
- Connect logging, monitoring alerts, and the cost dashboard, reviewing thresholds weekly;
- Re-run the evaluation sets every quarter; not re-selecting after model iterations is the same as never selecting.
The conclusion is clear: in a stage of oversupplied model capacity, competitiveness comes from the evaluation and routing system, not from betting on a single model. Build the evaluation sets, the routing layer, and the cost dashboard, and model selection turns from a one-time gamble into a continuously optimizable pipeline.
