How to Choose and Integrate Chinese LLMs: A Practical Engineering Guide
This guide reframes the problem of choosing a Chinese large language model as three engineering questions: capability fit, integration feasibility, and total cost of ownership. It covers building a tiered evaluation set, designing automated metrics, implementing resilient inference clients with retries and fallbacks, planning capacity from latency distributions, and using a weighted decision matrix. A deployment checklist and common pitfalls are included.
1. Why Model Selection Became an Engineering Problem
Over the past year, Chinese large language models have been iterating quickly, and flagship models are now routinely available on general-purpose inference platforms. A cloud vendor’s model inference platform—effectively a “model marketplace”—used to host mostly open-source models from abroad; it now also offers general-purpose and coding models from leading Chinese providers. For developers, this creates a new problem: supply has increased, but the cost of choosing has gone up with it.
This article does not evaluate any specific model or platform. Instead, it reframes “which one should I pick” into three answerable engineering questions:
- Capability fit: which capability dimensions does the task require, and where do candidate models stand relative to each other on those dimensions;
- Integration feasibility: is the inference service stable and available, and do the interface shape, concurrency limits, and context length meet business needs;
- Total cost of ownership: the combined cost of per-request price, latency distribution, failure retries, and operational effort.
2. Capability Evaluation: Translating Leaderboard Rankings into Business Metrics
Public benchmarks (such as evaluation sets aimed at web generation tasks) offer coarse-grained horizontal comparisons, but benchmark scores and business outcomes are not linearly related. A more reliable approach is to build your own evaluation set.
2.1 Build a Tiered Evaluation Set
- L0 smoke set (20–50 items): covers core scenarios, used for fast regression on every change;
- L1 scenario set (200–500 items): sampled from the real business distribution, including boundary and abnormal inputs;
- L2 adversarial set (50–100 items): long context, multi-turn coreference, strict format constraints, injection attacks, and so on.
2.2 Metrics Must Be Automatically Judgeable
Subjective scoring is hard to reproduce, so prefer metrics that can be judged automatically:
# Skeleton for automatically judgeable scoringdef score(sample, output):checks = {"schema_valid": validate_json(output, sample["schema"]),"tests_pass": run_unit_tests(output, sample["tests"]),"no_leak": not contains_secret(output),"latency_ok": sample["latency_ms"] <= sample["max_latency_ms"],}return sum(checks.values()) / len(checks)
For generation tasks, a three-stage approach works well: rule validation, model review, and human spot checks. Have humans review only low-confidence samples to keep costs under control.
3. Inference Integration: Stability Over Peak Performance
Calling a model on a general-purpose inference platform means facing a shared, elastic, possibly rate-limited HTTP service. Engineering-wise, assume instability by default.
3.1 Essential Client Capabilities
- Timeouts and retries: distinguish retryable errors (rate limits, 5xx) from non-retryable ones (invalid parameters);
- Exponential backoff with jitter to avoid retry storms;
- Idempotency keys to prevent duplicate billing and duplicate side effects;
- Streaming output, since time to first byte matters more to perceived experience than total duration.
import time, random, requestsdef call_with_retry(payload, url, max_retry=3):for i in range(max_retry):try:r = requests.post(url, json=payload, timeout=30)if r.status_code < 500:return r.json()except requests.RequestException:passtime.sleep(min(8, 2 ** i) + random.random())raise RuntimeError("upstream unavailable")
3.2 Fallbacks and Degradation
When upstream requests queue or hit rate limits, there must be a clear strategy: switch to a backup model, shorten the context, return a cached result, or return a readable degradation message. The degradation path must be covered by monitoring; otherwise failures degrade silently.
4. Performance and Cost: Look at Distributions, Not Averages
Latency on shared inference services typically follows a long-tailed distribution. Planning capacity from average latency alone leads to serious misjudgments.
- Track P50/P95/P99 and time to first byte;
- Estimate cost in tokens; separate pricing for input and output is the industry norm;
- Reduce unit cost through prompt compression, retrieval snippet trimming, and result caching;
- For batch offline tasks, use queues to smooth peaks and spread peak pressure.
Illustrative capacity estimation logic:
Daily QPS_avg = daily requests / 86400Peak factor k (empirically 3–10)Required concurrency ≈ QPS_avg * k * average processing time (seconds)
5. Selection Decision Matrix: Turning Subjective Preference into Explainable Scores
Use a weighted matrix instead of “it just feels better.” Weights are confirmed by the business side; scores come from L1/L2 evaluations and load test results.
| Dimension | Weight | Notes |
|---|---|---|
| Task accuracy | 0.35 | Pass rate on your own evaluation set |
| Latency P95 | 0.20 | Affects interactive experience |
| Unit cost | 0.20 | Converted per token |
| Context and format compliance | 0.15 | Long documents, strict JSON |
| Ecosystem and operability | 0.10 | Monitoring, logging, rate limit adaptation |
The value of the matrix is that it is reviewable: whenever the model or prompt changes, you can explain where score changes came from.
6. Common Pitfalls
- Leaderboard-only thinking: benchmark tasks differ greatly from the business distribution, making migration costly;
- Ignoring the long tail: capacity planned on averages causes widespread timeouts at peak;
- No evaluation set: every model switch relies on “trying a few cases,” with no regression;
- Tight coupling between prompts and models: switching models breaks everything, with no abstraction layer;
- Missing security: no input filtering or output validation leaves injection and leakage risks.
7. Deployment Checklist
- Build L0/L1/L2 tiered evaluation sets and integrate them into continuous integration;
- Implement retries, backoff, idempotency, streaming, and timeouts in the client;
- Configure fallback paths and alerts covering rate limiting and queuing scenarios;
- Complete selection review with the weighted matrix and keep decision records;
- Review cost and latency distributions monthly, and adjust models and prompts dynamically;
- For enterprise-grade workloads, evaluate general capabilities such as the container platform, log service, and monitoring and alerting offered by Baidu AI Cloud, for unified operations and observability.
8. Conclusion
A richer supply of models does not automatically make selection easier. What really determines success is the slow work of three things: the evaluation system, integration resilience, and cost governance. Turning selection into an engineering process that is measurable, regression-testable, and reviewable is what keeps output stable amid rapid model iteration.
