Introduction
In the landscape of deep learning, fine-tuning large pre-trained vision models (like CLIP) for specific tasks is standard practice. However, merging these specialized models into a single, unified architecture capable of handling all tasks simultaneously remains a challenge. Traditional "static merging" techniques—such as averaging weights—often suffer from parameter interference, where optimal weights for one task conflict with those for another. Because these methods seek a single, static set of weights, they frequently land in a suboptimal middle ground that underperforms the individual specialized models.
To address this, researchers have developed a novel approach: Weight-Ensembling Mixture of Experts (WEMoE). By "upcycling" the feed-forward layers of vision Transformers into a dynamic MoE module, the model can automatically route and combine task-specific knowledge based on the input image, effectively mitigating parameter interference without the usual performance trade-offs.
The WEMoE Methodology
Instead of forcing all task knowledge into one static set of weights, WEMoE separates "shared" knowledge from "task-specific" knowledge.
- Task Vectors: A task vector is defined as the difference between a fine-tuned model's weights and the original pre-trained weights.
- Selective Merging: The authors observed that Attention layers in Transformers behave similarly across different tasks. Consequently, these layers are merged using standard linear interpolation (Task Arithmetic).
- Upcycling MLPs: The Multi-Layer Perceptron (MLP) blocks, which encapsulate more task-specific information, are converted into a Mixture of Experts (MoE) module.
- Dynamic Routing: A lightweight router (a small MLP) is introduced. For any given input image, the router analyzes the features and generates dynamic weights to combine the various task vectors on the fly.
- Test-Time Adaptation (TTA): Because original training data is unavailable during merging, the router is trained using entropy minimization on unlabeled test data, encouraging high-confidence predictions.
Key Insights and Model Dynamics
A critical breakthrough in this work is the distinction between how Attention and MLP layers adapt to tasks. By analyzing weight similarities across layers, the authors discovered that Attention layers act as the model's "common sense," while MLPs function as "specialized skills." This justifies applying the complex MoE structure exclusively to the MLPs.
Unlike a static merged model—which acts like a Swiss Army knife with all tools half-open—WEMoE dynamically selects the right tool for the job. Even without explicit task labels, the router demonstrates emergent task identification. By the deeper layers of the network, the router correctly assigns the highest weight to the relevant task vector for the vast majority of samples.
Experimental Results
Evaluated on CLIP-ViT architectures across eight diverse image classification datasets (including SUN397, Stanford Cars, and MNIST), WEMoE demonstrated significant improvements:
- Superior Performance: On the ViT-B/32 benchmark, WEMoE achieved an average accuracy of 89.4%, outperforming the traditional Multi-Task Learning (MTL) baseline (88.9%) and significantly beating other merging methods like Task Arithmetic (69.0%) and AdaMerging (81.1%).
- Robustness: WEMoE proved remarkably stable against image corruptions like motion blur or Gaussian noise. A simplified 0-layer (bias-only) router version provided an exceptionally robust baseline.
- Parameter Efficiency: The upcycling process adds only a marginal fraction of trainable parameters (about 1.25% for a ViT-L/14), making it highly efficient.
Limitations and Future Directions
While highly effective, WEMoE does introduce memory overhead. Although the number of trainable parameters is low, storing task vectors for every merged task increases total parameter count and VRAM usage. Additionally, the reliance on Test-Time Adaptation requires a small amount of unlabeled target domain data to warm up the router.
Future work may explore low-rank approximations (like LoRA) or sparse MoE structures to reduce memory footprints, as well as extending this dynamic merging approach beyond vision to Large Language Models (LLMs).
Summary updated