Pruning is a highly effective approach for compressing large language models (LLMs), significantly reducing inference latency. However, conventional training-free structured pruning methods often employ a heuristic metric that indiscriminately removes some attention heads across all pruning layers, without considering their positions within the network architecture. In this work, we propose a novel pruning algorithm that strategically prunes attention heads in the model's higher layers. Since the removal of attention heads can alter the magnitude of token representations, we introduce an adaptive rescaling parameter that calibrates the representation scale post-pruning to counteract this effect. We conduct comprehensive experiments on a wide range of LLMs, including LLaMA3.1-8B, Mistral-7B-v0.3, Qwen2-7B, and Gemma2-9B. Our evaluation includes both generation and discriminative tasks across 27 datasets. The results consistently demonstrate that our method outperforms existing structured pruning methods. This improvement is particularly notable in generation tasks, where our approach significantly outperforms existing baselines. Code is available at https://github.com/SongtaoLiu0823/HARP.


翻译:剪枝是压缩大型语言模型(LLMs)的一种高效方法,能显著降低推理延迟。然而,传统的免训练结构化剪枝方法通常采用启发式度量,不加区分地移除所有剪枝层中的部分注意力头,而未考虑它们在网络架构中的位置。在本工作中,我们提出了一种新颖的剪枝算法,策略性地剪除模型高层中的注意力头。由于移除注意力头会改变词元表示的幅度,我们引入了一个自适应重缩放参数,用于在剪枝后校准表示尺度以抵消此影响。我们在包括LLaMA3.1-8B、Mistral-7B-v0.3、Qwen2-7B和Gemma2-9B在内的多种LLMs上进行了全面实验。我们的评估涵盖了27个数据集的生成式和判别式任务。结果一致表明,我们的方法优于现有的结构化剪枝方法。这一改进在生成任务中尤为显著,我们的方法明显超越了现有基线。代码可在https://github.com/SongtaoLiu0823/HARP获取。

0
下载
关闭预览

相关内容

【AAAI2024】EPSD:高效模型压缩中的早期剪枝与自我蒸馏
专知会员服务
24+阅读 · 2024年2月5日
【AAAI2024】公平感知的Transformer模型结构剪枝
专知会员服务
43+阅读 · 2023年12月27日
《深度神经网络剪枝》最新2023综述
专知会员服务
35+阅读 · 2023年8月17日
【AAAI2022】基于对比学习的预训练语言模型剪枝压缩
专知会员服务
29+阅读 · 2022年1月24日
深入理解BERT Transformer ,不仅仅是注意力机制
大数据文摘
22+阅读 · 2019年3月19日
读扩散?写扩散?推拉架构一文搞定!
架构师之路
17+阅读 · 2019年2月1日
跨越注意力:Cross-Attention
我爱读PAMI
172+阅读 · 2018年6月2日
基础 | 基于注意力机制的seq2seq网络
黑龙江大学自然语言处理实验室
16+阅读 · 2018年3月7日
深度学习中的注意力机制
CSDN大数据
24+阅读 · 2017年11月2日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
23+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
23+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员