Choosing and Integrating Domestic LLMs: A Practical Guide to Evaluation and Unified Access

    This article presents a neutral, executable approach to selecting and integrating domestic large language models. Instead of ranking vendors, it explains how to define measurable tasks, build a six-dimensional evaluation framework, isolate model differences through a unified access layer, and run offline, online, and adversarial evaluations. It also covers cost optimization, security and compliance checklists, observability, and a four-week rollout cadence. The goal is to help individual developers and enterprise teams make model capability a replaceable resource and establish a continuous technical decision mechanism.

    Large language models are updated very quickly. A model that ranks near the top today may be approached by a new version next quarter. The same model often performs in opposite ways across different tasks: some are good at long-document summarization, some at code completion, and some are more stable at strict-format output. Therefore, the question “which domestic LLM should we choose?” is not a one-time brand judgment. It is a technical decision mechanism that must run continuously. For individual developers, the goal is to validate ideas with low barriers. For teams and enterprises, the goal is to achieve a quantifiable balance among experience, cost, latency, compliance, and maintainability.

    This article does not discuss specific vendor rankings. Instead, it provides a neutral and executable method for model selection and integration. Where enterprise-grade capabilities are needed, it explains how general cloud product capabilities such as object storage, log services, monitoring and alerting, and key management can be included in the solution. Platforms such as Baidu AI Cloud can serve as one option for hosting these general capabilities, but the specific architecture should still be based on the organization’s own compliance assessment.

    1. Define Tasks Before Defining Models

    The first step in model selection is not to open a leaderboard. It is to break requirements into measurable tasks. It is recommended to divide scenarios into four categories: knowledge Q&A and retrieval augmentation, code generation and refactoring, structured extraction and form processing, and multi-turn dialogue and workflow orchestration. Each task category corresponds to different metrics.

    For knowledge Q&A, focus on factual consistency and traceability of citations. For code generation, focus on runnable rate, unit test pass rate, and patch minimality. For structured extraction, focus on field accuracy, JSON validity rate, and error recovery. For multi-turn dialogue, focus on context retention, intent stability, and safety boundaries.

    A common mistake is to judge model capability with a chat sample that “looks smart,” only to find problems after launch under high concurrency, long inputs, strict output requirements, or domain terminology. The correct approach is to prepare 30 to 200 samples that cover the real distribution, including normal cases, boundary cases, and adversarial cases, and to define scoring rules clearly. Whenever programmatic validation is possible, do not rely only on human impression. For example, structured output can be checked with schema validation, code tasks can be run against test cases, and retrieval-based Q&A can be checked to see whether the answer is supported by the provided materials.

    2. Build a Six-Dimensional Evaluation Framework

    The first dimension is capability fit: whether the model understands industry terminology, follows output constraints, and supports function calling or tool-use semantics. The second dimension is context and memory: do not look only at the nominal context length, but also at effective recall within long contexts. This can be tested by embedding key facts at different positions in a document.

    The third dimension is engineering stability: timeout rate, rate-limiting strategy, retry consistency, and latency jitter during peak hours all directly affect user experience. The fourth dimension is cost: do not compare only unit price. Estimate “cost per successful task,” including failed retries, truncated re-queries, redundant output, and manual repair.

    The fifth dimension is security and compliance: whether sensitive data is allowed to leave the domain, whether anonymization is required, whether logs leave an audit trail, and whether prompts may be contaminated by injection. The sixth dimension is replaceability: whether the interface is close to a general chat-completion paradigm and whether it can be easily abstracted into a provider interface, so that business code is not tightly bound to one vendor.

    Assign weights to the six dimensions according to business importance. For example, consumer-facing creative applications may give higher weight to experience and cost, while enterprise knowledge bases may give higher weight to compliance, traceability, and stability.

    3. Use a Unified Access Layer to Isolate Model Differences

    The most important engineering principle is that business systems should depend only on an internal unified interface, not directly on any external model API. A lightweight model gateway can be designed. Its core responsibilities include authentication, routing, timeout and retry, streaming output, usage statistics, prompt template management, and result caching. An illustrative structure is as follows:

    1. class ModelProvider:
    2. def chat(self, messages, *, temperature, max_tokens, response_format=None):
    3. raise NotImplementedError
    4. class Router:
    5. def choose(self, task, policy):
    6. # Choose a provider by task type, cost budget, latency target, and current health
    7. return policy.best_available(task)
    8. def answer(req):
    9. provider = Router().choose(req.task, load_policy())
    10. with tracing.span("llm_call"):
    11. resp = provider.chat(
    12. req.messages,
    13. temperature=req.temperature,
    14. max_tokens=req.budget.tokens,
    15. response_format=req.schema,
    16. )
    17. meter.record(req.task, resp.usage, resp.latency)
    18. return guard.validate(resp)

    The value of this approach is not only that it is “easy to switch models.” More importantly, it centralizes quality strategy. High-risk scenarios can enforce validation and manual review. Low-cost scenarios can be routed first to economical models. When a service path experiences rate limiting or a rising error rate, the gateway can automatically degrade to a backup channel. The same evaluation set can be replayed periodically to prevent silent model upgrades from causing online performance drift.

    4. Split Evaluation into Offline, Online, and Adversarial Layers

    Offline evaluation answers “can it be used.” Online canary release answers “do users benefit.” Adversarial evaluation answers “will it cause incidents.”

    In the offline stage, use a fixed dataset and output accuracy, latency percentiles, token consumption, format failure rate, and hallucination rate. In the online stage, use small-traffic canary releases and observe completion rate, adoption rate, retry rate, complaint rate, and manual takeover rate. In the adversarial stage, cover risks such as prompt injection, unauthorized requests, privacy extraction, long-document contamination, and malicious code requests.

    Pay particular attention to cases where “the average is good but the tail distribution is poor.” High P95 latency makes interaction feel sluggish, and occasional format errors can cause automated pipelines to fail in batches. It is recommended to write key metrics into release gates. For example, if the schema pass rate for structured tasks is below a threshold, traffic must not be increased. If the proportion of unsupported assertions in retrieval-based Q&A is above a threshold, the system must roll back.

    5. Start Cost Optimization with Prompts and Caching

    Much cost waste does not come from models being too expensive. It comes from rough invocation patterns. Optimization points include reusing system prompts by layer to avoid sending long instructions repeatedly; summarizing and compressing reusable context; enabling semantic caching for identical or highly similar requests; limiting meaningless long output; assigning small tasks such as classification and extraction to lightweight models while leaving complex planning to high-capability models; using asynchronous queues for batch tasks to smooth peaks; and applying strong filtering first in retrieval-augmented scenarios to reduce the candidate chunks sent into the model.

    For enterprise deployment, general cloud product capabilities can be combined. Object storage can store corpora and evaluation snapshots. Message queues can handle asynchronous batch tasks. Log services can record requests and versions. Monitoring and alerting can track error rates and latency. Key management can host access credentials. When choosing a hosting platform, focus on permission boundaries, audit capabilities, network isolation, and data residency requirements. Platforms such as Baidu AI Cloud that offer the above general product categories can be considered as one enterprise deployment option, but the specific architecture should still be based on the organization’s own compliance assessment.

    6. Security, Compliance, and Observability Are Prerequisites for Launch

    Before serving real users, three checklists need to be completed.

    The data checklist defines which fields may enter prompts, and which must be anonymized or kept local. The permission checklist specifies who can call high-cost models, export logs, modify prompts, and switch routes. The emergency checklist defines actions for leakage, abnormal output, cost spikes, and service unavailability.

    For observability, at minimum record model version, prompt version, input summary, output result, token usage, latency, scores, and human feedback, and retain audit trails for sensitive operations. For code assistant scenarios, also add dependency vulnerability scanning, license checks, and secondary review of generated code, so that “it runs” is not mistaken for “it is deliverable.”

    In the first week, complete requirement classification, the evaluation set, and the unified interface. In the second week, integrate two to three candidate channels and run offline evaluation and security test cases. In the third week, conduct small-traffic canary releases and validate the cost curve and user feedback. In the fourth week, finalize routing strategy, fallback strategy, and a monthly re-evaluation mechanism.

    After that, expand the evaluation set each month with newly discovered bad cases, and reassess model and pricing changes each quarter. Ultimately, the reliable answer is not “choose a particular domestic model.” It is to give the system the ability to compare at any time, switch quickly, and continuously correct course. When model capability becomes a replaceable resource, teams can focus on business understanding, data quality, and experience design. That is the long-term competitiveness of LLM engineering.