arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2303.09266cs.CLcs.AIcs.LG
收藏

SmartBERT:一种促进动态提前退出机制以加速BERT推理的方法

SmartBERT: A Promotion of Dynamic Early Exiting Mechanism for Accelerating BERT Inference

Zhejiang University(浙江大学)

Boren Hu, Yun Zhu, Jiacheng Li, Siliang Tang

AI总结:

SmartBERT通过在每个BERT层添加跳过门和退出操作符,结合跨层对比学习与硬权重机制,实现动态层跳过与提前退出,在GLUE八个数据集上减少2-3倍计算量且准确率损失极小。

摘要:

动态提前退出已被证明能够提高预训练语言模型(如BERT)的推理速度。然而,所有样本在提前退出之前必须经过所有连续层,且更复杂的样本通常需要经过更多层,这仍然存在冗余计算。在本文中,我们提出了一种新颖的动态提前退出结合层跳过的BERT推理方法,命名为SmartBERT,它在BERT的每一层中添加了一个跳过门和一个退出操作符。SmartBERT可以自适应地跳过某些层,并自适应地选择是否退出。此外,我们提出了跨层对比学习,并将其结合到我们的训练阶段,以增强中间层和分类器,这有利于提前退出。为了在训练和推理阶段之间保持跳过门使用的一致性,我们在训练阶段提出了一种硬权重机制。我们在GLUE基准的八个分类数据集上进行了实验。实验结果表明,与BERT相比,SmartBERT实现了2-3倍的计算量减少,且准确率下降极小,我们的方法在效率和准确率方面均优于先前的方法。此外,在像RTE和WNLI这样的一些复杂数据集中,我们证明了基于熵的提前退出几乎不起作用,而跳过机制对于减少计算至关重要。

英文摘要:

Dynamic early exiting has been proven to improve the inference speed of the pre-trained language model like BERT. However, all samples must go through all consecutive layers before early exiting and more complex samples usually go through more layers, which still exists redundant computation. In this paper, we propose a novel dynamic early exiting combined with layer skipping for BERT inference named SmartBERT, which adds a skipping gate and an exiting operator into each layer of BERT. SmartBERT can adaptively skip some layers and adaptively choose whether to exit. Besides, we propose cross-layer contrastive learning and combine it into our training phases to boost the intermediate layers and classifiers which would be beneficial for early exiting. To keep the consistent usage of skipping gates between training and inference phases, we propose a hard weight mechanism during training phase. We conduct experiments on eight classification datasets of the GLUE benchmark. Experimental results show that SmartBERT achieves 2-3x computation reduction with minimal accuracy drops compared with BERT and our method outperforms previous methods in both efficiency and accuracy. Moreover, in some complex datasets like RTE and WNLI, we prove that the early exiting based on entropy hardly works, and the skipping mechanism is essential for reducing computation.

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

↑