Vision Transformers as Probabilistic Expansion from Learngene

Qiufeng Wang, Xu Yang, Haokun Chen, Xin Geng

Introduction

In the current era of "foundation models," developers often face a "one-size-fits-all" dilemma. Massive, high-performing models like Vision Transformers (ViTs) are powerful, but deploying them on resource-constrained hardware (like smartphones or edge devices) usually requires training smaller versions from scratch or relying on complex compression techniques.

Existing "Learngene" research aims to condense knowledge from an "ancestry model" into a compact "gene" for descendant models. However, these methods have two major flaws: they often just pick a few integral layers (ignoring valuable knowledge distributed across the rest of the model), and they lack "elasticity," meaning you cannot easily scale these extracted genes to fit a specific, custom-sized architecture.

To address this, researchers have introduced PEG (Probabilistic Expansion from LearnGene), a novel framework that extracts the essence of a massive ViT and expands it into smaller, elastic models tailored for specific devices. By treating model weights as a probabilistic distribution rather than fixed values, PEG achieves up to a 3.6x speedup in convergence and significantly higher accuracy in data-scarce environments.

Methodology: The PEG Framework

The PEG framework moves away from rigid "layer-picking" and operates in two distinct phases: Sampling and Expanding.

The PEG framework illustrating the sampling of a Learngene from an ancestry model and its expansion into elastic descendant models.

1. Probabilistic Sampling (Condensing)

Instead of selecting specific layers, PEG treats the parameters of the ancestry model as a distribution.

  • MSA Sampling: It uses a Gaussian mixture approach to sample Multi-Head Self-Attention (MSA) layers. It synthesizes a reduced number of attention heads by taking weighted combinations of the original heads, where the weights are drawn from a standard Gaussian distribution.
  • FFN Sampling: Similarly, it condenses the Feed-Forward Network (FFN) layers into a more compact set.
  • The "Learngene": The result is a compact, highly informative "learngene" that theoretically approximates the parameter distribution of the giant ancestry model.

2. Non-linear Expansion (Initializing)

To turn this compact gene into a functional model of a specific size, PEG uses non-linear mapping. It employs a neural network (using ReLU activations) to expand the number of attention heads and FFN layers to the desired "elastic" scale. This allows a single "learngene" to initialize a "Tiny," "Small," or "Base" model depending on the downstream task's hardware constraints.

Key Insights

  • Knowledge as a Density: The most profound insight is that model knowledge isn't just "stored" in specific weights; it exists in the distribution of those weights. By approximating this density function, PEG preserves the "ancestry" knowledge more effectively than just copying layers.
  • Elasticity is Key: Unlike previous methods that were hard-coded to specific architectures, PEG’s use of learnable expansion functions makes the initialization process dynamic.
  • The Importance of Attention: Through ablation studies, the authors found that inheriting the MSA (Attention) components is significantly more important for performance than inheriting the FFN components. Specifically, the Query ($Q$) and Key ($K$) matrices are the most critical "genetic" traits to pass down.

Experimental Results

The authors evaluated PEG across a wide range of standard computer vision benchmarks, including ImageNet-1K, CIFAR datasets, and fine-grained classification tasks like Oxford Flowers and iNaturalist-2019.

Accuracy vs. Epoch graphs demonstrating the significant speedup achieved by PEG on DeiT-Base and Swin-Base architectures.
  • Faster Convergence: On ImageNet-1K, PEG reached optimal performance up to 3.6x faster than training from scratch. This translates to massive savings in computational cost and time.
  • Superior Performance: PEG consistently outperformed training from scratch and other initialization methods. On the large-scale long-tail iNaturalist-2019 dataset, PEG outperformed other Learngene methods by a massive 7.81%.
  • High Data Efficiency: When training data is scarce, PEG shines. Using only 25% of the training data on ImageNet, PEG outperformed a from-scratch model (trained on the same 25%) by 10.6%.
  • Versatility: While primarily tested on DeiT (Data-efficient Image Transformers), the authors successfully applied PEG to Swin Transformers, proving the method isn't tied to a single architecture.

Limitations and Future Work

While PEG speeds up the final fine-tuning, the "expanding" phase itself requires a preliminary training period (e.g., 100 epochs). Additionally, while the theory should hold for other architectures like Large Language Models (LLMs) or standard CNNs, the current scope is heavily focused on Vision Transformers. Future directions include exploring more complex non-linear mappings for the expansion phase to further improve the elasticity and performance of descendant models.

Summary updated

BibTeX
@inproceedings{wang2024vision,
  author = {Qiufeng Wang and Xu Yang and Haokun Chen and Xin Geng},
  title = {{Vision Transformers as Probabilistic Expansion from Learngene}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=5ExWEazod5},
}
Figure