How to Choose a Chinese LLM: A Practical Selection Framework from Requirements to Deployment

    Selecting a large language model requires balancing accuracy, cost, latency, and compliance rather than chasing leaderboard rankings. This guide walks through a practical framework: defining task boundaries, evaluating six core dimensions (task performance, context window, inference cost, latency and concurrency, tool calling and structured output, and data compliance), building a small-scale evaluation set with real business samples, and applying scenario-specific strategies for code assistance, document Q&A, information extraction, and customer service. It also covers engineering best practices such as a unified API abstraction layer, fallback and fault tolerance, prompt version control, and cost monitoring, so teams can establish a repeatable evaluation process for long-term stability.

    1. Why Selection Matters More Than Chasing the “Best” Model

    Many teams pick a model by looking at public leaderboards and simply choosing the top-ranked one. This approach often fails in production. Leaderboard scores come from fixed test sets whose question types rarely match real business data. A model that excels at general Q&A may not reliably extract fields from contract text, nor does it guarantee it can meet response-time requirements under high concurrency.

    Model selection is essentially about finding an acceptable balance across four constraints: quality, cost, latency, and compliance. The same model can deliver very different value in different business scenarios. Selection should therefore start from business requirements, not from rankings.

    2. Define Task Boundaries Before Comparing Models

    Before benchmarking candidates, break down your tasks clearly. Common task types include:

    • Open-ended generation: copywriting, creative content, marketing materials. These tasks demand fluent expression and style control, with lower requirements for output determinism.
    • Knowledge Q&A: internal policy lookup, product documentation Q&A. These depend heavily on retrieval quality; the model must stay faithful to the provided material and minimize hallucination.
    • Structured extraction: pulling fields from invoices, contracts, or tickets. Output format stability is critical, and field accuracy is the core metric.
    • Code-related tasks: code completion, defect localization, unit test generation. These require strong syntactic correctness and contextual understanding.
    • Multi-step reasoning and tool calling: querying databases or calling APIs in response to user requests, then summarizing results. The model must reliably generate function arguments and handle abnormal tool responses.

    Task type determines the evaluation focus. Structured extraction emphasizes format compliance, knowledge Q&A emphasizes grounding in retrieved material, and open-ended generation emphasizes stylistic consistency.

    3. Six Core Evaluation Dimensions

    3.1 Task Performance

    Quality is the first gate in selection. Evaluate with real business samples rather than relying on generic benchmarks. Samples should cover both common and edge cases: malformed inputs, ambiguous questions, very long documents, and so on.

    3.2 Context Window

    The context window determines how much input a model can process at once. Long-document Q&A, multi-turn dialogue, and codebase analysis all depend on long context. Note that supporting a long context window does not guarantee the model accurately uses information buried in the middle. In practice, place key information at different positions in the text and observe how well the model recalls it.

    3.3 Inference Cost

    Cost is driven by the volume of input and output tokens. Output tokens usually cost more than input tokens, so long-text generation scenarios need careful accounting. A simple estimation formula:

    1. Cost per request = input tokens × input unit price + output tokens × output unit price
    2. Monthly cost ≈ cost per request × average daily requests × 30

    Billing rules follow each provider’s published pricing. Recalculate against the current price list during selection—do not rely on historical figures.

    3.4 Latency and Concurrency

    Latency has two metrics: time to first token and total response time. Interactive applications such as chat assistants and code completion are sensitive to time to first token. Batch jobs, such as overnight summarization, care more about throughput. Concurrency must be verified through load testing—fast single requests do not guarantee stability at peak traffic.

    3.5 Tool Calling and Structured Output

    In agent-style applications, the model must output function names and arguments in the agreed format and correctly interpret tool return values. Test how the model behaves under abnormal conditions: missing parameters, type errors, and tool timeouts. Structured output stability also needs verification—for example, whether the model consistently returns valid JSON.

    3.6 Data Compliance and Deployment Options

    Scenarios involving personal information, trade secrets, or regulated industry data require confirming where data is stored, how it is transmitted, and whether it is used for model training. Deployment options also need evaluation: public cloud API access, private/on-premises deployment, or hybrid approaches. These differ significantly in cost, operational overhead, and security boundaries.

    4. Building a Small-Scale Evaluation Set

    Evaluating on real business data is the most valuable step in the selection process. A recommended workflow:

    1. Extract 100–300 samples from production or historical data, covering all task types and edge cases.
    2. Write scoring criteria for each sample. Closed-form tasks can use keyword or field matching; open-ended tasks can use a detailed scoring rubric, with manual spot checks where needed.
    3. Call each candidate model with identical prompts and parameter settings, recording outputs and latency.
    4. Aggregate accuracy, format compliance, average latency, and per-request cost into a comparison table.

    Below is a simplified evaluation script illustrating the basic structure of scoring and latency measurement:

    1. import time
    2. from dataclasses import dataclass
    3. @dataclass
    4. class EvalCase:
    5. prompt: str
    6. expected_keywords: list[str]
    7. def keyword_score(answer: str, case: EvalCase) -> float:
    8. """Score by the fraction of expected keywords hit; a rough metric for closed-form tasks."""
    9. if not case.expected_keywords:
    10. return 0.0
    11. hits = sum(1 for kw in case.expected_keywords if kw in answer)
    12. return hits / len(case.expected_keywords)
    13. def run_eval(call_model, cases: list[EvalCase]) -> dict:
    14. """call_model invokes the model under test: it takes a prompt and returns text."""
    15. scores, latencies = [], []
    16. for case in cases:
    17. start = time.perf_counter()
    18. answer = call_model(case.prompt)
    19. latencies.append(time.perf_counter() - start)
    20. scores.append(keyword_score(answer, case))
    21. return {
    22. "avg_score": sum(scores) / len(scores),
    23. "avg_latency_s": sum(latencies) / len(latencies),
    24. }

    This script is for illustration only. Keyword matching cannot judge semantic correctness. Production evaluation should combine structural validation, human scoring, or rubric-based automated review.

    5. Selection Strategies for Common Scenarios

    Code assistance: prioritize code generation correctness, adherence to existing code style, and understanding of long-file and multi-file context. Test with the team’s real code snippets and validate outputs by running unit tests.

    Document Q&A: focus on retrieval-augmented generation quality. The model should answer strictly based on retrieved material and state clearly when the material is insufficient. Design a set of questions whose answers are not in the documents to check whether the model fabricates content.

    Information extraction: focus on field accuracy and format stability. Provide explicit field definitions and output examples in the prompt, programmatically validate that outputs meet structural requirements, and route failures to retry or human review.

    Customer service and dialogue: these scenarios demand low time to first token and multi-turn consistency. Test whether the model remembers earlier commitments in long conversations and how it responds when users are emotional or questions are vague.

    6. Engineering Considerations for Production

    6.1 Unified Invocation Layer

    Business code should not depend directly on any single model’s proprietary API. Wrap a unified adapter layer and manage model name, endpoint, credentials, and parameters through configuration. Switching models or running canary tests then only requires a config change, not code changes.

    1. import os
    2. def load_model_config() -> dict:
    3. """Load model configuration from environment variables; never hard-code credentials."""
    4. return {
    5. "base_url": os.environ["MODEL_BASE_URL"],
    6. "api_key": os.environ["MODEL_API_KEY"],
    7. "model_name": os.environ.get("MODEL_NAME", "default-model"),
    8. "timeout_s": float(os.environ.get("MODEL_TIMEOUT_S", "30")),
    9. }

    6.2 Fallback and Fault Tolerance

    Model services can time out, hit rate limits, or suffer temporary failures. Design degradation strategies—for example, retry once after a timeout or switch to a backup model. Cap the retry count, and be cautious with non-idempotent operations to avoid repeating write actions.

    6.3 Prompt Version Management

    Prompts evolve with the business and should be version-controlled like code. After every prompt change, rerun the evaluation set to confirm there is no regression.

    6.4 Cost Monitoring

    Log input/output length, model name, and latency for every call, and track spending by business line. Abnormal cost spikes often come from unexpectedly bloated prompts or looping calls; timely monitoring and alerts catch these problems early.

    7. Summary of the Selection Process

    1. Break down requirements by task type and define the core metric for each.
    2. Determine acceptable deployment options based on data compliance requirements.
    3. Build an evaluation set from real samples and compare two to three candidate models.
    4. Compute a composite score across quality, cost, and latency; select a primary model and a backup.
    5. Integrate through the unified invocation layer, monitor quality and cost continuously after launch, and re-evaluate periodically.

    Model selection is not a one-time decision. Model versions update quickly, and business needs change. Building a repeatable evaluation process supports long-term project stability far better than picking a “best model” once.