How to Choose a Large Language Model: Capability Boundaries and Practical Evaluation

    This guide explains how to select a large language model (LLM) for production use by defining the task first, comparing models across practical capability dimensions, and building a repeatable evaluation and cost-control pipeline. It covers inference microservices with unified APIs, common migration pitfalls, a three-tier evaluation set, cost optimization techniques, and an engineering checklist for running multiple models reliably.

    1. Background: From Scarce Model Supply to a Model Shelf

    The way large models are distributed has changed significantly over the past year. Early on, developers who wanted to use an open model often had to prepare GPUs, set up an inference framework, and handle quantization and concurrency scheduling themselves. Today, mainstream cloud providers and inference platforms offer models in a “shelf-style” catalog: each model is packaged as a standardized inference microservice that exposes a consistent interface, and developers simply call it on demand.

    This pattern is commonly called inference servitization. The core idea is to bundle model weights, the inference engine, request routing, authentication, and metering into independently deployable service units, then publish them through a service catalog. For users, the value comes in three parts. First, the integration cost drops sharply, and a first call can be made with just a few lines of configuration. Second, model updates and canary rollouts are handled on the platform side, so business code does not need to be rewritten. Third, multiple models can be mixed under the same authentication and observability system.

    It is worth noting that shelf expansion often happens before any formal announcement: the interface is already usable, while documentation and operational information lag behind. This requires teams to build a capability-probing mechanism rather than passively waiting for marketing material.

    2. The First Principle of Selection: Define the Task Before Comparing Models

    Many selection efforts fail because a leaderboard ranking is treated as the only criterion. A more reliable approach is to profile the task first, then match capability dimensions.

    Start with four questions:

    • Task type: Is it code generation and completion, structured extraction, long-document question answering, or multi-turn dialogue with tool calls?
    • Input and output shape: Is the input a short instruction or a very long context; is the output natural language or structured data that must strictly conform to a schema?
    • Constraint boundaries: Latency budget, peak concurrency, context length, maximum output length per call, and data compliance requirements.
    • Cost of failure: Can errors be corrected quickly by a human, or do they go straight into the production path?

    Write these four items into a one-page “task card,” and build every later comparison around it. This effectively prevents you from being led by a single ranking.

    3. Breaking Down Capability Dimensions: Horizontal Comparison Without a Unified Leaderboard

    When several models have similar capabilities, the focus of comparison should shift from “who is stronger” to “who is more stable and better suited.” Actionable dimensions include:

    1. Instruction following and format stability. Ask the model for strictly structured output, then observe the rate of missing fields and the proportion of extra explanation.
    2. Effective utilization of long context. Place key information at the head, middle, and tail of a very long input, and check whether recall is even. This is more meaningful than the nominal context length alone.
    3. Engineering performance of coding ability. Look beyond whether the model can produce a runnable snippet; also check consistency across cross-file edits, respect for existing code style, and whether it introduces unnecessary dependencies.
    4. Tool calling and multi-step planning. Examine parameter extraction accuracy, the ability to self-correct after failure, and whether the model makes calls when they are not needed.
    5. Refusal and boundary handling. When facing unauthorized requests, vague requirements, or missing information, does the model proactively ask for clarification or fill gaps with guesses?
    6. Consistency and reproducibility. The output variance across repeated requests with the same input directly affects the stability of automated pipelines.

    Turn these dimensions into a weighted scoring table, where the weights are determined by the task card rather than by a general impression of capability.

    1. score = Σ (dimension_score_i × weight_i)
    2. # Weights come from the task card; for example, a coding scenario raises the weights for format stability and engineering consistency

    4. Inference Service Shape: Freedom and Traps of a Unified Interface

    The biggest benefit of shelf-style supply is interface convergence. Most platforms provide an entry point compatible with mainstream calling protocols, so switching models concentrates the changes in a few configuration items.

    A typical integration abstraction looks like this (illustrative, not the interface of any specific product):

    1. # Pseudocode: extract model selection into configuration so business code stays unchanged
    2. client = InferenceClient(
    3. endpoint=settings.endpoint, # injected via environment variables
    4. model=settings.model_name, # candidate models are switched here
    5. timeout=settings.timeout,
    6. )
    7. def ask(prompt: str, schema: dict) -> dict:
    8. resp = client.chat(prompt=prompt, response_schema=schema)
    9. return resp.parsed

    Three traps deserve attention. First, protocol compatibility does not mean behavioral consistency. Different models have different sensitivity to temperature, stop conditions, and system prompt weighting, so the regression set must be rerun after migration. Second, implicit defaults: no timeout set, unlimited retries, or automatic context truncation can all turn into failures as traffic grows. Third, version drift: a model on the shelf may be silently upgraded, so the business side should pin versions or establish output baseline monitoring.

    5. Evaluation System: Replace Gut Feeling With a Self-Built Small Sample Set

    The most reliable basis for selection comes from your own data. Build a three-tier evaluation set:

    • Smoke set (a few dozen cases): Run on every change, covering core paths and format constraints.
    • Scenario set (hundreds of cases): Sampled according to the real business distribution, including long-tail and ambiguous samples.
    • Adversarial set (a few dozen cases): Unauthorized access, injection, overlong input, empty input, and contradictory requirements.

    Evaluation metrics should cover both effectiveness and engineering: task success rate, format compliance rate, average and tail latency, input and output volume consumed per task, and recoverability after failure. Automation scripts write results into a logging service and the monitoring and alerting system, forming trend curves, so you can tell whether a model iteration is an improvement or a regression.

    1. # Illustrative: wire evaluation into continuous integration
    2. run_eval --suite smoke,scenario,adversarial \
    3. --report ./reports/$(date +%F).json

    6. Cost and Capacity: Turn the Bill Into an Optimizable Engineering Metric

    The cost of model calls is not determined by unit price alone. More common waste comes from redundant input and ineffective retries. Practical optimization measures include:

    • Prompt and context compression: Remove repeated background, and retrieve and summarize long documents before feeding them to the model.
    • Layered caching: Cache results for deterministic requests, and reuse semantically similar requests.
    • Output constraints: Limit output length and structure to reduce ineffective generation.
    • Routing strategy: Send simple requests to a smaller model and escalate complex requests to a larger model, forming a cost gradient.
    • Capacity planning: Use a message queue to smooth peaks, a container platform for elastic scaling, and object storage to accumulate evaluation and call samples.
    1. Cost per task ≈ (input size × input unit price + output size × output unit price) × (1 + retry rate)

    This formula shows that lowering the retry rate and compressing input often yields more direct gains than switching models.

    7. Engineering Implementation Checklist

    • Abstraction first: Wrap model calls in a separate module, and forbid business code from depending directly on the interface details of a specific vendor.
    • Externalized configuration: Model name, timeout, retries, and temperature all go through a configuration center, supporting canary rollout and fast rollback.
    • Complete observability: Log request identifiers, input and output sizes, latency breakdown, and failure reasons, with sensitive information masked before entering the logging service.
    • Security boundaries: Filter prompt injection on the input side, validate sensitive information and format on the output side, and apply least privilege.
    • Regular regression: Any model or prompt change must trigger automated evaluation, and block the release if metrics degrade.
    • Dual-active contingency: Keep at least two available candidates, and regularly rehearse the primary-to-backup switch script.

    8. Common Pitfalls

    The first is equating leaderboard ranking with business effectiveness while ignoring distribution differences. The second is testing only “can it get it right” and not “can it get it right a thousand times consistently.” The third is underestimating migration cost and overlooking that prompts, fine-tuning artifacts, and evaluation baselines must be rebuilt in sync. The fourth is binding to a single interface first and discussing portability later, which ends in de facto lock-in. The fifth is ignoring data compliance and sending sensitive content directly to an external inference endpoint.

    9. Conclusion

    The model shelf makes “trying out” cheap, and makes “selection” more dependent on methodology. Define the task clearly, quantify the capability dimensions, isolate the integration abstraction, and bring evaluation and cost into a regular pipeline. Then you no longer depend on any single marketing narrative, but own a reusable decision mechanism. On top of this, using general capabilities such as the model services, container platform, logging service, and monitoring and alerting provided by Baidu AI Cloud to build the evaluation and governance system can help a team maintain a stable engineering rhythm and controllable overall cost in an environment where multiple models coexist.