Abstract
Multi-task learning (MTL) concurrently trains a model on diverse task datasets to exploit common features, thereby improving overall performance across the tasks. Recent studies have dedicated efforts to merging multiple independent model parameters into a unified model for MTL, thus circumventing the need for training data and expanding the scope of applicable scenarios of MTL. However, current approaches to model merging predominantly concentrate on enhancing performance within in-domain (ID) datasets, often overlooking their efficacy on out-of-domain (OOD) datasets. In this work, we proposed LwPTV (Layer-wise Pruning Task Vector) by building a saliency score, measuring the redundancy of parameters in task vectors. Designed in this way ours can achieve mask vector for each task and thus perform layer-wise pruning on the task vectors, only keeping the pre-trained model parameters at the corresponding layer in merged model. Owing to its flexibility, our method can be seamlessly integrated with most of existing model merging methods to improve their performance on OOD tasks. Extensive experiments demonstrate that the application of our method results in substantial enhancements in OOD performance while preserving the ability on ID tasks.
Introduction
In the current "pre-train then fine-tune" paradigm, researchers often develop a library of specialized models tailored for specific domains, such as medical imaging or satellite photography. Model merging has emerged as a computationally efficient shortcut to create a single multi-task model by mathematically combining the weights of these specialists without the need for expensive retraining.
However, a significant challenge remains: fine-tuning often "distorts" the generalized features learned by the original pre-trained model (PTM) to fit a specific dataset. When these fine-tuned models are merged, the resulting model typically performs well on the specific tasks it was trained for (In-Domain or ID) but fails to generalize to new, unseen data (Out-of-Domain or OOD). This "generalization gap" effectively erodes the zero-shot capabilities of the original PTM. To address this, we introduce LwPTV (Layer-wise Pruning Task Vector), a plug-and-play method that identifies and prunes redundant updates at the layer level, restoring robust generalization while maintaining specialist performance.
Methodology
LwPTV treats fine-tuning updates as "task vectors" ($\tau$), representing the difference between fine-tuned weights and original pre-trained weights. The core innovation is a Layer-wise Saliency Score based on the hypothesis that updates consistent across many tasks are likely redundant noise that interferes with generalization, whereas variable updates contain critical task-specific information.
- Saliency Calculation: For every layer, the method calculates how much each task's update deviates from the mean update across all tasks.
- Adaptive Pruning: Layers with the lowest saliency scores are pruned (set to zero). Pruning a task vector at a specific layer causes the merged model to revert to the original, robust pre-trained weights for that layer.
- Shared Masking: To prevent the loss of critical task-specific information, an OR operation is used: if any task identifies a layer as highly salient, that layer is preserved in the final merged model.
LwPTV is designed to be "plug-and-play," allowing it to be integrated into existing merging algorithms such as Task Arithmetic, Ties-Merging, or AdaMerging.
Experiments and Results
The researchers evaluated LwPTV across vision and language domains, using the H-score (the harmonic mean of ID and OOD performance) to measure the balance between specialization and generalization. Vision tests included 8 ID datasets (e.g., Stanford Cars, EuroSAT) and 13 OOD datasets (e.g., ImageNet-1k, PCAM). NLP tests utilized the T5-large model on various ID and OOD tasks.
Key Findings
- Significant OOD Boost: On the ViT-B/32 architecture, adding LwPTV to the standard Task Arithmetic baseline improved OOD accuracy by nearly 10% and the overall H-score by 7.4%. As shown in Figure 1, LwPTV consistently improves the OOD robustness of various merging baselines.
- Efficiency: LwPTV is highly efficient. On a large ViT-H/14 model, the pruning process takes approximately 9 seconds, significantly faster than parameter-wise methods which can take over 30 minutes.
- Storage Optimization: By pruning entire layers, LwPTV can reduce the storage footprint of task vectors by up to 50%.
Conclusion
LwPTV offers a robust solution to the generalization gap in model merging by identifying and pruning redundant layer-wise updates. By maintaining a "pre-trained anchor" for non-essential layers, the method preserves the model's broad capabilities while enabling multi-task specialization. Future research will explore applying these strategies to heterogeneous architectures and complex generative models like Large Language Models (LLMs), where task conflicts are more prevalent.
Summary updated