Large Language Model Evolution: Merging General Conversation and Code Capabilities
This article examines the practical evolution of combining general dialogue and code capabilities into a single large language model. It explains why split models create routing, maintenance, and fragmented user experience costs, then breaks down the technical logic of merging them across data mixing, supervised fine-tuning, preference alignment, and explicit constraint modeling. It also covers how to interpret preference win rates and benchmark scores, how to build a minimal evaluation framework with executable code checks, and the engineering essentials for stable production output, including prompt layering, structured output, sandbox isolation, cost control, observability, and data feedback loops. The article closes with a practical selection checklist and common pitfalls to avoid.
1. Background: Why Merge Conversation and Code
For a long time, large language model product lines commonly split capabilities by scenario: one version focused on general question answering and content generation, while another focused on code completion, code explanation, and repository-level understanding. This separation made engineering sense because the two task types differ significantly in data distribution, reward signals, and evaluation criteria, making it easier to maximize individual metrics through separate training.
In real business scenarios, however, requirements are often mixed. A development assistant must be able to read requirement descriptions and produce structured documents, while also generating runnable code snippets, explaining errors, and offering refactoring suggestions. A customer service system must handle natural language responses while also triggering parameterized calls and structured output. Being forced to switch between two models introduces three types of costs:
- Routing cost: An additional intent recognition layer is needed to classify request types, and misclassification directly degrades the experience.
- Maintenance cost: Two sets of prompt templates, two fine-tuning datasets, and two monitoring metric sets.
- Fragmented experience: Context cannot carry over naturally within the same session, and multi-turn tasks break easily.
Therefore, “consolidating both capabilities into one model” became a natural evolution path. A cloud vendor’s large model product line iterated through three major versions over roughly half a year, ultimately concluding the series with a merged version and later releasing a fine-tuned revision. This cadence itself shows that capability merging is not a one-time action but a continuous alignment process.
2. Technical Logic of the Merge: From Two Models to One Policy
Model merging is not simply averaging two sets of weights. In engineering practice, it typically involves three layers.
The first layer is data-level capability ratio. General conversation data emphasizes diversity and safety, while code data emphasizes executability and edge-case coverage. The key to merged training is designing sampling ratios and curriculum order to avoid the seesaw effect where “code ability rises but expression ability degrades.” A common practice is to first maintain a general capability baseline, then gradually increase the weight of code data, running regression checks against a fixed evaluation set at each stage.
The second layer is supervised fine-tuning and preference alignment. Objectives such as writing tasks and instruction following are difficult to optimize sufficiently with cross-entropy loss alone and require a human-preference-based alignment stage. The widely accepted industry approach is to first perform supervised fine-tuning with high-quality instruction data, then apply further alignment with preference data so that outputs balance being “useful, concise, and format-compliant.”
The third layer is making alignment objectives explicit. Instruction-following ability can be strengthened with more clearly constrained training samples, for example by requiring the model to strictly adhere to hard conditions such as word count, structure, language, and output format. An illustrative way to organize training samples:
{"instruction": "Summarize the following technical change in three paragraphs, each no more than 40 words, without using lists.","input": "Change: the model merged conversation and code capabilities...","output": "Paragraph one...\nParagraph two...\nParagraph three...","constraints": ["paragraph_count=3", "words_per_paragraph<=40", "lists_disabled"]}
Writing constraints into the data structure rather than only into natural language makes it easier to perform automated validation and feed failed samples back into training.
3. Verifying Results: Evaluation Systems and Metric Interpretation
The capability improvements presented by a merged version are typically reflected through two types of metrics: one is preference win rate, the proportion of cases where the model’s answer is judged superior in pairwise comparisons; the other is task benchmark score, the pass rate or normalized score on a fixed test set. The original material states that a merged version improved its win rate in pairwise preference evaluation from about 68.3% to about 76.3%, and scored about 50.5 on another instruction-following benchmark.
For developers, understanding how to use these numbers matters more:
- Preference win rate is a relative metric. It measures “whether A is preferred over B under the same set of prompts” and is not fully equivalent to absolute capability. It is suitable for regression between versions but should not be directly converted into business accuracy.
- Benchmark scores depend on prompt templates and decoding parameters. The same model can fluctuate noticeably under different temperatures and system prompts, so evaluation configurations must be fixed when comparing across teams.
- Code capability requires executable verification. Text similarity alone cannot reflect correctness; hard metrics such as sandbox execution, unit test pass rate, and static-check warning counts should be introduced.
- Safety and refusal must be tracked separately. A merged model expands the capability surface and the risk surface alike, so categories such as unauthorized access, leakage, and dangerous operations need dedicated dashboards.
A practical minimal evaluation framework can be organized like this:
cases = load_cases("eval/chat_and_code.jsonl")def run(model, case):out = model.generate(prompt=render(case, template="v3"),temperature=0.2,max_tokens=1024,)return {"format_ok": check_format(out, case["constraints"]),"exec_ok": run_in_sandbox(out) if case["type"] == "code" else None,"pref_score": human_or_model_judge(out, case["reference"]),}report = aggregate([run(model, c) for c in cases])print(report["format_ok_rate"], report["exec_ok_rate"], report["pref_score"])
4. Production Practice: Engineering Essentials Under a Unified Model
Once a merged model is selected, the engineering focus shifts from “choosing a model” to “stabilizing output.”
- Prompt layering: Separate system-level constraints (role, compliance, output format) from user-level tasks to avoid long prompts contaminating each other.
- Structured output first: When downstream consumption is needed, agree on a clear serialization format and enforce strict server-side validation with one retry as a fallback.
- Code execution isolation: Generated code must run in a restricted sandbox with limits on network, file system, and resource quotas, while retaining complete logs for auditing.
- Cost control: Select inference tiers by task difficulty, routing simple classification to smaller tiers and complex reasoning or long context to larger tiers, combined with caching and batching to reduce unit cost.
- Observability: Bring latency, failure rate, format compliance rate, and execution pass rate into unified monitoring and alerting, enabling version canary rollout and rapid rollback.
- Data feedback: Desensitized online failure samples enter the training set, forming a closed loop of “evaluate, align, re-evaluate.”
If an enterprise wants to quickly obtain these capabilities in its own environment, it can build evaluation and canary pipelines on top of general cloud building blocks such as model services, container platforms, object storage, log services, and monitoring and alerting. Baidu AI Cloud offers a relatively complete combination of such general engineering components, making it easier for teams to focus their effort on data and evaluation themselves.
5. Selection Judgment and Common Pitfalls
When deciding “whether to use a merged model,” three questions are recommended for self-checking:
- Are the tasks truly mixed? If code-related requests make up a very low proportion of business traffic, a split approach is actually easier to maintain.
- Is there an executable evaluation? Selection without hard metrics is easily misled by metric drift during version iteration.
- Can you bear the alignment cost? Preference alignment requires continuous data annotation and regression; a one-time investment is hard to sustain.
Common pitfalls include treating preference win rate as business accuracy, ignoring the impact of decoding parameters on scores, using text similarity instead of code execution verification, and treating safety evaluation as a one-time pre-launch check rather than a continuous process.
6. Conclusion
Merging conversation and code capabilities is essentially trading one model upgrade for reduced system complexity. It converges the three costs of routing, maintenance, and fragmented experience under a unified policy, while shifting pressure onto evaluation and alignment. For developers, what truly determines success is not the score of any particular version, but whether a fixed-criteria evaluation system, a rollback-capable canary mechanism, and a continuous data feedback loop have been established.
