Model Merging for Efficient LLM Reasoning: Technical Approach and Engineering Workflow

    This article examines model merging as a training-free way to build a new model from multiple trained parent models, with a focus on Mixture of Experts (MoE) architectures. It covers expert-level selective merging, shared and attention layer choices, interpolation coefficient search, a five-step engineering workflow, comparison with continued training, distillation, and quantization, as well as evaluation metrics, risks, and adoption recommendations.

    1. Background

    Large language models continue to improve on complex reasoning tasks, but inference costs are rising alongside those gains. The number of generated tokens directly determines compute overhead and response time. If a model tends to produce long explanations and repeatedly verify itself, even a correct answer can lead to longer waits and higher compute consumption. As a result, the industry is increasingly asking whether a model can give more concise answers while maintaining its reasoning ability.

    Common approaches include continued training to compress output style, knowledge distillation so that a smaller model imitates a larger one, quantization to reduce memory usage, and prompt constraints to limit response length. Each method has costs. Retraining requires substantial compute and high-quality data. Distillation depends on the quality of the teacher model’s outputs. Quantization may damage reasoning accuracy. Prompt constraints are unstable, and the model may still expand its reasoning when faced with difficult problems.

    Model merging offers another path. It does not require a new training process. Instead, it directly combines the parameters of multiple trained models to construct a new model that combines different characteristics.

    2. Core Approach: Assembling a New Model from Parent Models

    2.1 Separability of Mixture of Experts Architecture

    A Mixture of Experts (MoE) architecture splits the feed-forward network into many expert sub-networks, and each input token activates only a small number of them. A router decides which experts are activated. The advantage of this structure is that it provides a large parameter scale with a small amount of computation per pass.

    For merging tasks, the value of MoE lies in its fine granularity. Experts from different parent models can be independently compared, replaced, or interpolated without replacing the entire model. This allows merging operations to be performed at the tensor level. Computational complexity is roughly linear with the number of parameters, and there is no need for repeated forward inference to search for combinations.

    2.2 Selective Merging of Routed Expert Tensors

    The basic operation of selective merging is as follows: for each layer and each routed expert, select the corresponding tensor from several candidate parent models, then interpolate or replace it according to certain weights. Selection rules can be based on expert activation statistics on specific tasks or on manually defined capability labels.

    The key at this step is to keep tensor shapes consistent and to ensure that the correspondence between the router and the experts is not broken. If expert indices have different meanings in different parent models, direct merging will cause routing mismatch and noticeably degrade output quality. Therefore, the expert alignment relationship among parent models must be confirmed before merging.

    2.3 Trade-offs Between Shared and Attention Layers

    Shared layers and attention layers apply to all tokens and determine the model’s basic representation ability and generation style. In practice, a common approach is to retain the shared layers and attention layers from one parent model, because they determine the conciseness and speed of responses at the overall behavior level. Routed experts are then selected as needed from parent models with stronger capabilities.

    The logic behind this division is that capability is mainly stored in expert parameters, while style and efficiency are mainly determined by the shared parts. However, this assumption must be validated through evaluation and cannot be treated as a definitive conclusion.

    2.4 Determining Interpolation Coefficients

    Interpolation coefficients determine the contribution ratio of each parent model. When coefficients lean toward one parent model, the merged result is closer to that parent model. When coefficients are too close to a uniform distribution, the merging effect may be insignificant. In engineering practice, candidate values are usually searched on a discrete grid, each candidate set is evaluated on a validation set, and the set with the best overall score is selected. The search space should be kept small to control evaluation cost.

    3. Engineering Workflow

    A complete merging process usually includes five steps:

    1. Define the objective: clarify the capability to improve, such as mathematical reasoning or code generation, and the metrics to control, such as average output length and time to first token.
    2. Select parent models: choose candidate models that perform well on the target capability and have compatible architectures. Models with inconsistent architectures cannot be directly merged.
    3. Align and check: verify the number of experts, number of layers, tensor shapes, and vocabulary settings.
    4. Execute merging: perform interpolation and selection by layer and by expert, and record the source of each step for traceability.
    5. Evaluate and regress: test on both target tasks and general tasks, and check for capability degradation or changes in safety behavior.

    The following illustrative code shows the structure of the merging logic. It is not a runnable implementation, and actual engineering work needs to add details based on the specific architecture:

    1. def merge_moe_layer(parents, weights, router_source):
    2. """Merge Mixture of Experts parameters by layer (illustrative)."""
    3. merged = {}
    4. # Shared layers and attention layers: reuse the specified parent model
    5. merged["shared"] = parents[router_source]["shared"]
    6. merged["attention"] = parents[router_source]["attention"]
    7. # Routed experts: interpolate same-index experts from each parent model by weight
    8. num_experts = parents[router_source]["num_experts"]
    9. merged["experts"] = []
    10. for e in range(num_experts):
    11. tensor = None
    12. for name, w in weights.items():
    13. part = parents[name]["experts"][e] * w
    14. tensor = part if tensor is None else tensor + part
    15. merged["experts"].append(tensor)
    16. return merged

    The key points in the code are that expert indices must be aligned first, the sum of weights should be agreed in advance (usually 1), and the source of each step must be recorded.

    4. Comparison with Other Approaches

    Different approaches suit different constraints. The table below provides a brief comparison:

    Approach Training cost Data dependency Main risk Applicable scenario
    Continued training High Requires large-scale, high-quality data Forgetting existing capabilities The overall capability system needs improvement
    Knowledge distillation Medium to high Depends on teacher model outputs Student model capability ceiling is limited Small model deployment is required
    Model quantization Low Usually requires a small amount of calibration data Precision loss Memory or bandwidth is constrained
    Model merging Low (no training required) Requires a validation set for parameter selection Capability is hard to predict and requires repeated evaluation Multiple usable parent models already exist and fast combination is needed

    The advantage of merging is speed and low cost. The disadvantage is that results depend on parent model quality, and behavior is difficult to predict in advance, so thorough evaluation is required.

    5. Evaluation Metrics and Validation Methods

    Evaluation should cover three types of metrics:

    • Capability metrics: accuracy on tasks such as mathematical reasoning, code, and knowledge question answering. Use a fixed internal evaluation set and compare item by item with each parent model.
    • Efficiency metrics: average number of generated tokens, time to first token, and end-to-end response time. Efficiency comparisons should be conducted on the same hardware and with the same request batch.
    • Safety and stability metrics: refusal behavior, harmful content trigger rate, and output format compliance rate. Merging may change the model’s alignment characteristics, so these need to be tested separately.

    Evaluation samples need to be representative. If the evaluation set heavily overlaps with the parent models’ training data, scores will be inflated and will not reflect true capability. It is recommended to keep a set of private held-out samples for final acceptance.

    6. Risks and Considerations

    1. License compliance: before merging, confirm the license terms of each parent model, including whether modification, redistribution, and commercial use are allowed. The merged model remains subject to the original licenses.
    2. Capability degradation: after some experts are replaced, existing capabilities may fail in edge cases. Build a regression test set covering long context, multilingual use, and tool calling.
    3. Overly short outputs: excessive pursuit of conciseness may compress the reasoning steps for complex problems and reduce accuracy. Clear thresholds should be set between efficiency and accuracy.
    4. Reproducibility: record parent model versions, interpolation coefficients, expert selection strategy, and random seeds to ensure results can be reproduced.

    7. Adoption Recommendations

    Teams trying this technology can proceed in the following order. First, validate the method in a small-scale experimental environment and confirm that parent model alignment and the merging process are stable. Next, build a complete evaluation system and put capability, efficiency, and safety metrics on the same dashboard. Finally, launch in a canary environment with a small amount of traffic, observe performance under real requests, and retain the ability to roll back quickly.

    Model merging is not a one-time engineering action but a process of continuous iteration. New parent models keep appearing, and teams need to repeatedly evaluate and combine them so that the balance between inference efficiency and capability remains within an acceptable range.