LLM Selection: From Inference Serving to Production Deployment

    This article explores common pitfalls in evaluating and deploying Large Language Models (LLMs) and proposes a general methodology for model selection. It separates model capabilities, inference services, and business pipelines, emphasizing the importance of defining specific workloads and building enterprise private evaluation sets. The article also covers inference platforms, candidate model comparison dimensions, rollout strategies, RAG integration, actual cost calculation, security and compliance, and continuous operations, helping businesses find the most suitable model under their specific constraints.

    Model selection often falls into two traps: treating public leaderboards as the sole criteria, and mistaking “running a demo” for “stable production.” As various LLMs enter the enterprise landscape via inference microservices, managed APIs, or private deployments, the real question is not “which is the strongest,” but “which is the best fit under my data, traffic, latency, budget, and compliance constraints.” This article strips away platform and brand factors to distill a general approach: how to treat an inference serving platform as a model shelf and runtime base, how to design fair evaluations, how to build an integration layer and routing strategy, and ultimately how to embed model capabilities stably into business processes.

    1. Clarify Concepts First: Models, Inference Services, and Business Pipelines Are Different

    Three layers of concepts should be separated before discussing selection.

    Layer 1 is model capability, including Chinese comprehension, code generation, tool calling, long context, multi-turn dialogue, structured output, mathematical reasoning, and safe refusal to answer. It determines “what can theoretically be done.”

    Layer 2 is inference serving capability, which is how models are called via standard interfaces. It focuses on throughput, time-to-first-token (TTFT) latency, stability, concurrency limits, authentication, rate limiting, logging, replay, grayscale release, and cost metering. It determines “whether it is engineering-friendly.”

    Layer 3 is the business pipeline, including retrieval-augmented generation (RAG), access control, auditing, caching, human review, task orchestration, and result persistence. It determines “whether the value is realized.”

    Many teams only look at Layer 1 during evaluation, only to find problems concentrated in Layers 2 and 3 after launch: timeouts under peak traffic, cost overruns from repeated calls, context pollution from retrieval noise, lack of desensitization for sensitive fields, and no fallback for abnormal outputs. Therefore, the selection document must cover model quality, service quality, and pipeline quality.

    2. Don’t Ask “Which Vendor”, Define the Workload First

    There is no universally optimal LLM for all scenarios. A more reasonable starting point is to break down business traffic into several workloads and provide quantitative constraints. For example:

    • Customer support Q&A: Requires high availability, low latency, controllable answers, allows external knowledge retrieval, and heavily relies on citations and refusals.
    • Code assistance: Focuses on completion accuracy, repository-level context, unit test generation, patch compilability, and keeping sensitive code within the domain.
    • Document summarization: Focuses on long context, factual consistency, format stability, and batch processing costs.
    • Marketing creation: Allows more divergence but requires controlling brand tone, advertising law risks, and factual errors.
    • Data analysis: Emphasizes structured output, function calling, table comprehension, and retryable failures.

    Each workload should define at least four types of metrics: quality, experience, cost, and risk. Quality metrics can be manual scoring, factual hit rate, or task success rate. Experience metrics include TTFT, full response latency, and timeout rate. Cost metrics include cost per 1,000 calls, post-cache hit cost, and peak scaling cost. Risk metrics include sensitive information leak rate, unauthorized response rate, hallucination rate, and unparseable output rate.

    Comparison only makes sense when the workload is specific enough. A model good at long-form writing may not be suitable for low-latency ticket classification; a model excelling at code might be unstable in formal document styles.

    3. Build an “Enterprise Private Evaluation Set”, More Important Than Public Leaderboards

    Public benchmarks are valuable for quickly filtering candidates, but their distribution often differs from real enterprise traffic. It is recommended to build a three-tier evaluation set.

    Tier 1 is the general capability set, used to eliminate obviously unqualified models, covering instruction following, language comprehension, basic reasoning, code snippets, and format output.

    Tier 2 is the business sampling set, sampled from historical tickets, real Q&A, internal documents, and desensitized logs, preserving original noise as much as possible: typos, colloquialisms, mixed intents, missing context, and incomplete fields.

    Tier 3 is the adversarial and boundary set, covering prompt injection, unauthorized requests, privacy extraction, false information induction, ultra-long context interference, malicious code generation requests, and format-breaking samples.

    Scoring should not just be “good/bad.” Break it down into reviewable dimensions, such as factual correctness, constraint satisfaction, citation consistency, style matching, appropriateness of refusal, and whether sensitive information is leaked. For structured tasks, prioritize programmatic validation: whether JSON is parseable, whether fields are complete, whether enum values are valid, whether SQL passes in a read-only sandbox, and whether generated patches compile and pass tests. For open-ended tasks, model preliminary scoring plus manual spot-checks can be used, but review rubrics should be recorded to avoid standard drift among different reviewers.

    4. Value of Inference Microservice Platforms: Unified Shelf, Not Unified Decision

    Common inference microservice platforms in the industry essentially encapsulate different models into discoverable, callable, measurable, and governable service units. The benefits are clear: unified authentication, rate limiting, monitoring, and elastic scaling, so teams don’t need to rewrite integration logic for each model. It also allows fast switching between candidate models during grayscale testing, reducing trial-and-error costs.

    However, a “unified shelf” does not mean a “unified strategy.” The platform solves availability but cannot replace adaptability. Enterprises still need to build their own gateway layer above the platform to handle:

    • Model aliasing and version binding: Business services depend only on stable aliases, not hardcoded specific versions.
    • Routing strategies: Selecting models based on task type, tenant tier, context length, and cost budget.
    • Fallback strategies: Automatically switching to a cheaper or more stable model when a high-priority model times out or fails.
    • Caching and deduplication: Applying semantic caching to high-frequency similar requests to avoid redundant consumption.
    • Auditing and replay: Recording input summaries, output summaries, latency, token usage, and human feedback.

    A schematic integration configuration can be abstracted as:

    1. route:
    2. intent: customer_support
    3. context_budget: 32000
    4. latency_slo_ms: 1800
    5. candidates:
    6. - alias: general-pro
    7. weight: 70
    8. max_cost_per_1k: 0.20
    9. - alias: cost-lite
    10. weight: 30
    11. fallback: true
    12. policies:
    13. pii_redaction: true
    14. require_citation: true
    15. max_retry: 2

    The point here is not the specific fields of a platform, but explicitly expressing “business intent, budget, latency, risk strategy” to avoid scattering model selection across hardcoded services.

    5. Candidate Model Comparison Dimensions: Use a Matrix Instead of Emotion

    It is recommended to maintain a candidate matrix, where each row is a candidate model or deployment form, and each column is a key dimension. Common dimensions include:

    1. Effectiveness: General benchmark score, business set score, adversarial set pass rate, structured output success rate.
    2. Context: Effective context rather than nominal context; whether answers remain consistent after long-text retrieval.
    3. Latency: TTFT, full response latency, tail latency for long outputs, degradation curve under concurrency.
    4. Cost: Input/output unit price, caching benefits, batch discounts, private deployment resource consumption.
    5. Controllability: System prompt compliance, style consistency, tool calling stability, refusal boundaries.
    6. Deployment: Feasibility and operational complexity of managed APIs, dedicated instances, private deployment, and offline environments.
    7. Compliance: Whether data leaves the domain, training usage boundaries, log retention, industry regulatory requirements.
    8. Ecosystem and Migration: API compatibility, vector database adaptation, monitoring integration, exit costs.

    Scoring should distinguish between “threshold items” and “competitive items.” For example, in financial scenarios, keeping sensitive data within the domain might be a threshold item; failing it means direct elimination. After meeting thresholds, compare quality and cost. This prevents being swayed by a single-point advantage.

    6. Rollout Path: From Shadow Traffic to Tiered Grayscale

    LLM rollout should not switch to full traffic at once. The recommended path is: passing offline evaluation, shadow traffic observation, small traffic grayscale, tiered volume increase, and cost optimization after stabilization.

    The shadow phase does not return results to users; it only records model performance on real inputs to discover out-of-distribution issues. The small traffic phase prioritizes low-risk scenarios, such as internal knowledge base drafts or customer support suggestions rather than automatic replies. When increasing volume, segment by tenant, channel, region, and business tier, reserving human review for high-value customers or high-risk operations.

    During grayscale, fallback switches must be preset: when error rates, latency, or sensitive words trigger thresholds, automatically roll back to rule-based systems, retrieval templates, or low-cost models. Establish an “untrusted output” channel for generated results: low confidence, no citations, abnormal formats, or risk classification hits should not reach end users directly.

    7. RAG and Model Selection: A Good Model Can’t Save Bad Context

    Many enterprises blame hallucinations entirely on the model, but retrieval quality is often a bigger variable. If recalled documents are incorrect, chunks are too fragmented, permission filtering is missing, or time references are confused, even the strongest model will only steadily produce “plausible errors.”

    Therefore, evaluation should test the model within the complete RAG pipeline rather than raw Q&A. Observe whether the model can recognize “I don’t know,” cite correct segments, avoid being misled by adjacent but irrelevant paragraphs, explain conflicts when multiple documents disagree, and distinguish between policy versions and time validity. For knowledge-intensive businesses, the joint metrics of retrieval recall, reranking quality, and answer citation often predict online performance better than simple model scores.

    8. Cost Model: Look at the Cost of a Successful Task, Not Just the Unit Price

    Nominal token pricing is easy to compare, but real cost depends on the total consumption of “successfully completing a business task.” This includes retries, context expansion, tool calling round-trips, auditing, and human intervention. A cheap model requiring more retries and longer prompts may not save money; an expensive model with a high first-pass success rate, accurate refusals, and reduced manual review might have lower overall costs.

    A simplified formula can be used:

    1. Single effective cost =
    2. (input_tokens * input_price + output_tokens * output_price + tool_and_retrieval_cost) * average_retry_count
    3. + manual_review_probability * review_cost
    4. + expected_loss_from_failures_and_fallbacks

    Optimization methods include semantic caching, prompt compression, context pruning, batch asynchronous tasks, off-peak scheduling, hot-cold tiered routing, and output length constraints. For long-context tasks, evaluate the cost difference between “feeding all materials to the model” and “retrieving first, then compressing.”

    9. Security and Compliance: Move Defenses to Both Input and Output Sides

    LLM security is not a final filter before launch; it should run through input, retrieval, generation, execution, and persistence. The input side handles identity recognition, permission checks, sensitive field desensitization, and prompt injection detection. The retrieval side handles document-level permissions and tenant isolation. The generation side constrains formats, citations, and tool whitelists. The execution side maintains least privilege, secondary confirmation, and auditing for any write operations. The output side performs privacy re-scanning, factual annotation, and disclaimer policies.

    For code generation scenarios, generated code should be untrusted by default: dependencies must be scanned, keys detected, patches pushed to CI, and dangerous commands sandboxed. For office and customer support scenarios, clearly define what the model cannot promise, such as compensation, contract changes, medical diagnoses, and legal conclusions, mandating handoff to humans when necessary.

    10. Organizational Landing: Selection Is Continuous Operation, Not a One-Time Purchase

    Finally, it is recommended to form three long-term assets: evaluation assets, routing assets, and observability assets. Evaluation assets ensure quick re-testing when new models emerge; routing assets ensure centralized, editable strategies; observability assets ensure that quality, cost, latency, and risk can be reviewed weekly. Regarding team roles, business owners define success criteria, platform engineering handles integration and stability, algorithm or application engineering handles prompts, retrieval, and evaluation, and security compliance handles boundaries and auditing.

    If enterprises are already using general cloud capabilities like those from Baidu AI Cloud, they can leverage object storage, container platforms, logging services, monitoring and alerting, message queues, and access control as the foundation to handle evaluation data, service orchestration, call chain tracing, and alerting closures. However, model and platform selection should still be based on the aforementioned metrics rather than brand preference or short-term hype.

    The conclusion is clear: LLMs have entered a stage where they are comparable, composable, and grayscale-testable. The correct approach is not to bet on a single “strongest model,” but to build a replaceable model integration and evaluation system, allowing the business to achieve continuous optimization across effectiveness, latency, cost, and compliance.