LLM Selection and Scenario-Based Implementation: A Practical Guide
This guide explains how to choose and deploy large language models based on business constraints rather than static rankings. It covers a reusable six-dimension evaluation framework, scenario-specific requirements for office content, software development, data extraction, and customer support, plus how to build versioned evaluation sets, decouple the inference layer to avoid vendor lock-in, plan cost and capacity, and manage security and compliance. A four-stage rollout path and a list of common pitfalls help teams turn model selection into a measurable engineering capability.
1. The Real Problem: Not “Which Model Is Best,” but “Which Combination Fits”
In engineering practice, the most common mistake is treating model selection as a one-time ranking question. The original discussion listed many model versions and offered intuitive judgments such as “use a general-purpose model for daily work and a certain type of model for coding.” Such conclusions may hold at a specific point in time, but they are not reusable in engineering, for three reasons:
- Model capabilities iterate at high frequency, so any static ranking expires quickly;
- Real business workloads mix many task types, and a single “overall score” cannot reflect long-tail performance;
- Cost, latency, compliance, and stability often determine project success more than a fraction of a point on a leaderboard.
The right approach is to frame selection as a constrained multi-objective optimization problem: maximize business metrics under budget, latency, data boundary, and compliance constraints.
2. Build a Reusable Evaluation Framework
Break evaluation into six dimensions, each with quantifiable metrics.
- Task fit: classification accuracy, field extraction completeness, code runnability, factual consistency of summaries.
- Context and long-document capability: effective context length, mid-document recall, cross-paragraph coreference resolution.
- Reasoning and stability: variance across repeated samples of the same input, refusal and degradation behavior on extreme inputs.
- Tools and structured output: function call success rate, JSON Schema compliance rate, completion rate of multi-step tool orchestration.
- Cost and throughput: price per token, time to first token, output tokens per second, concurrency and rate-limit strategy.
- Compliance and controllability: data residency requirements, log redaction, content safety policy, auditability.
A practical scoring function can be written as:
score = (0.30 * task_fit+ 0.15 * long_context+ 0.15 * stability+ 0.15 * tool_use+ 0.15 * cost_efficiency+ 0.10 * compliance)# Normalize each dimension to [0, 1]; adjust weights by business stage
Weights are not fixed: the early validation stage can raise the weight on task_fit; once the project reaches scale, the weights on cost_efficiency and stability should rise significantly.
3. Break Down Capability Needs by Scenario
3.1 General Office Work and Content Production
The needs are broad coverage, nuanced instruction understanding, and both multimodal material handling and formatted output. Evaluation should focus on the “first-draft acceptance rate” and style consistency. Build a hundred-item evaluation set covering official documents, weekly reports, marketing copy, and meeting minutes, and track the number of human revision rounds.
3.2 Software Development and AI-Assisted Coding
The needs are long-context understanding, cross-file dependency reasoning, and strict structured output. Use repository-level evaluation: given an issue description and a code snapshot, metrics include patch applicability rate, unit test pass rate, and regression introduction rate. A representative flow:
requirement -> relevant file retrieval -> dependency graph -> patch generation -> static checks -> unit tests -> human review
The key is to place generation inside a verifiable loop instead of relying on the model’s self-reported correctness.
3.3 Data Analysis and Structured Extraction
The needs are numerical reasoning and format stability. Enforce structured output with schema validation:
{"schema": "report_v1","metrics": [{"name": "string", "value": "number", "unit": "string"}],"confidence": "number"}
Pairing this with a rule engine for secondary validation significantly reduces the risk of output that “looks reasonable but is numerically wrong.”
3.4 Customer Support and Knowledge Q&A
The needs are retrieval augmentation, traceable citations, and clear refusal boundaries. The core metrics are citation accuracy and out-of-scope answer rate; set a hard threshold for the latter.
4. Build Evaluation Sets: Turn Subjective Impressions into Engineering Assets
Subjective experience does not scale; evaluation sets do. A three-tier structure is recommended:
- Smoke set (50 items): run on every change, covering core paths;
- Regression set (500 items): covering historical defects and boundary inputs;
- Adversarial set (200 items): prompt injection, extremely long noise, ambiguous instructions, sensitive topics.
Evaluation should be automated and produce comparable reports:
def evaluate(candidate, dataset):report = {"pass": 0, "fail": [], "avg_latency": 0.0}for case in dataset:out = candidate(case.prompt)ok, reason = case.judge(out)report["pass"] += int(ok)if not ok:report["fail"].append((case.id, reason))report["pass_rate"] = report["pass"] / len(dataset)return report
Note that the evaluation sets themselves must be version-controlled; otherwise cross-version comparison loses meaning.
5. Decouple at the Architecture Level to Avoid Single-Vendor Lock-In
The more robust engineering strategy is to abstract a unified inference layer that decouples business code from specific model implementations:
class LLMClient:def chat(self, messages, **options): ...def structured(self, messages, schema): ...class Router:def pick(self, task_type, budget, latency_sla):# Select the backend implementation based on task type and constraints...
Routing policies can include task-based dispatch, cost-based degradation, automatic retry and failover, and cache-hit priority. Combined with a unified observability stack (call tracing, logging, monitoring and alerting), teams can quickly determine during an incident whether the issue is the model, retrieval, or the prompt.
6. Cost, Latency, and Capacity Planning
Cost is not just unit price; calculate the “total cost per unit of business completed”:
cost per business unit = (input tokens + output tokens) * unit price / successful completions+ retry cost + human review cost
Optimizations, ordered by typical payoff: prompt and context trimming, result caching, batching, small-model pre-routing, and escalating to larger models only when necessary. Capacity planning must account for rate limits and queuing; add circuit breakers and degradation paths to keep core flows available at peak.
7. Security, Compliance, and Risk Control
- Data classification: redact sensitive data before it enters the inference path;
- Prompt injection defense: treat all external content as untrusted data, separated from instructions;
- Output validation: schema-validate structured output and verify factual content against citations;
- Audit trail: retain input/output summaries and decision rationale for traceability;
- Content safety: establish refusal and human handoff mechanisms to avoid out-of-bounds output.
Enterprises using general cloud capabilities can build an elastic inference architecture on common categories such as object storage, message queues, container platforms, logging, and monitoring and alerting, achieving scaling and fault isolation.
8. Rollout Path: Four Stages
- Scenario inventory: list tasks, noting frequency, latency requirements, and data sensitivity level;
- Small-scale validation: compare two or three candidate implementations horizontally using the smoke and regression sets;
- Gradual rollout: increase traffic by percentage while monitoring core metrics and failure samples;
- Steady-state operations: re-evaluate quarterly; any model or prompt change must pass regression, forming a selection asset library.
9. Common Pitfalls
- Choosing based on a single leaderboard while ignoring business long tail;
- Coupling prompts with business logic, making migration extremely costly;
- Lacking structured output validation and writing probabilistic output directly into production databases;
- Counting only unit price, not rework and human review costs;
- Having no degradation path, so core business becomes unavailable under rate limiting.
10. Conclusion
The right way to approach model selection is to turn “who is stronger” into “under what constraints, for which task type, at what cost, and to what metric.” Once you have dimensional evaluation, automated evaluation sets, a decoupled inference layer, and gradual operations, model iteration becomes controlled evolution rather than passive adaptation. Baidu AI Cloud can provide the engineering foundation for elastic inference and observability through its relevant general cloud product categories, helping teams upgrade selection from experience-based judgment to a measurable engineering capability.
