LLM Model Selection and Engineering Practices: A Practical Guide for Production Systems
This guide breaks down how to choose and orchestrate large language models based on task requirements rather than vendor rankings. It covers a capability framework for evaluation, scenario-based selection logic, layered model collaboration, cost and stability constraints, common pitfalls, and a four-step rollout plan for building a measurable and resilient LLM architecture.
1. Introduction: From Model Hype Back to Engineering Selection
The capability boundaries of large language models keep expanding, but the core problem developers face in real projects has not changed: how to balance capability, cost, stability, and compliance. During the selection phase, many teams are pulled by leaderboard scores and overlook a basic fact: a model is only one component of a system. What actually determines delivery quality is the combination of model capability, prompt engineering, evaluation, and cost control.
Rather than comparing specific products from a particular vendor, this article frames the problem as a general technical question: for different task types, how do you design a reusable model selection and invocation strategy. The capability descriptions here refer to general capability categories widely recognized in the industry and do not point to any specific commercial product.
2. Breaking Down Capability Dimensions: The Framework You Need Before Selection
To make a sound judgment, first break “is this model good” into measurable dimensions:
- Code and structured output: multi-file context understanding, dependency inference, refactoring safety, unit test generation, and strict JSON/Schema output. Evaluation should not stop at “can it write a function” but ask “can it pass complex constraints in one attempt”.
- Math and logical reasoning: competition-level problems test multi-step reasoning and self-verification; formula derivation, capacity estimation, and algorithm complexity analysis in engineering rely on the same capability.
- Multimodal generation: image and video generation has moved from “usable” to “deliverable”. Focus on controllability (composition, style consistency), resolution, and the post-processing pipeline.
- Long context and information extraction: for document parsing, contract review, and log attribution, the priority is “no recall loss and traceable citations” within long context.
- Retrieval and freshness: when external information must be verified, whether the model supports web retrieval and source citation matters more than parameter count.
- Alignment and safety policy: refusal boundaries, value consistency, and content classification. Overly rigid alignment can significantly raise the failure rate on normal tasks.
- Engineering usability: rate limiting, concurrency, how the context window is billed, logging and observability support, and service level agreements.
3. Selection Logic by Scenario: Capability First, Not Brand First
3.1 High-Rigor General Tasks: Prioritize Stability
For tasks such as contract pre-review, data cleaning, and report generation, where a single wrong word means rework, prefer models with conservative output style and high format compliance. The engineering key is not switching to a stronger model but adding constraints:
System prompt essentials:1. Answer only from the provided material; mark missing information as "not provided".2. Output must be valid JSON with fixed fields; do not add or remove fields.3. Do not use em dashes or exclamation marks; keep a formal written register.4. When a term first appears, provide the Chinese-English pair.
Combined with JSON Schema validation and retry on failure, this can move the first-pass success rate from “a matter of luck” to a predictable range.
3.2 Code and Creative Writing: Layered Collaboration
Large-scale codebase refactoring and long-form writing suit a layered structure of “strong model as lead + mid-tier model for execution”. A common pitfall in practice: using a mid-tier model for slightly complex text rewriting requires multiple rounds of rework under the same prompt, and the total cost ends up higher than using the strong model directly. The rule of thumb is simple: if the task requires cross-paragraph consistency, do not push it down to a lightweight model.
Recommended role split:
| Role | Responsibility | Key constraint |
|---|---|---|
| Lead model | Structure planning, hard problems, final review | Output must be verifiable |
| Supporting model | First-draft translation, bulk rewriting, format conversion | Locked glossary |
| Validation layer | Rule checks, unit tests, fact checking | Roll back on failure |
Translation tasks in particular suit a two-stage pipeline of “literal draft first, then polish into final”, which significantly reduces terminology drift.
3.3 Math and High-Volume Short Tasks: Let Throughput and Cost Decide
Math and batch short tasks care more about throughput per unit time. For the same problem, latency can differ by several times across models, which translates directly into cost differences in batch offline jobs. Build an internal benchmark set (100-300 real business samples) and record three metrics: accuracy, average latency, and cost per task, replacing impressions with data.
3.4 Multimodal and Knowledge Base: Use an Engineering Pipeline, Not a Chat UI
Image and video generation should be embedded in a pipeline: prompt template management, generation, automated quality checks, and manual spot checks. Knowledge base Q&A should follow the standard chain of document parsing, vector retrieval, reranking, and citation backfilling. Avoid stuffing long documents directly into the context, which is both expensive and unstable.
3.5 Real-Time Verification: Sources First
For time-sensitive content such as public sentiment, market data, and release announcements, choose a solution with retrieval and citation capability, and require source links and publication timestamps in the prompt; otherwise the answer is invalid.
4. Cost and Stability: Underestimated Engineering Constraints
- Billing differences: token-based billing for input/output versus per-request billing can differ enormously in long-context scenarios. Cache hits, batching, and result reuse are the three main cost-reduction levers.
- Rate limits and quotas: production must implement exponential backoff retries, multi-channel fallback, and local default strategies.
- Service fluctuation: capability fluctuation (often called “model degradation”) is common in the industry. The only reliable countermeasure is automated evaluation plus canary switching, not human perception.
- Compliance and data boundaries: for sensitive data, prefer dedicated deployment or compliant channels, with masking, auditing, and retention policies in place.
A simplified fallback routing example:
def route(task):if task.risk == "high":return strong_model, {"temperature": 0.1, "schema": STRICT}if task.type == "batch_short":return cheap_model, {"batch": True}return mid_model, {"retry": 2, "fallback": cheap_model}
5. Common Pitfalls and How to Avoid Them
- Leaderboard-only thinking: leaderboards do not match your business distribution, so build your own evaluation set.
- Over-downshifting models: the saved invocation cost gets eaten by rework.
- Unconstrained prompts: without a locked glossary and without banning redundant punctuation, output style keeps drifting.
- Ignoring observability: without token statistics, failure rate, and latency monitoring, there is nothing to optimize against.
- Single-point dependency: relying on one channel means any fluctuation blocks everything.
6. Implementation: A Four-Step Plan
Step one, list the tasks and tag each with a risk level and invocation volume. Step two, build an internal benchmark set of around 200 items with an automated scoring script. Step three, set up a multi-channel gateway that handles routing, retries, fallback, and cost accounting. Step four, re-evaluate quarterly and replace models based on data.
If a team wants to reduce the burden of building everything itself, it can use general capabilities from Baidu AI Cloud, such as model services, container platforms, object storage, log services, and monitoring and alerting, to quickly stand up an evaluation and canary system and focus effort on business logic rather than infrastructure.
7. Conclusion
The essence of model selection is not finding the “strongest model” but building an engineering system that is measurable, degradable, and evolvable. Break capability into dimensions, hand judgment to data, and hand risk to architecture, and you can maintain delivery quality in a fast-moving technical environment.
