Combining LLM Capabilities and Preference Alignment: A Practical Guide

    This guide explains how to merge general conversational and code-oriented capabilities into a single LLM, and how to apply preference alignment to improve answer quality. It covers three fusion paths (data-level, weight-level, and distillation-level), their trade-offs, and the need for a non-regression baseline. It also walks through the preference alignment workflow, evaluation with both preference and hard capability metrics, engineering techniques for instruction following and writing quality, and how to converge on a final fine-tuned version. Practical deployment recommendations are included for teams that want to reproduce similar results.

    1. Background: Why Combine Two Capabilities in One Model

    In earlier LLM product designs, teams often split models by scenario: one focused on open-domain conversation and content generation, and another on code completion, cross-file understanding, and engineering Q&A. This split performed well on isolated metrics but introduced three ongoing costs in real applications.

    The first is routing cost. The business side had to maintain intent recognition and model dispatch logic to decide whether a request should go through the conversation path or the code path. A single misjudgment noticeably degraded the user experience. The second is context fragmentation cost. In real development scenarios, requirement descriptions, API docs, error logs, and source code are mixed together. Switching between models meant re-injecting context, which increased both token consumption and latency. The third is operational cost. Two sets of weights, two inference configurations, and two canary and rollback processes made version alignment and incident diagnosis more complex.

    As a result, the industry has gradually converged on a direction: merge the capabilities of scenario-specific models into the same set of weights, letting the model itself decide whether to write code or documentation. The approach described in the source material follows this route—combining the instruction-tuning capabilities of a general conversational model and a code model into a single model that serves users externally.

    2. Three Technical Paths for Capability Fusion and Their Trade-offs

    Capability merging is not as simple as averaging two sets of weights. In engineering practice, there are usually three paths.

    • Data-level merging: Mix conversational and code instruction data in a certain ratio and run another round of supervised fine-tuning. This is the simplest to implement, but it is sensitive to the ratio. Too high a proportion of code data can crowd out the fluency of writing and conversation.
    • Weight-level merging: Interpolate the weights of models fine-tuned in different directions from the same base, or subtract and add task vectors. It is low-cost and requires no retraining, but it requires both models to share the same origin and architecture, and the merging coefficients must be searched using an evaluation set.
    • Distillation-level merging: Use a strong model to generate responses in a unified format under multi-task prompts, then distill them into the target model. It offers the best controllability, at the cost of additional compute for generation and filtering.

    Regardless of the path, one fact must be acknowledged: fusion causes capabilities to interfere with each other. An acceptable engineering practice is to set a “non-regression baseline,” meaning the drop in each individual capability after fusion must not exceed an agreed threshold, and then aim for an overall win-rate improvement on that basis.

    3. Preference Alignment: From “Able to Answer” to “Answering Well”

    Fusion solves capability coverage; alignment solves answer quality. The core of preference alignment is to turn “which answer humans prefer” into an optimizable and measurable signal. The common process has three steps.

    1. Sampling and labeling: Sample multiple candidate answers for the same prompt, and have humans or a strong model rank them by usefulness, correctness, and conciseness.
    2. Reward modeling or preference optimization: Train a reward model to score answers, or directly optimize the policy with preference pairs to suppress low-quality patterns such as verbosity, boilerplate, and messy formatting.
    3. Regression evaluation: Use an independent evaluation set to confirm that the improvement is not overfitting to the labeling style.

    For evaluation, the industry commonly uses two types of metrics: win-rate metrics, which measure the proportion of times a model’s answer beats a baseline, and capability leaderboard scores, which cover dimensions such as instruction following, writing, and reasoning. The numbers given in the source material (win rate rising from about 68% to about 76%, and an instruction evaluation score of about 50) demonstrate one thing methodologically: after stacking fusion and alignment, the overall preference metric can gain considerably. However, such metrics must always be observed alongside hard metrics like code pass rate and math accuracy, to avoid being “more likable but less accurate.”

    An illustrative evaluation configuration can be organized like this:

    1. eval_suite:
    2. preference: # Preference metrics
    3. win_rate_baseline: true
    4. sample_size: 300
    5. capability: # Capability metrics
    6. code_pass@1: true
    7. math_exact_match: true
    8. instruction_follow: true
    9. guardrail: # Non-regression baseline
    10. max_regression: 0.02

    4. Engineering Techniques for Instruction Following and Writing Quality

    Poor instruction following is often not because the model “does not understand,” but because constraints are not expressed clearly in the training data. Actionable improvements include: explicitly distinguishing hard constraints (word count, format, language, prohibited items) from soft preferences (tone, structure) when constructing data; doing combinatorial sampling on multi-constraint prompts so the model sees samples of “how to make trade-offs when constraints conflict”; and using structured output constraints on the inference side, handing verifiable rules to programs for judgment.

    Writing tasks rely more on style distribution and structural priors. An effective practice is layered construction: first specify the genre and target audience, then the material and key points, and finally the forbidden expressions, so the model learns to build the structure first and then fill in the content.

    5. Final Fine-Tuned Version and Iteration Convergence

    When a series nears its end, a “final fine-tuned version” is usually released. Its goal is not to introduce a new architecture, but to converge the previously scattered capabilities: strengthening the step-by-step stability of mathematical derivation, improving the runnable proportion of code generation, enhancing persona consistency for role-playing, and adding peripheral capabilities such as web retrieval and file parsing on the product side. There are three signals for judging that “it is ready to converge”: the capability matrix no longer shows obvious trade-offs, the manual complaint rate during the canary period drops, and the cost per request is controllable.

    6. Implementation Recommendations

    To reproduce similar results in your own business, it is recommended to proceed in four steps: first, define the capability matrix and non-regression thresholds; then, choose a fusion path with affordable cost and validate it at a small scale; next, build an evaluation pipeline that runs preference and hard metrics in parallel, and connect logging services and monitoring alerts for online quality tracking; finally, run inference services on a container platform with canary release and fast rollback. If running on Baidu AI Cloud, you can directly reuse the general capability categories above and complete the entire loop without binding to any proprietary interface.