arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2203.09055cs.CL
收藏

高效率BERT的细粒度和粗粒度混合自注意

Fine- and Coarse-Granularity Hybrid Self-Attention for Efficient BERT

JD AI Research(京东人工智能研究院)

Jing Zhao, Yifan Wang, Junwei Bao, Youzheng Wu, Xiaodong He

摘要:

基于转换器的预训练模型,如BERT,在许多自然语言处理应用中取得了非凡的成功。然而,部署这些模型的成本可能过高,因为Transformer的标准自注意力机制在输入序列长度上遭受二次计算成本。面对这一点,我们提出了FCA,一个细粒度和粗粒度的混合自注意力,通过逐步缩短计算序列长度的自注意力,降低了计算成本。具体而言,FCA采用基于注意力的评分策略来确定每层令牌的信息量。然后,将信息标记作为自注意的细粒度计算单元,将非信息标记替换为一个或多个簇作为自注意的粗粒度计算单元。在GLUE和RACE数据集上的实验表明,与原始BERT相比,使用FCA的BERT在精度损失<1%的情况下实现了2倍的FLOPs减少。我们表明,FCA提供了一个显着更好的准确性和FLOPs之间的权衡比以前的方法。

英文摘要:

Transformer-based pre-trained models, such as BERT, have shown extraordinary success in achieving state-of-the-art results in many natural language processing applications. However, deploying these models can be prohibitively costly, as the standard self-attention mechanism of the Transformer suffers from quadratic computational cost in the input sequence length. To confront this, we propose FCA, a fine- and coarse-granularity hybrid self-attention that reduces the computation cost through progressively shortening the computational sequence length in self-attention. Specifically, FCA conducts an attention-based scoring strategy to determine the informativeness of tokens at each layer. Then, the informative tokens serve as the fine-granularity computing units in self-attention and the uninformative tokens are replaced with one or several clusters as the coarse-granularity computing units in self-attention. Experiments on GLUE and RACE datasets show that BERT with FCA achieves 2x reduction in FLOPs over original BERT with <1% loss in accuracy. We show that FCA offers a significantly better trade-off between accuracy and FLOPs compared to prior methods.

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

↑