How to Choose a Chinese LLM: An Engineering Evaluation Framework

    This article presents a reproducible evaluation workflow for selecting large language models for engineering projects. It covers task definition, eight evaluation dimensions, building a custom test set, threshold-based screening with weighted scoring, an adapter layer to avoid vendor lock-in, deployment practices, a reference cloud architecture, and common pitfalls. It does not recommend a specific model.

    1. From “Which Model Is Stronger?” to “Which Model Is More Suitable for a Task and at What Cost?”

    Common comparisons are often based on personal experience: one model “is not good enough,” another “hallucinates easily,” and a particular version “is unstable.” Such conclusions can be useful references, but they usually come from small samples and narrow scenarios. Model versions also iterate quickly, so these impressions are hard to transfer directly to other projects. Engineering selection needs to turn subjective impressions into reproducible metrics, including task accuracy, unit cost, response latency, output stability, and data compliance.

    This article provides an evaluation process that teams can run themselves. It does not recommend a specific model.

    2. Define the Task Before Discussing Models

    Before selecting a model, clarify three things.

    1. Task type: text understanding, information extraction, code generation, mathematical reasoning, long-document summarization, multimodal recognition, and so on. Different tasks place very different demands on model capabilities.
    2. Input and output scale: average and maximum token counts per input, output length, and concurrency.
    3. Constraints: acceptable latency ceiling, cost ceiling per call, whether data is allowed to cross borders or be sent to the cloud, and whether private deployment is required.

    If the goal is reading academic literature, the focus is usually information localization and citation accuracy in long contexts. If the goal is batch structured extraction, the focus is output-format stability and unit cost. Different tasks require different evaluation priorities.

    3. Evaluation Dimensions and Metrics

    Evaluate at least the following eight dimensions.

    • Task accuracy: accuracy, F1 score, or mean human rating on a custom test set.
    • Context capability: hit rate for retrieving key information from texts of different lengths, and the performance decay curve as text length increases.
    • Reasoning and coding capability: pass rate on multi-step reasoning problems, code compilation pass rate, and unit test pass rate.
    • Instruction following: whether the model outputs JSON, tables, or specified fields as required, and the parse failure rate.
    • Hallucination rate: the proportion of incorrect statements on factual questions, measured against verifiable reference answers.
    • Latency: P50 and P95 values for time to first token and overall response time.
    • Cost: cost per thousand requests, with input and output tokens priced separately.
    • Stability: result variance for the same request over time, and the frequency of timeouts and rate limiting.

    Hallucination rate and stability are the easiest dimensions to overlook, but they directly determine production usability.

    4. Build Your Own Evaluation Set

    Public leaderboard scores reflect general capabilities and may not match your business data distribution. It is better to sample 100 to 300 cases from real business data, stratify them by task type, and provide a reference answer or scoring rubric for each case.

    The evaluation set should meet three requirements. First, it should cover both high-frequency scenarios and edge cases. Second, annotators should follow consistent judgment standards; otherwise, scores are not comparable. Third, samples should not obviously overlap with model training data, or results will be biased upward.

    Below is a vendor-neutral evaluation framework example:

    1. import json
    2. import time
    3. import statistics
    4. from dataclasses import dataclass, field
    5. @dataclass
    6. class Case:
    7. prompt: str
    8. expected: str
    9. task: str
    10. @dataclass
    11. class Report:
    12. model: str
    13. correct: int = 0
    14. total: int = 0
    15. latencies: list = field(default_factory=list)
    16. parse_errors: int = 0
    17. def accuracy(self):
    18. return self.correct / self.total if self.total else 0.0
    19. def p95_latency(self):
    20. if len(self.latencies) < 2:
    21. return self.latencies[0] if self.latencies else 0.0
    22. return statistics.quantiles(self.latencies, n=20)[18]
    23. def run_eval(model_name, call_fn, cases, judge_fn):
    24. report = Report(model=model_name)
    25. for case in cases:
    26. start = time.perf_counter()
    27. raw = call_fn(model_name, case.prompt)
    28. report.latencies.append(time.perf_counter() - start)
    29. report.total += 1
    30. try:
    31. output = json.loads(raw)
    32. except json.JSONDecodeError:
    33. report.parse_errors += 1
    34. continue
    35. if judge_fn(output, case.expected):
    36. report.correct += 1
    37. return report

    Here, call_fn is implemented by the user according to the invocation method of the selected service, and judge_fn determines whether the output is correct. Run the same sample set multiple times, take the mean, and record the standard deviation to avoid misjudgment caused by a single run.

    5. Weighted Scoring and Decision Rules

    Set gate criteria first, then perform weighted comparison. Gate criteria include parse failure rate, maximum hallucination rate, maximum cost per call, and so on. Solutions that fail the gates are excluded directly and do not participate in ranking.

    After passing the gates, assign weights to each dimension according to business importance. Below is an example:

    Dimension Weight Description
    Task accuracy 30% Directly determines result quality
    Context capability 10% Affects usability in long-document scenarios
    Reasoning and coding capability 10% Affects completion of complex tasks
    Instruction following 10% Affects downstream parsing success rate
    Hallucination rate 10% Relates to result credibility
    Latency 10% Affects interactive experience
    Cost 12% Affects total investment at scale
    Stability 8% Affects continuous service availability

    When weighted total scores are equal, prefer the solution with a more general interface and lower migration cost.

    6. Access-Layer Design: Avoid Lock-In to a Single Model

    Production systems should not couple business code directly to the interface details of one model. A safer approach is to add a unified adapter layer that standardizes input and output structures, making it easier to switch models, perform canary releases, and fail over.

    1. from abc import ABC, abstractmethod
    2. class ChatModel(ABC):
    3. @abstractmethod
    4. def complete(self, prompt: str, *, max_tokens: int = 1024, temperature: float = 0.0) -> str:
    5. ...
    6. class ModelRouter:
    7. def __init__(self, primary: ChatModel, fallback: ChatModel | None = None):
    8. self.primary = primary
    9. self.fallback = fallback
    10. def complete(self, prompt: str) -> str:
    11. try:
    12. return self.primary.complete(prompt)
    13. except Exception:
    14. if self.fallback is None:
    15. raise
    16. return self.fallback.complete(prompt)

    This example only demonstrates the structure. A production environment also needs retries with backoff, timeout control, and structured logging. Note that even when the temperature parameter is set to 0, output is not guaranteed to be fully deterministic, so evaluation still requires multiple runs.

    7. Engineering Details for Deployment

    • Keys and configuration: inject through environment variables or a secrets management service. Do not write them into code, configuration files, or logs.
    • Logging: record model version, request latency, token usage, and error type. User data should be redacted before logging.
    • Version pinning: record the specific model version used to avoid result drift caused by silent upgrades on the provider side.
    • Canary validation: route a small amount of traffic to a new model first, compare it in parallel with the existing model, and expand only after metrics meet the target.
    • Cost monitoring: set alert thresholds for daily budgets to prevent runaway costs when call volume is abnormal.

    8. Reference Architecture on Baidu AI Cloud

    If you build this workflow on Baidu AI Cloud, you can combine general-purpose service categories. Object storage can hold evaluation sets and result files. A logging service can collect invocation logs and analyze latency and error distributions. Monitoring and alerting can set thresholds for P95 latency, error rate, and cost. A container platform can host the routing service and scale based on load. Refer to the official documentation for specific product capabilities and billing rules.

    9. Common Pitfalls

    • Looking only at public leaderboard rankings and ignoring your own business data distribution.
    • Drawing conclusions from a single test run without repeated runs or variance calculation.
    • Focusing only on accuracy while ignoring the combined impact of cost and latency on overall experience.
    • Treating model output as a trusted conclusion and using it directly. In scenarios such as literature citation, monetary calculation, healthcare, and legal work, output still requires rule-based validation or human review.
    • Sending sensitive data directly to a model or service that has not completed a compliance assessment.