Abstract
Model merging offers a cost-effective way to combine specialized Large Language Models (LLMs) without retraining. However, existing methods like Task Arithmetic often use uniform coefficients, ignoring the varying importance of specific layers and tasks. We present Sens-Merging, a plug-and-play method that dynamically adjusts merging coefficients based on layer-wise parameter sensitivity and cross-task transferability. Our results demonstrate that Sens-Merging significantly outperforms traditional merging techniques, sometimes even exceeding the performance of specialized parent models.
Introduction
The proliferation of specialized LLMs—fine-tuned for specific domains like mathematics, coding, or dialogue—has created a demand for methods that can synthesize these capabilities into a single model. While multi-task retraining is a solution, its computational cost and data requirements are often prohibitive. Model merging techniques, such as Task Arithmetic, Ties, or DARE, provide an alternative by combining "task vectors" (the difference between fine-tuned and base weights).
However, these methods typically apply a single, uniform weight to all parameters across all tasks. This approach fails to account for the fact that different layers contribute differently to specific tasks and that some tasks possess higher generalizability than others. Sens-Merging addresses these limitations by introducing a sensitivity-guided coefficient adjustment strategy.
Methodology
Sens-Merging acts as a plug-and-play enhancement for existing merging techniques. It calculates dynamic merging weights at two distinct levels using a small calibration dataset:
1. Task-Specific Scaling (Layer-wise)
This component estimates parameter sensitivity using a first-order Taylor expansion of the loss function. By approximating how much the model's loss would increase if a specific parameter were zeroed out, the method identifies critical layers for a given task. These sensitivities are aggregated layer-by-layer, assigning higher weights to layers that are essential for task performance.
2. Cross-Task Scaling (Model-wise)
To measure how well one model's knowledge transfers to another task, Sens-Merging compares the output logits of different models on calibration data. If a specialized model's outputs (e.g., a Math model) closely align with another (e.g., a Chat model) on a specific task, measured via L2 distance, that model is deemed to have high cross-task transferability and receives a higher global weight.
The final merging coefficients are derived by multiplying these two scaling factors and normalizing them via a softmax function before applying them to the task vectors.
Experimental Evaluation
The authors evaluated Sens-Merging across seven standard benchmarks spanning three domains:
- General Knowledge: MMLU, HellaSwag, TruthfulQA
- Mathematical Reasoning: GSM8K, MATH
- Code Generation: HumanEval, MBPP
The method was tested on LLaMA2 (7B and 13B) and Mistral 7B architectures using standard zero-shot accuracy and pass@1 metrics.
Key Insights
- Task-Specific Layer Importance: Sensitivity analysis revealed that different tasks rely on different parts of the network. Chat models show peak sensitivity in lower layers (basic language processing), Math models peak in middle layers (logical reasoning), and Code models exhibit a unique dual-peak sensitivity pattern.
- Transferability Dynamics: Mathematical reasoning provides strong transferable skills to other tasks, and chat abilities facilitate general language understanding. In contrast, coding skills are highly specialized and do not transfer well to non-code tasks.
- The Scaling Trade-off: There is a distinct trade-off between the two scaling methods. Task-specific scaling excels at boosting peak performance in narrow domains, while cross-task scaling sacrifices some peak performance for broader, general gains across all tasks.
- Synergy Beats Specialization: Merging models can yield better performance on a specific task than the model fine-tuned exclusively for that task. For example, the combined knowledge of Chat, Math, and Code models created a more effective coder than the standalone Code model.
Results
Sens-Merging demonstrated significant performance gains across all tested configurations:
- Performance Boost: On LLaMA2-7B, adding Sens-Merging to standard Task Arithmetic improved the average score across all benchmarks from 29.03 to 34.78—a 19.22% relative improvement.
- Outperforming Experts: When merging Chat, Math, and Code models, the resulting model scored 33.1 on MBPP and 18.9 on HumanEval. This significantly outperformed the specialized Code model, which scored 26.8 and 5.5, respectively.
- Scalability: The method maintained strong gains when scaled to larger models (LLaMA2-13B) and different architectures (Mistral 7B), proving its robustness.
Limitations and Future Work
While effective, Sens-Merging is currently designed for homogeneous model merging, requiring all models to share the same base architecture. Future research may explore extending this to heterogeneous architectures. Additionally, while the method works well for LoRA fine-tuned models, fully fine-tuned models with massive weight divergences may require further adaptations to ensure stability.
Summary updated