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

具有长短范围注意力的Lite Transformer

Lite Transformer with Long-Short Range Attention

Shanghai Jiao Tong University(上海交通大学);Massachusetts Institute of Technology(麻省理工学院)

Zhanghao Wu, Zhijian Liu, Ji Lin, Yujun Lin, Song Han

摘要:

Transformer在自然语言处理(例如,机器翻译、问答);然而,它需要大量的计算来实现高性能,这使得它不适合于受到硬件资源和电池严格限制的移动应用。在本文中,我们提出了一个有效的移动NLP架构,精简版Transformer,以方便部署移动NLP应用程序的边缘设备。关键的原语是长短距离注意力(LSRA),其中一组头部专门用于本地上下文建模(通过卷积),而另一组专门用于长距离关系建模(通过注意力)。这种专门化在三个成熟的语言任务上带来了比普通Transformer一致的改进:机器翻译、抽象摘要和语言建模。在有限的资源(500 M/100 M MAC)下,Lite Transformer在WMT'14英语-法语上的性能分别优于Transformer 1.2/1.7 BLEU。Lite Transformer将Transformer基础模型的计算量减少了2.5倍,BLEU评分降低了0.3。结合修剪和量化,我们进一步将Lite Transformer的模型大小压缩了18.2倍。对于语言建模,Lite Transformer在大约500 M MAC时实现了比Transformer低1.8的困惑。值得注意的是,Lite Transformer在移动NLP设置中的BLEU比基于AutoML的Evolved Transformer高0.5倍,而无需进行需要超过250年GPU的昂贵架构搜索。代码已在https://github.com/mit-han-lab/lite-transformer上提供。

英文摘要:

Transformer has become ubiquitous in natural language processing (e.g., machine translation, question answering); however, it requires enormous amount of computations to achieve high performance, which makes it not suitable for mobile applications that are tightly constrained by the hardware resources and battery. In this paper, we present an efficient mobile NLP architecture, Lite Transformer to facilitate deploying mobile NLP applications on edge devices. The key primitive is the Long-Short Range Attention (LSRA), where one group of heads specializes in the local context modeling (by convolution) while another group specializes in the long-distance relationship modeling (by attention). Such specialization brings consistent improvement over the vanilla transformer on three well-established language tasks: machine translation, abstractive summarization, and language modeling. Under constrained resources (500M/100M MACs), Lite Transformer outperforms transformer on WMT'14 English-French by 1.2/1.7 BLEU, respectively. Lite Transformer reduces the computation of transformer base model by 2.5x with 0.3 BLEU score degradation. Combining with pruning and quantization, we further compressed the model size of Lite Transformer by 18.2x. For language modeling, Lite Transformer achieves 1.8 lower perplexity than the transformer at around 500M MACs. Notably, Lite Transformer outperforms the AutoML-based Evolved Transformer by 0.5 higher BLEU for the mobile NLP setting without the costly architecture search that requires more than 250 GPU years. Code has been made available at https://github.com/mit-han-lab/lite-transformer.

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

↑