How to Choose and Use Open-Source Chinese LLMs: A Practical Guide for Developers
Selecting and deploying open-source Chinese large language models involves more than comparing benchmark scores. This guide walks developers through the full decision process: understanding what "open source" actually means for model weights and licenses, selecting models based on business tasks rather than leaderboards, choosing between full fine-tuning and LoRA/QLoRA, managing inference trade-offs among VRAM, throughput, and latency, building application layers with RAG and agents, and mitigating common risks such as licensing, data security, outdated knowledge, and cost overruns. A sample intent-recognition and response pipeline with failure handling is included.
How to Choose and Use Open-Source Chinese LLMs: A Practical Guide for Developers
1. First, Understand What “Open Source” Actually Means
Many people equate “open source” with publicly available code. For large language models, you need to break the concept down: Are the model weights downloadable? Is the training code public? Is the training data disclosed? What uses does the license permit? The combination of these factors determines what your team can actually do.
A model whose weights are downloadable but whose license restricts commercial use is fine for internal validation, but not for embedding directly into a paid product. Before selecting a model, open the license file on the model’s page and review the clauses on commercial use, redistribution, and publishing modified versions, one by one. Licenses are set by the rights holder and terms may change between versions, so re-check them with every upgrade.
2. Model Selection: Work Backward from the Task
The starting point for selection is your business task, not a leaderboard. You can filter candidates with four questions:
- What capabilities does the task require? Classification, information extraction, and summarization can usually be handled by smaller models; multi-step reasoning and complex code generation demand larger ones.
- What are the latency and concurrency requirements? Online customer service cares most about time to first token; offline batch processing cares most about throughput.
- Can the data leave your environment? When personal information, medical records, or undisclosed financial data is involved, prioritize private deployment.
- How much operations overhead can the team handle? The larger the parameter count, the greater the investment in VRAM, networking, and monitoring.
Benchmark scores are a useful reference, but read the methodology carefully. The same model can score very differently across evaluation sets, prompt templates, and decoding parameters. When evaluating scores, record three things: the name of the evaluation set, the evaluation version, and the source of the test scripts. A score missing any of these is a clue, not a basis for decisions.
A more reliable approach is to build a small evaluation set from your own data. Collect 100 to 300 real business samples covering common cases and edge cases, annotate the reference answers manually, then run every candidate model through the same script. This kind of evaluation is inexpensive and directly answers the question: “Which model is more stable in my business?”
3. Fine-Tuning: Full-Parameter vs. Low-Rank Adaptation
Full-parameter fine-tuning updates all of the model’s weights. It has a higher ceiling for domain adaptation, but it requires substantial VRAM, more training data, and more careful hyperparameter tuning. With insufficient data, full fine-tuning easily overfits and can degrade the model’s original general capabilities.
LoRA adds a small number of trainable low-rank matrices alongside the original weights and trains only these new parameters. VRAM usage drops significantly and training is faster, making it suitable for scenarios with moderate data volume and limited resources. QLoRA goes further by quantizing the base model to 4-bit, reducing VRAM requirements even more. The trade-offs are a more complex training pipeline and quantization-induced precision loss that must be checked during evaluation.
Three conditions can guide the decision: the scale and quality of available training data, available VRAM, and how deeply the business depends on domain knowledge. If you only need to adjust output format or tone, a small amount of data plus LoRA is usually sufficient. If the model must master extensive professional terminology and reasoning patterns, consider full fine-tuning or continued pre-training—but budget a longer experimentation cycle.
Before fine-tuning, always try prompt engineering and retrieval-augmented generation first; many problems are solved at that stage. Fine-tuning has real costs, and its benefits must be verified with the same evaluation set.
4. Inference Deployment: The Trade-Off Between Throughput and VRAM
Inference deployment revolves around three metrics: VRAM, throughput, and latency.
Quantization is a common way to reduce VRAM usage. FP16 retains relatively high precision; INT8 and INT4 use less VRAM but may lose precision on complex reasoning or mathematical computation. Before deployment, compare results at different precisions on your own evaluation set—don’t just look at the percentage of VRAM saved.
The KV cache stores key-value vectors of historical tokens to avoid redundant computation. It consumes substantial VRAM, which is especially noticeable in long-context scenarios. Continuous batching dynamically schedules across requests to improve GPU utilization. Inference frameworks such as vLLM implement these mechanisms and provide an OpenAI-compatible server API, making it easy to swap into existing calling code. llama.cpp is better suited for running quantized models on personal computers or edge devices.
A recommended deployment sequence: first get the service running on a single GPU and record time to first token, tokens generated per second, and peak VRAM; then decide whether to use multi-GPU parallelism or add replicas based on concurrency needs; finally, configure health checks, timeouts, and rate limiting. Never change the model, quantization method, and framework version all at once—if something breaks, you won’t be able to isolate the cause.
Cost estimation should be based on measured data. Plugging single-GPU throughput, average request length, and target concurrency into the calculation gives you the required number of GPUs. Cloud billing models, reserved-instance discounts, and idle time all affect final cost, so rely on actual bills.
5. The Application Layer: RAG and Agents
Open-source models have parametric knowledge with a cutoff date and generally contain no internal enterprise information. Retrieval-augmented generation (RAG) combines external document retrieval with model generation, making the basis of each answer traceable. Vector databases such as Milvus and FAISS handle the storage and retrieval of text embeddings. Retrieval quality directly determines answer quality, so document chunking strategy, embedding model selection, and re-ranking all need testing.
Agents add tool calling, multi-step planning, and state management on top of the model. They fit tasks like querying orders, invoking calendars, or executing fixed workflows. When using agents, restrict the range of callable tools, require human confirmation for write operations, and log every call for auditing.
Below is illustrative code for an intent-recognition and response pipeline. It will not run as-is: build_messages, vector_db, llm_client, and safety_checker must be implemented for your actual environment, and dependencies and versions must be confirmed by you.
import logginglogger = logging.getLogger("support_agent")FALLBACK_REPLY = "Sorry, I can't answer that right now. Transferring you to a human agent."def answer_query(query: str, chat_history: list[dict]) -> str:# 1. Retrieve relevant documents; set top_k and a similarity threshold# to avoid injecting irrelevant contenttry:hits = vector_db.search(query, top_k=5, min_score=0.6)except Exception:logger.exception("Vector search failed, query=%r", query)return FALLBACK_REPLYcontext = "\n\n".join(h.text for h in hits) if hits else ""# 2. Build the prompt; limit history turns to control context lengthmessages = build_messages(query, context, chat_history[-6:])# 3. Call the model with a timeout and a generation length captry:reply = llm_client.chat(messages, temperature=0.3,max_tokens=512, timeout=10)except TimeoutError:logger.warning("Model response timed out, query=%r", query)return FALLBACK_REPLYexcept Exception:logger.exception("Model call failed, query=%r", query)return FALLBACK_REPLY# 4. Output safety check; fall back to a human if it failsif not safety_checker.validate(reply):logger.info("Output failed safety check; falling back to human")return FALLBACK_REPLYreturn reply
The point of this code is the failure paths. Retrieval failure, model timeout, and failed safety checks all fall back to a human agent and are written to the logs. Logs should record request identifiers and latency, but must not record users’ sensitive personal information. After launch, monitor the fallback rate, average latency, and user satisfaction, and adjust retrieval thresholds and prompts accordingly.
6. Common Risks and How to Handle Them
First, license risk. Verify license terms before commercial use and keep a record of the review.
Second, data security. Publicly available weights do not mean safe training data. A model may reproduce sensitive content from its training data or produce biased statements. Run adversarial testing before launch, covering scenarios such as induced leakage, unauthorized instructions, and harmful content. Deploy sensitive-information filtering on the output side and perform necessary de-identification on the input side.
Third, outdated knowledge. Model knowledge stops at the training cutoff date. For time-sensitive businesses, update the vector store regularly and label answers with information sources and dates.
Fourth, runaway costs. Long contexts, high concurrency, and automatic retries can amplify expenses rapidly. Set usage caps, apply per-user rate limits, and cap the number of retries.
Fifth, evaluation bias. If the internal evaluation set heavily overlaps with training data, scores will be inflated. Update the evaluation set regularly and cross-check it against real production samples.
7. Pre-Launch Checklist
Before going live, confirm each of the following:
- The model license has been reviewed and usage restrictions have been documented.
