Transkimmer: Transformer Learns to Layer-wise Skim

Yue Guan, Zhengyi Li, Jingwen Leng, Zhouhan Lin, Minyi Guo
5/15/2022
cs.CL
transformer-attention

Official code: ChandlerGuan/Transkimmer (22 stars, Python, last commit 2022-08-21).

Abstract

Transformer architecture has become the de-facto model for many machine learning tasks from natural language processing and computer vision. As such, improving its computational efficiency becomes paramount.

Show full abstract

One of the major computational inefficiency of Transformer-based models is that they spend the identical amount of computation throughout all layers. Prior works have proposed to augment the Transformer model with the capability of skimming tokens to improve its computational efficiency. However, they suffer from not having effectual and end-to-end optimization of the discrete skimming predictor. To address the above limitations, we propose the Transkimmer architecture, which learns to identify hidden state tokens that are not required by each layer. The skimmed tokens are then forwarded directly to the final output, thus reducing the computation of the successive layers. The key idea in Transkimmer is to add a parameterized predictor before each layer that learns to make the skimming decision. We also propose to adopt reparameterization trick and add skim loss for the end-to-end training of Transkimmer. Transkimmer achieves 10.97x average speedup on GLUE benchmark compared with vanilla BERT-base baseline with less than 1% accuracy degradation.

View on arXivView PDF

Code Implementations(1)

Code for ACL2022 publication Transkimmer: Transformer Learns to Layer-wise Skim

225Python, ShellMar 16, 20224 years ago

Similar Papers

Cite this paper

@article{guan2022transkimmer,
  title  = {Transkimmer: Transformer Learns to Layer-wise Skim},
  author = {Yue Guan and Zhengyi Li and Jingwen Leng and Zhouhan Lin and Minyi Guo},
  year   = {2022},
  eprint = {2205.07324},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2205.07324}
}

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

Discussion