A Practical Guide to Selecting and Calling Chinese LLMs

    This guide explains why model rankings fall short for engineering decisions and how to turn model selection into an optimization problem under constraints. It covers quantifiable evaluation dimensions, scenario-based matching strategies, a unified client abstraction with routing and fallback, client-side engineering practices, cost control and quality safeguards, common pitfalls, and a practical rollout checklist. The same abstraction and governance approach applies when running inference on general-purpose cloud capabilities such as container platforms, logging, and monitoring.

    1. Why Rankings Cannot Drive Engineering Decisions

    In practice, asking “which model is the strongest” rarely produces an actionable answer, for three reasons:

    1. Task distribution differs: academic Q&A, long-document understanding, code generation, and structured extraction place completely different demands on a model, and no single leaderboard covers them all.
    2. Cost structure differs: per-token pricing, concurrency quotas, and context length limits together determine the real bill; parameter count is only an indirect indicator.
    3. Integration differs: cloud APIs, local inference, and hybrid routing vary enormously in operational complexity.

    The right approach is to reframe “choosing a model” as “finding the optimal solution under defined constraints.”

    2. Quantifiable Selection Dimensions

    Score candidates on the dimensions below, adjusting weights to your business:

    • Inference quality: accuracy, hallucination rate, and instruction adherence on your own evaluation set.
    • Context capacity: the effective window needed for long documents and multi-turn dialogue; note that nominal length and effective recall length are not equivalent.
    • Throughput and latency: time to first token (TTFT) and output tokens per second (TPS) directly shape the interaction experience.
    • Cost controllability: input and output are billed separately, which matters most in long-context scenarios.
    • Ecosystem and compliance: whether data residency, audit logs, and content safety policies meet requirements.

    A simplified scoring function:

    1. score = (
    2. 0.35 * quality # performance on your own eval set
    3. + 0.20 * context # effective context match
    4. + 0.20 * latency # latency target met
    5. + 0.15 * cost # normalized inverse of cost
    6. + 0.10 * compliance # compliance met
    7. )

    3. Matching Strategies for Typical Scenarios

    • Academic research Q&A: prioritize long context and citation stability, and use retrieval-augmented generation (RAG) to reduce hallucination.
    • Code and structured output: prioritize instruction adherence and JSON schema stability, with schema validation and retries.
    • High-concurrency lightweight tasks: prioritize small, low-latency models, and use rule-based pre-filtering to cut unnecessary calls.
    • Sensitive data scenarios: prioritize options that can be deployed privately, running inference services on a container platform.

    4. A Unified Access Layer to Hide Model Differences

    Strongly consider adding an abstraction layer so business code is not tied to one vendor’s API:

    1. class LLMClient:
    2. def chat(self, messages, stream=True, max_tokens=1024):
    3. raise NotImplementedError
    4. class CloudClient(LLMClient): # generic cloud API
    5. def chat(self, messages, stream=True, max_tokens=1024):
    6. # unified auth, retry, and rate limiting
    7. ...
    8. class LocalClient(LLMClient): # local inference service
    9. def chat(self, messages, stream=True, max_tokens=1024):
    10. ...

    In the routing layer, select the backend dynamically by “task label + cost threshold” and keep a fallback path:

    1. def route(task, budget):
    2. if task == "long_doc" and budget > HIGH:
    3. return CloudClient()
    4. return LocalClient()

    5. Client-Side Engineering Essentials

    When integrating multiple models into a general-purpose chat client:

    1. Separate configuration from secrets: keep keys in environment variables or a secrets manager, never in the repository.
    2. Streaming rendering: append incrementally instead of replacing the whole block, to avoid UI jitter.
    3. Timeouts and retries: distinguish connection timeouts from read timeouts, and use exponential backoff with jitter.
    4. Observability: instrument TTFT, TPS, token consumption, and failure reasons, and wire them into logging and alerting.
    1. // Pseudocode: incremental streaming render
    2. for await (const chunk of stream) {
    3. buffer += chunk.text;
    4. render(buffer); // update only the new part
    5. }

    6. Cost Control and Quality Safeguards

    • Tiered routing: send simple requests to lightweight models and escalate complex ones.
    • Cache reuse: cache results for frequent identical prefixes and skip inference on a hit.
    • Context trimming: use a sliding window plus summary compression to cut wasted input tokens.
    • Automated evaluation: run a fixed small eval set as a regression check, with automatic alerts and rollback when quality drops.

    7. Common Pitfalls

    1. Looking only at parameter count while ignoring effective context and instruction adherence.
    2. Testing single-shot quality while ignoring latency jitter under concurrency.
    3. Treating nominal context as effective context, causing recall to collapse on long documents.
    4. Having no unified abstraction layer, so switching models means rewriting business logic.

    8. Rollout Checklist

    1. Define task labels and constraints (latency, cost, compliance).
    2. Build an in-house evaluation set of 50–200 items.
    3. Set up the unified access layer and routing policy.
    4. Add streaming output, retries, and instrumentation.
    5. Launch with a canary release and review cost and quality curves weekly.

    Following this path yields a stable, cost-effective foundation for LLM applications without depending on any single product; the same abstraction and governance approach carries over if you host workloads on general-purpose capabilities from Baidu AI Cloud, such as container platforms, logging, and monitoring with alerting.