arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2107.00910cs.CL
收藏

学习了Transformers的Token剪枝

Learned Token Pruning for Transformers

University of California, Berkeley(加州大学伯克利分校);Samsung Semiconductor, Inc.(三星半导体公司)

Sehoon Kim, Sheng Shen, David Thorsley, Amir Gholami, Woosuk Kwon, Joseph Hassoun, Kurt Keutzer

摘要:

在实践中部署Transformer模型是具有挑战性的,因为它们的推理成本与输入序列长度成二次方。为了解决这个问题,我们提出了一种新的学习令牌修剪(LTP)方法,自适应地删除不重要的令牌作为输入序列通过Transformer层。特别是,LTP会修剪注意力分数低于阈值的令牌,该阈值是在训练期间为每层学习的。我们的基于阈值的方法允许修剪序列的长度根据输入序列自适应地变化,并避免了算法上昂贵的操作,如top-k令牌选择。我们广泛地测试了LTP在GLUE任务上的性能,并表明我们的方法在相同数量的FLOP的情况下,比现有的最先进的令牌修剪方法高出约2.5%的准确性。特别是,LTP在精度下降不到1%的情况下实现了高达2.1倍的FLOPs减少,这使得Intel Haswell CPU和NVIDIA V100 GPU的吞吐量分别提高了1.9倍和2.0倍。此外,我们证明了LTP比以前的方法更强大的输入句子长度的变化。我们的代码是在PyTorch中开发的,并且是开源的。

英文摘要:

Deploying transformer models in practice is challenging due to their inference cost, which scales quadratically with input sequence length. To address this, we present a novel Learned Token Pruning (LTP) method which adaptively removes unimportant tokens as an input sequence passes through transformer layers. In particular, LTP prunes tokens with an attention score below a threshold value which is learned for each layer during training. Our threshold-based method allows the length of the pruned sequence to vary adaptively based on the input sequence, and avoids algorithmically expensive operations such as top-k token selection. We extensively test the performance of LTP on GLUE tasks and show that our method outperforms the prior state-of-the-art token pruning methods by up to ~2.5% higher accuracy with the same amount of FLOPs. In particular, LTP achieves up to 2.1x FLOPs reduction with less than 1% accuracy drop, which results in up to 1.9x and 2.0x throughput improvement on Intel Haswell CPUs and NVIDIA V100 GPUs, respectively. Furthermore, we demonstrate that LTP is more robust than prior methods to variations on input sentence lengths. Our code has been developed in PyTorch and has been open-sourced.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑