BEExformer: A Fast Inferencing Binarized Transformer with Early Exits
作者: Wazib Ansar, Saptarsi Goswami, Amlan Chakrabarti
分类: cs.CL, cs.AI, cs.NE
发布日期: 2024-12-06 (更新: 2025-07-12)
备注: This revised manuscript includes 18 pages, 17 figures, and 6 tables. Methodology and results sections have been improved for clarity and depth, incorporating additional comparisons, ablations, and a new evaluation dataset. A few relevant references were added, and overall organization refined for better readability
💡 一句话要点
提出BEExformer,一种结合二值化感知训练和早退机制的快速推理Transformer。
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 二值化神经网络 早退机制 Transformer 模型压缩 自然语言处理 高效推理 选择性学习
📋 核心要点
- 现有Transformer模型庞大且计算需求高,难以在资源受限设备上部署,二值化和早退是有效的加速方法,但存在精度损失和研究不足的问题。
- BEExformer通过二值化感知训练(BAT)和选择性学习遗忘网络(SLFN)增强上下文信息保留,并结合早退(EE)机制加速推理,提升模型效率。
- 实验结果表明,BEExformer在减少模型大小和FLOPs的同时,甚至能提高准确率,实现了性能和效率的Pareto最优权衡。
📝 摘要(中文)
本文提出了一种名为BEExformer的二值化早退Transformer,旨在提升Transformer模型在资源受限环境下的推理效率。该模型是首个结合二值化感知训练(BAT)和早退(EE)机制的Transformer,用于高效快速的文本推理。每个Transformer块集成了一个选择性学习遗忘网络(SLFN),以增强上下文信息的保留并消除不相关信息。BAT采用可微的二阶近似符号函数,实现梯度计算,捕捉权重的符号和幅度,从而减少21.30倍的模型大小。EE机制依赖于中间Transformer块间熵的减少,通过软路由损失估计加速推理,减少52.08%的FLOPs,并通过解决深度网络中固有的“过度思考”问题,甚至提高了2.89%的准确率。在六个涵盖多个NLP任务的数据集上进行的广泛评估,以及与SOTA方法的比较和各种消融实验,证明了其Pareto最优的性能-效率权衡。
🔬 方法详解
问题定义:现有的大型语言模型(LLMs)虽然在各种应用中取得了领先成果,但其庞大的规模和处理需求阻碍了它们在资源受限环境中的部署。二值化和早退(EE)是提高效率的有效方法,但二值化可能导致性能损失,因为降低的精度会影响梯度估计和参数更新。此外,关于EE机制的研究仍处于早期阶段。
核心思路:BEExformer的核心思路是将二值化感知训练(BAT)与早退(EE)机制相结合,构建一个既能减小模型尺寸,又能加速推理过程的Transformer模型。通过BAT,模型能够在二值化的情况下更好地进行训练,减少精度损失。而EE机制则允许模型在中间层提前输出结果,避免不必要的计算,从而加速推理。
技术框架:BEExformer的整体架构基于标准的Transformer模型,但在每个Transformer块中都集成了选择性学习遗忘网络(SLFN)和一个早退分支。SLFN用于增强上下文信息的保留,并消除不相关的信息。BAT用于训练二值化权重。EE机制通过监测中间Transformer块的熵变化来决定是否提前退出。整个训练过程包括BAT和软路由损失估计。
关键创新:BEExformer的关键创新在于以下几点:1) 首次将二值化感知训练(BAT)与早退(EE)机制结合,用于Transformer模型的加速。2) 提出了选择性学习遗忘网络(SLFN),用于增强上下文信息的保留。3) BAT采用可微的二阶近似符号函数,使得梯度计算能够捕捉权重的符号和幅度。
关键设计:BAT采用可微的二阶近似符号函数,具体实现细节未知。EE机制基于中间Transformer块间熵的减少,通过软路由损失估计来决定是否提前退出,具体实现细节未知。SLFN的具体网络结构和参数设置未知。
🖼️ 关键图片
📊 实验亮点
BEExformer在多个NLP任务上进行了广泛的评估,实验结果表明,该模型能够减少21.30倍的模型大小,减少52.08%的FLOPs,并且在某些情况下甚至能够提高2.89%的准确率。与SOTA方法相比,BEExformer在性能和效率之间取得了更好的平衡。
🎯 应用场景
BEExformer适用于资源受限的设备和场景,例如移动设备、嵌入式系统和边缘计算。它可以用于加速各种NLP任务的推理,例如文本分类、情感分析、机器翻译等。该研究有助于推动大型语言模型在资源受限环境中的应用,并降低AI模型的部署成本。
📄 摘要(原文)
Large Language Models (LLMs) based on transformers achieve cutting-edge results on a variety of applications. However, their enormous size and processing requirements hinder deployment on constrained resources. To enhance efficiency, binarization and Early Exit (EE) have proved to be effective solutions. However, binarization may lead to performance loss as reduced precision affects gradient estimation and parameter updates. Besides, research on EE mechanisms is still in its early stages. To address these challenges, we introduce Binarized Early Exit Transformer (BEExformer), the first-ever selective learning-based transformer integrating Binarization-Aware Training (BAT) with EE for efficient and fast textual inference. Each transformer block has an integrated Selective-Learn Forget Network (SLFN) to enhance contextual retention while eliminating irrelevant information. The BAT employs a differentiable second-order approximation to the sign function, enabling gradient computation that captures both the sign and magnitude of the weights. This aids in 21.30 times reduction in model size. The EE mechanism hinges on fractional reduction in entropy among intermediate transformer blocks with soft-routing loss estimation. This accelerates inference by reducing FLOPs by 52.08% and even improves accuracy by 2.89% by resolving the "overthinking" problem inherent in deep networks. Extensive evaluation through comparison with the SOTA methods and various ablations across six datasets covering multiple NLP tasks demonstrates its Pareto-optimal performance-efficiency trade-off.