汉明注意力蒸馏:为高效长上下文Transformer二值化键与查询
Hamming Attention Distillation: Binarizing Keys and Queries for Efficient Long-Context Transformers
AI总结:
本文提出汉明注意力蒸馏(HAD),通过二值化键与查询并用汉明距离替代点积,结合注意力稀疏化,在GLUE和ImageNet上以远低于现有二值化方法的性能损失实现长上下文Transformer的高效推理和硬件面积与功耗大幅降低。
摘要:
具有扩展上下文窗口的预训练Transformer模型在大规模运行时计算和内存需求极高,往往限制其在实际部署中的应用。本文提出汉明注意力蒸馏(Hamming Attention Distillation,HAD),这是一种新颖的框架,通过对注意力机制中的键(keys)和查询(queries)进行二值化来实现显著的效率提升。通过将键和查询转换为{-1, +1}向量,并用高效的汉明距离计算替代点积运算,我们的方法大幅降低了计算开销。此外,我们引入注意力矩阵稀疏化以剪除低影响力激活,从而进一步降低处理长上下文序列的成本。尽管采用了这些激进的压缩策略,我们的蒸馏方法仍保持了较高的表示能力,与先前的Transformer二值化方法相比,准确率显著提高。我们在包括GLUE基准、ImageNet和QuALITY在内的一系列任务和模型上评估了HAD,展示了二值化Transformer中最先进的性能,同时大幅降低了长上下文推理的计算成本。我们在定制硬件仿真中实现了HAD,与标准注意力的定制硬件实现相比,展示了更优越的性能特征。HAD在GLUE上仅损失1.78%的性能,而最先进的二值化工作损失为9.08%;在ImageNet上损失2.5%的性能,而对比方法损失为12.14%,同时目标定制硬件相比标准注意力对应方案实现了79%的面积减少和87%的功耗降低。
英文摘要:
Pre-trained transformer models with extended context windows are notoriously expensive to run at scale, often limiting real-world deployment due to their high computational and memory requirements. In this paper, we introduce Hamming Attention Distillation (HAD), a novel framework that binarizes keys and queries in the attention mechanism to achieve significant efficiency gains. By converting keys and queries into {-1, +1} vectors and replacing dot-product operations with efficient Hamming distance computations, our method drastically reduces computational overhead. Additionally, we incorporate attention matrix sparsification to prune low-impact activations, which further reduces the cost of processing long-context sequences. \par Despite these aggressive compression strategies, our distilled approach preserves a high degree of representational power, leading to substantially improved accuracy compared to prior transformer binarization methods. We evaluate HAD on a range of tasks and models, including the GLUE benchmark, ImageNet, and QuALITY, demonstrating state-of-the-art performance among binarized Transformers while drastically reducing the computational costs of long-context inference. \par We implement HAD in custom hardware simulations, demonstrating superior performance characteristics compared to a custom hardware implementation of standard attention. HAD achieves just $\mathbf{1.78}\%$ performance losses on GLUE compared to $9.08\%$ in state-of-the-art binarization work, and $\mathbf{2.5}\%$ performance losses on ImageNet compared to $12.14\%$, all while targeting custom hardware with a $\mathbf{79}\%$ area reduction and $\mathbf{87}\%$ power reduction compared to its standard attention counterpart.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。