LLM Selection and Engineering Practice: A Practical Evaluation Guide for Production Systems
Once large language models move from demos into production, the real question is no longer "which model is the best" but "which combination of models and engineering strategies is the most reliable under specific business constraints." This guide explains how to turn model selection into a measurable, regression-testable, and governable engineering process. It covers scenario profiling, key evaluation dimensions—task quality and stability, context utilization, tool calling, cost, latency, compliance, and version management—along with evaluation methodology, a unified model gateway architecture, and governance practices for common use cases such as coding assistance, writing, data analysis, and knowledge Q&A.
LLM Selection Is Multi-Objective Optimization Under Scenario Constraints
After LLMs enter the engineering and deployment stage, the core question teams face is no longer “which model is the strongest” but “which combination of models and engineering strategies is the most stable under specific business constraints.” Different models differ noticeably in general capability, code tasks, long-context handling, multimodal understanding, tool calling, cost and latency, and release cadence. Selection must start from the scenario, turning vague impressions into a measurable, regression-testable, and governable engineering system.
There is no single optimal LLM. General-purpose models usually work well as the default entry point of a workflow, covering writing, Q&A, analysis, and simple programming. Models with strong specialized capabilities may perform better at code generation, structured extraction, or multimodal tasks, but require additional evaluation of supply stability, versioning policy, cost, and compliance boundaries. Before selecting, build a scenario profile: task type, input/output length, real-time requirements, cost of failure, budget ceiling, data sensitivity level, and whether tool calling and external knowledge retrieval are needed. Only by making these constraints explicit can you decompose “strong overall performance” into comparable metrics.
Key Evaluation Dimensions
1. Task Quality and Stability
Quality should not be judged from demo cases alone. Use an offline evaluation set that covers the real distribution, combining automatic metrics with human blind review. For code tasks, focus on runnability, test pass rate, defect density, and maintainability; for writing tasks, on factual consistency, structural completeness, and style controllability; for structured extraction, on field-level accuracy and miss rate. Stability matters too: variance across multiple runs on the same input, performance on long-tail samples, and regressions after version upgrades.
2. Context Utilization and Knowledge Boundaries
For long documents, don’t rely on the nominal context length. Evaluate effective information utilization, citation and traceability capabilities, and robustness to noise. For time-sensitive knowledge, use retrieval-augmented generation (RAG) to bring in external material and require traceable citations in outputs. In knowledge Q&A scenarios, also evaluate refusal capability so the model does not fabricate answers when evidence is insufficient.
3. Tool Calling and Structured Output
Engineering systems usually need the model to select tools, generate valid parameters, and handle errors. Evaluate tool-selection accuracy, parameter validity, multi-step task success rate, and error recovery. Structured output should be safeguarded with constraint validation and retry mechanisms. A sample routing logic:
function select_model(request):if request.compliance_level == "high":candidates = controlled_deployment_model_setelse:candidates = general_model_poolif request.type == "code_generation" and request.complexity == "high":candidates = candidates.sort_by(code_eval_score, stability, cost)else if request.type == "low_risk_summary":candidates = candidates.sort_by(cost, p95_latency)else:candidates = candidates.sort_by(overall_quality, stability)return candidates.first_available()
4. Cost, Latency, and Throughput
Cost is not just the per-call price. Compute total cost per task, including retries, human review, cache hits, and degradation overhead. Focus on P95 latency rather than averages, and evaluate concurrency limits and queuing policies. Low-risk tasks can be routed to smaller models, escalating high-complexity tasks to stronger ones.
5. Compliance, Control, and Auditability
Data residency, log anonymization, content safety, permission isolation, and audit trails must be part of the evaluation. For highly sensitive scenarios, prefer controlled deployment or dedicated environments, and clarify accountability boundaries for outputs.
6. Version and Supply Stability
Models iterate quickly. Teams should pin versions, establish change notifications and regression gates, and run dual versions in parallel with fast rollback. Supply stability also covers service availability, quotas, regional coverage, and the risk of product policy changes—never bind critical business to a single uncontrollable path.
Evaluation Methodology and Engineering Architecture
Build a “golden set” for evaluation: sample and anonymize from real business data, covering both high-frequency and long-tail scenarios, with labeled expected outputs and acceptable boundaries. Use automatic scoring plus human blind review. Online, run A/B gray releases to observe task completion rate, human edit rate, average handling time, failure rate, and unit cost. Public leaderboards are a reference only and cannot replace business-specific evaluation. Set regression gates before release, and re-run the core set and red-team tests after version upgrades.
On the engineering side, build a unified model gateway that centrally handles authentication, quotas, routing, caching, logging, monitoring, and fallback. The gateway should log request IDs, model versions, prompt template versions, tool call chains, and costs for troubleshooting. Caching should distinguish identical requests from semantically similar ones, with attention to privacy and anonymization. Degradation strategies include timeout fallback, rate-limited queuing, and human takeover. At the infrastructure level, general capabilities such as object storage, logging services, monitoring and alerting, and container platforms—such as those offered by Baidu AI Cloud—can be used to build the evaluation and gateway foundation.
Typical Scenarios and Governance Recommendations
For coding assistance, evaluate code completion, unit test generation, refactoring, and review capabilities, focusing on compile pass rate, test pass rate, security vulnerabilities, and maintainability, with human review retained. For writing and office scenarios, focus on fact-checking, citation integrity, and template controllability. For data analysis, evaluate structured extraction, query generation, and result explanation. For multimodal generation, consider quality, copyright, and content safety together. For knowledge Q&A and customer service, combine retrieval, citation, refusal, and emotional-compliance policies.
At the organizational level, model selection is not a one-time purchase but a continuous governance process. Maintain evaluation sets and baselines, re-evaluate periodically, build cost dashboards, manage supply risks, version prompt templates, and conduct security reviews. The core principles: scenario first, measurable metrics, recoverable failures, and auditable processes. Rather than asking “which model is the best,” answer “under which constraints, which combination of models and engineering strategies is the most stable.” Use a general-purpose model as the default entry point, compose specialized capabilities as needed, and let engineering governance ensure sustained availability.
