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.
- 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.
- Input and output scale: average and maximum token counts per input, output length, and concurrency.
- 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:
import jsonimport timeimport statisticsfrom dataclasses import dataclass, field@dataclassclass Case:prompt: strexpected: strtask: str@dataclassclass Report:model: strcorrect: int = 0total: int = 0latencies: list = field(default_factory=list)parse_errors: int = 0def accuracy(self):return self.correct / self.total if self.total else 0.0def p95_latency(self):if len(self.latencies) < 2:return self.latencies[0] if self.latencies else 0.0return statistics.quantiles(self.latencies, n=20)[18]def run_eval(model_name, call_fn, cases, judge_fn):report = Report(model=model_name)for case in cases:start = time.perf_counter()raw = call_fn(model_name, case.prompt)report.latencies.append(time.perf_counter() - start)report.total += 1try:output = json.loads(raw)except json.JSONDecodeError:report.parse_errors += 1continueif judge_fn(output, case.expected):report.correct += 1return 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.
from abc import ABC, abstractmethodclass ChatModel(ABC):@abstractmethoddef complete(self, prompt: str, *, max_tokens: int = 1024, temperature: float = 0.0) -> str:...class ModelRouter:def __init__(self, primary: ChatModel, fallback: ChatModel | None = None):self.primary = primaryself.fallback = fallbackdef complete(self, prompt: str) -> str:try:return self.primary.complete(prompt)except Exception:if self.fallback is None:raisereturn 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.
