TokenFormer: Rethinking Transformer Scaling with Tokenized Model Parameters

Haiyang Wang, Yue Fan, Muhammad Ferjad Naeem, Yongqin Xian, Jan Eric Lenssen +3 more
10/30/2024
cs.LG

Official code: Haiyang-W/TokenFormer (592 stars, Apache-2.0, last commit 2025-02-11). 1 more implementation below.

Abstract

Transformers have become the predominant architecture in foundation models due to their excellent performance across various domains. However, the substantial cost of scaling these models remains a significant concern. This problem arises primarily from their dependence on a fixed number of parameters within linear projections. When architectural modifications (e.g., channel dimensions) are introduced, the entire model typically requires retraining from scratch. As model sizes continue growing, this strategy results in increasingly high computational costs and becomes unsustainable. To overcome this problem, we introduce TokenFormer, a natively scalable architecture that leverages the attention mechanism not only for computations among input tokens but also for interactions between tokens and model parameters, thereby enhancing architectural flexibility. By treating model parameters as tokens, we replace all the linear projections in Transformers with our token-parameter attention layer, where input tokens act as queries and model parameters as keys and values. This reformulation allows for progressive and efficient scaling without necessitating retraining from scratch. Our model scales from 124M to 1.4B parameters by incrementally adding new key-value parameter pairs, achieving performance comparable to Transformers trained from scratch while greatly reducing training costs. Code and models are available at https://github.com/Haiyang-W/TokenFormer.

View on arXivView PDF

Code Implementations(2)

Apache-2.0

[ICLR2025 Spotlight🔥] Official Implementation of TokenFormer: Rethinking Transformer Scaling with Tokenized Model Parameters

59243C, C++Oct 29, 20241 years agoApache-2.0
architectureattention-mechanismfoundation-modelsllmscaling-methods+1 more

Reimplementation of TokenFormer: Rethinking Transformer Scaling with Tokenized Model Parameters

00Python, Jupyter NotebookFeb 11, 20251 years ago

Similar Papers

Cite this paper

@article{wang2024tokenformer,
  title  = {TokenFormer: Rethinking Transformer Scaling with Tokenized Model Parameters},
  author = {Haiyang Wang and Yue Fan and Muhammad Ferjad Naeem and Yongqin Xian and Jan Eric Lenssen and Liwei Wang and Federico Tombari and Bernt Schiele},
  year   = {2024},
  eprint = {2410.23168},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2410.23168v2},
  journal = {ICLR 2024 2024}
}

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/2410.23168.svg)](https://codeofpaper.com/paper/2410.23168)

Discussion