Understanding Permutation Based Model Merging with Feature Visualizations

Congshu Zou, geraldin nanfack, Stefan Horoi, Eugene BelilovskyUniReps @ NeurIPS 2024

TL;DR

This paper investigates why and how merging deep learning models works, specifically focusing on models that can be linearly connected after permuting their internal features. By visualizing what features these models learn, the authors gain insights into the merging process, revealing that while permutation helps align features, some "rare" features remain challenging to match.

What Problem Does This Paper Address?

Deep learning models, even when trained on the same data with the same architecture, can learn vastly different internal representations. This makes directly averaging their weights (model merging) ineffective. A recent discovery, "linear mode connectivity" (LMC), suggests that models trained with stochastic gradient descent (SGD) can be connected by a linear path in their parameter space, provided we account for permutation invariance (i.e., the order of features doesn't fundamentally change what the model learns). This has led to methods that first find a permutation to align features and then merge the models. However, the mechanisms behind why this permutation-based merging works, and what properties it imparts to the merged model, remain poorly understood. This paper aims to shed light on these inner workings using feature visualization.

Methods

The core of this research involves feature visualization, a technique used to understand what a neural network "sees" or detects. Specifically, the authors employ activation maximization, where they find input images that maximally activate specific neurons (or channels in CNNs). By comparing these visualizations between different models:

  • Permutation Alignment: They use the REPAIR method [10] to find a permutation that aligns the features of one model to another.
  • Visual Comparison: They then visually compare the top-activated images for corresponding channels in the original and permuted models.
  • Merged Model Analysis: They extend this to analyze the feature visualizations of the merged models (both direct averaging and permuted averaging) to see how the merging process affects learned features.
  • Quantitative Metrics: To complement visual inspection, they use metrics like Kendall's Tau and CLIP-8 [13] to quantitatively assess the similarity of top-activated images.
  • Linear Regression Alignment: As an alternative to permutation, they also explore aligning features using linear regression, regressing features from one model onto another.

Datasets

  • ImageNet: The primary dataset used for training and evaluating the models.

Key Insights and Ideas

  • Permutation is Necessary but Not Sufficient: While permuting models to align features significantly improves the similarity of their top-activated images, it doesn't guarantee perfect alignment for all features. Some features remain visually dissimilar even after permutation.
  • "Rare" Features are Hard to Match: The features that are difficult to align after permutation often correspond to what the authors term "rare features" in the reference model. These might be less common patterns or concepts that the other model hasn't learned as strongly or in the same way.
  • Merged Model Behavior Varies: The top-activated images of the merged model depend on the similarity of features after permutation. If features are well-aligned, the merged model's features are also similar. If not, the merged model's features might be dominated by one of the source models, or even represent something entirely new.
  • Linear Regression Offers an Alternative: Aligning features using linear regression shows promise, suggesting that a feature in one model might be represented by a combination of features in another, rather than a strict one-to-one mapping. This hints at a more distributed representation.
  • Sparsity in Linear Regression: The weights learned in the linear regression alignment are often sparse, indicating that only a subset of features from the second model are needed to approximate a feature in the first.

Key Results

  • Improved Merging Accuracy: The paper's appendix shows that permutation-based merging significantly improves validation accuracy compared to direct interpolation, especially for ResNet models.
  • Visual Evidence of Alignment: Figures throughout the paper (e.g., Figure 1, 5, 6, 7, 8, 9, 10, 12, 14, 15) provide visual evidence of feature similarity and dissimilarity across different models and merging strategies.
  • Identification of Mismatched Cases: The study systematically categorizes scenarios where merged models exhibit different behaviors based on the initial feature alignment.

Limitations and Future Work

  • Empirical Nature: The study is largely empirical, relying on visual inspection and metrics that may not perfectly differentiate all cases.
  • Quantifying Similarity: The authors suggest future work could focus on more robust quantitative methods to measure channel similarity.
  • Sparse Linear Combinations: Exploring the sparse linear combinations of permuted channel representations as a merging approach is proposed as a promising future direction.

Summary updated

BibTeX
@inproceedings{zou2024understanding,
  author = {Congshu Zou and geraldin nanfack and Stefan Horoi and Eugene Belilovsky},
  title = {{Understanding Permutation Based Model Merging with Feature Visualizations}},
  booktitle = {UniReps @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=CWTEiuwOQU},
}
Figure