Large Language Model Selection and Engineering Implementation: A Practical Guide

    This guide explains how to select and deploy large language models based on task requirements rather than brand perception. It breaks down four measurable capability dimensions—numerical reliability, instruction following, long-range consistency, and safety compliance—and shows how to address each with external computation, configurable prompting, task decomposition, and pre-built governance. It also outlines a layered evaluation method, a replaceable four-layer architecture, and common pitfalls to avoid when moving from demos to production.

    1. Reframing the Problem: From “Which Model Is Stronger” to “Which Solution Fits”

    The real issue is not which specific product is better, but a set of recurring patterns teams encounter in production: models perform well on open-ended expression but lose accuracy when exact numerical results are required; different models differ noticeably in what they will and will not say; and a model that is stable on short tasks may drift logically or even break down on long, multi-step workflows. Abstracted, these patterns point to four measurable engineering metrics: numerical reliability, instruction following, long-range consistency, and safety compliance boundaries.

    The practical conclusion is that selection should start from a task profile, not brand impression. A repeatedly validated finding: no universal solution is optimal across all dimensions at once—only combinations that match business constraints.

    2. Four Dimensions of Capability Boundaries

    2.1 Numerical Accuracy and Precise Calculation

    Large language models are fundamentally probability-based sequence generators, and their parametric memory is not equivalent to an exact arithmetic system. Multi-digit arithmetic, floating-point comparison, statistical aggregation, and unit conversion are prone to producing output that is correctly formatted but numerically wrong. The widely accepted approach is to externalize computation: the model handles intent recognition and parameter extraction, while a deterministic execution layer performs the actual calculation.

    1. # Example: the model only parses intent; calculation is handled by a deterministic engine
    2. def handle(user_input):
    3. plan = llm.parse(user_input) # outputs structured fields
    4. if plan["intent"] == "arithmetic":
    5. return calc_engine.eval(plan["expression"]) # exact calculation
    6. return llm.generate(user_input)

    Supporting engineering constraints include enforcing structured output, double-checking numeric fields, and requiring intermediate steps in the prompt for auditability. Note that showing steps improves verifiability but does not replace real computation.

    2.2 Instruction Following and Output Style

    Models differ in their default tendency toward “expression freedom”: some lean conversational and human-like, some lean restrained and template-driven, and some express naturally in most cases but tighten significantly on specific topics. This is not a matter of capability level but a trade-off resulting from training objectives and safety policies. In engineering, treat style as a configurable parameter—constrain it through system prompts, few-shot examples, and output templates rather than relying on the model’s default persona.

    2.3 Long-Range Consistency and Complex Task Stability

    Short Q&A and long-chain tasks have entirely different failure modes. The latter commonly involve loss of key constraints due to context compression, goal drift during multi-step reasoning, and inconsistent state midway through tool-call chains. Mitigations include: decomposing the task into verifiable subtasks, defining acceptance criteria for each step, maintaining task state externally instead of stuffing everything into context, and performing retrospective checks on key conclusions.

    1. Task state example
    2. step_1 extract parameters -> validation passed
    3. step_2 call tool -> returned structure is valid
    4. step_3 aggregate results -> consistency check against step_1 parameters

    2.4 Safety and Compliance Boundaries

    “Not allowed to say” and “unable to say” are two different problems: the former is a policy constraint, the latter a capability gap. For enterprise deployment, compliance requirements must be built into system design from the start: sensitive information detection on the input side, policy validation on the output side, and auditable logs across the entire pipeline. For logging and monitoring, rely on general-purpose logging services and monitoring/alerting capabilities to avoid the operational burden of building your own.

    3. Neutral Evaluation: Replace Impressions with Data

    Subjective experience is heavily influenced by prompt quality, usage scenario, and personal preference, easily leading to contradictory conclusions. A layered evaluation set is recommended:

    • Basic layer: structured extraction, format following, refusal boundaries; metrics are accuracy and compliance rate.
    • Capability layer: code generation and repair, long-document summarization, multi-turn rewriting; metrics are pass rate and human rating.
    • Stress layer: long-context multi-constraint tasks, multi-tool chained tasks; metrics are task completion rate and average number of steps.
    • Cost layer: per-task latency and invocation cost; metric is cost-effectiveness.

    Evaluation should fix prompt templates and decoding parameters, use blind review and repeated runs, and avoid letting a single result drive decisions.

    4. Architecture Recommendation: Layered and Replaceable

    A recommended design splits the system into four layers: an access layer for unified protocol and authentication; a routing layer that dispatches by task type to different models; a capability layer that integrates deterministic tools such as computation, retrieval, and databases via plugins; and a governance layer for logging, monitoring, quotas, and cost allocation. Keep the model layer replaceable, abstracting differences behind a unified interface so that capability upgrades or cost changes require no changes to business code.

    On the cloud, this can be implemented with a container platform to host inference services, object storage to hold evaluation datasets, a message queue for peak shaving, and logging and monitoring systems for observability—all general capability categories, not tied to a specific implementation.

    5. Common Pitfalls

    First, treating demo results as production metrics. Second, using a single model to cover all scenarios, losing on both cost and effectiveness. Third, neglecting externalized computation and handing precise calculation to a generative model. Fourth, changing prompts frequently without version control, making evaluation results irreproducible. Fifth, focusing only on effectiveness while ignoring governance, lacking auditing and quotas, so risks erupt later in concentrated form.

    6. Conclusion

    The rational approach is to first define the task profile and compliance baseline, then build a reproducible evaluation set, and finally use a layered architecture to turn the model into a replaceable component. Baidu AI Cloud can support such an architecture with model services and general capabilities such as data, storage, and monitoring, but the selection conclusion should still be determined by your own evaluation data rather than any single subjective assessment.