Block-Skim: Efficient Question Answering for Transformer

Yue Guan, Zhengyi Li, Jingwen Leng, Zhouhan Lin, Minyi Guo +1 more
12/16/2021
cs.CL
transformer-attention

Official code: ChandlerGuan/blockskim (6 stars, Python, last commit 2022-03-01).

Abstract

Transformer models have achieved promising results on natural language processing (NLP) tasks including extractive question answering (QA). Common Transformer encoders used in NLP tasks process the hidden states of all input tokens in the context paragraph throughout all layers.

Show full abstract

However, different from other tasks such as sequence classification, answering the raised question does not necessarily need all the tokens in the context paragraph. Following this motivation, we propose Block-skim, which learns to skim unnecessary context in higher hidden layers to improve and accelerate the Transformer performance. The key idea of Block-Skim is to identify the context that must be further processed and those that could be safely discarded early on during inference. Critically, we find that such information could be sufficiently derived from the self-attention weights inside the Transformer model. We further prune the hidden states corresponding to the unnecessary positions early in lower layers, achieving significant inference-time speedup. To our surprise, we observe that models pruned in this way outperform their full-size counterparts. Block-Skim improves QA models' accuracy on different datasets and achieves 3 times speedup on BERT-base model.

View on arXivView PDF

Code Implementations(1)

Code for BlockSkim

63Python, ShellJul 30, 20214 years ago

Similar Papers

Cite this paper

@article{guan2021blockskim,
  title  = {Block-Skim: Efficient Question Answering for Transformer},
  author = {Yue Guan and Zhengyi Li and Jingwen Leng and Zhouhan Lin and Minyi Guo and Yuhao Zhu},
  year   = {2021},
  eprint = {2112.08560},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2112.08560}
}

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

Discussion