Weight subcloning: direct initialization of transformers using larger pretrained ones

Mohammad Samragh, Mehrdad Farajtabar, Sachin Mehta, Raviteja Vemulapalli, Fartash Faghri +3 more
12/14/2023
41 citations
cs.LGcs.CLcs.CV
transformer-attention

No official code found. Best implementation: SonicCodes/subcloning (21 stars, Jupyter Notebook, last commit 2024-07-03).

Abstract

Training large transformer models from scratch for a target task requires lots of data and is computationally demanding. The usual practice of transfer learning overcomes this challenge by initializing the model with weights of a pretrained model of the same size and specification to increase the convergence and training speed.

Show full abstract

However, what if no pretrained model of the required size is available? In this paper, we introduce a simple yet effective technique to transfer the knowledge of a pretrained model to smaller variants. Our approach called weight subcloning expedites the training of scaled-down transformers by initializing their weights from larger pretrained models. Weight subcloning involves an operation on the pretrained model to obtain the equivalent initialized scaled-down model. It consists of two key steps: first, we introduce neuron importance ranking to decrease the embedding dimension per layer in the pretrained model. Then, we remove blocks from the transformer model to match the number of layers in the scaled-down network. The result is a network ready to undergo training, which gains significant improvements in training speed compared to random initialization. For instance, we achieve 4x faster training for vision transformers in image classification and language models designed for next token prediction.

View on arXivView PDF

Code Implementations(1)

implementation of https://arxiv.org/pdf/2312.09299

212Jupyter NotebookJun 24, 20242 years ago

Similar Papers

Cite this paper

@article{samragh2023weight,
  title  = {Weight subcloning: direct initialization of transformers using larger pretrained ones},
  author = {Mohammad Samragh and Mehrdad Farajtabar and Sachin Mehta and Raviteja Vemulapalli and Fartash Faghri and Devang Naik and Oncel Tuzel and Mohammad Rastegari},
  year   = {2023},
  eprint = {2312.09299},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2312.09299v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2312.09299.svg)](https://codeofpaper.com/paper/2312.09299)

Discussion