LLM Model Selection: Routing Requests by Task Complexity
Choosing a single model for every use case usually hurts both cost and user experience. This article explains how to classify tasks into four complexity tiers, which capability metrics matter during model selection, and how to build a routing gateway with caching, rule-based dispatch, output validation, and fallback paths. It also covers building an evaluation set and common anti-patterns to avoid.
1. The Problem: “Which Model Is Better?” Is the Wrong Question
In engineering practice, teams often get stuck debating which model to pick. Abstracted properly, the real technical problem is not a binary choice but matching task characteristics to model capabilities. Different tasks place very different demands on reasoning depth, knowledge breadth, latency, context length, and output structure. Covering every scenario with one model often damages both cost efficiency and user experience.
The core criterion can be reduced to one question: does the task require multi-step reasoning? Knowledge questions (for example, the definition of a metric or the meaning of a term) are shallow retrieval tasks: they are latency-sensitive and require little reasoning. Advice-seeking questions such as “what should I do next?” are planning tasks: they require decomposing goals, enumerating constraints, comparing options, and assessing risks, which demands deeper reasoning and stronger context retention.
2. Task Tiers: A Classification Standard You Can Actually Encode
Do not rely on subjective judgment. Make task tiers explicit so they can be turned into rules and features.
- L0 Factual: definitions, units, thresholds, concept explanations. Short answers, high uniqueness, citable authoritative sources.
- L1 Transformation: format conversion, summarization, extraction, rewriting. Clear input/output structure, verifiable with validators.
- L2 Analytical: attribution, comparison, explaining metric anomalies. Requires integrating multiple sources, with several plausible explanations.
- L3 Planning: path selection, solution design, risk contingency. Incomplete goals, conflicting constraints, multiple rounds of clarification.
In practice, a lightweight classifier (keywords + rules + small-model scoring) can do the first pass, and uncertain samples can be escalated to a stronger reasoning pipeline, forming a cascade.
def route(task: str, ctx_len: int, need_json: bool) -> str:# Pseudocode: pick a capability tier by complexity and constraintsif need_json or len(task) < 120:return "fast_tier" # low-latency tierif ctx_len > 60000:return "long_context_tier" # long-context tierreturn "reasoning_tier" # deep-reasoning tier
3. Capability Dimensions: Six Metrics That Actually Matter
- Reasoning depth: whether the model keeps a consistent chain under multiple constraints without drifting.
- Latency and throughput: time to first token and output tokens per second directly shape the interaction experience.
- Context window and effective utilization: a large window does not mean effective use; watch key-information recall in long documents.
- Structured output stability: whether results reliably conform to a schema so downstream parsing works.
- Cost structure: input and output are usually billed separately, so long-document summarization and short Q&A have completely different cost profiles.
- Operability: whether logging, monitoring and alerting, rate limiting, and degradation are in place.
4. Routing Layer Design: Make Dispatch Part of the Infrastructure
Insert a unified gateway between business logic and models, responsible for five duties: authentication, rate limiting, caching, routing, and auditing. A practical routing strategy is “rules first, model fallback”:
- On a cache or semantic-cache hit, return directly at the lowest cost.
- On a rule hit (such as a pure definition question), use the low-latency tier.
- On a miss, enter the reasoning tier and allow multi-round clarification.
- Validate results (schema validation, factual-citation validation) before returning.
User request -> Gateway (auth/rate limit) -> Semantic cache-> Rule classification -> Low-latency tier / Reasoning tier-> Output validation -> Logging and monitoring -> Response
5. Evaluation: No Evaluation, No Selection
Build a business evaluation set of at least 200 items covering all four tiers, and fix three metrics: task success rate, average latency, and cost per task. Separate “automatically judgeable” checks (format, fields, numeric values) from “requires human sampling” checks (reasonableness of advice). Every time you adjust routing thresholds or prompts, run a regression to avoid experience rollback.
6. Common Anti-Patterns
- Sending every request to the strongest reasoning tier: cost spirals and latency becomes unacceptable.
- Looking only at context window size while ignoring key-information recall in long documents.
- Missing output validation, causing frequent downstream errors in structured parsing.
- No fallback path, so a single hiccup in the primary pipeline takes everything down.
7. Recommendations and Conclusion
First build the task tiers and evaluation set, then introduce the routing gateway, and finally tune thresholds continuously with monitoring data. If your organization already uses relevant general capabilities from Baidu AI Cloud, you can combine the gateway with general services such as logging, monitoring and alerting, and object storage to form an observable, rollback-capable engineering loop. The conclusion: there is no universally better model, only the capability combination that best matches task complexity, latency budget, and cost constraints.
