Change Is the Only Constant: Dynamic LLM Slicing based on Layer Redundancy

📄 arXiv: 2411.03513v1 📥 PDF

作者: Razvan-Gabriel Dumitru, Paul-Ioan Clotan, Vikas Yadav, Darius Peteleaza, Mihai Surdeanu

分类: cs.CL, cs.AI, cs.LG

发布日期: 2024-11-05

备注: Accepted at EMNLP Findings 2024

🔗 代码/项目: GITHUB


💡 一句话要点

提出动态层切片方法以提升大语言模型的压缩效率

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大语言模型 动态剪枝 层冗余评分 模型压缩 性能提升

📋 核心要点

  1. 现有的常量切片方法在大语言模型的压缩效率和性能之间存在权衡,难以适应动态变化的需求。
  2. 本文提出了一种动态层特定剪枝的方法,通过层冗余评分来评估每层的输入输出变化,从而实现更高效的模型压缩。
  3. 实验结果显示,动态切片方法在多个基准测试中相较于SliceGPT基线提升了性能,困惑度显著降低,验证了其有效性。

📝 摘要(中文)

本文提出了一种通过动态层特定剪枝来压缩大语言模型(LLMs)的新方法,增强了SliceGPT建立的传统方法。通过引入层冗余(LR)评分,评估每层对输入的变化程度,利用该评分动态剪枝个别层的冗余部分,从而保持所有层的平均剪枝比例为固定值。实验表明,该方法在多个数据集上对Llama3-8B和Mistral-7B模型进行了评估,结果显示动态切片方法不仅保持了模型性能,在许多情况下还优于传统的常量切片方法,性能提升可达5%,困惑度降低幅度达到7%。

🔬 方法详解

问题定义:本文旨在解决现有常量切片方法在大语言模型压缩中的效率与性能之间的矛盾,尤其是在动态应用场景下的适应性不足。

核心思路:通过引入层冗余(LR)评分,动态评估每层对输入的影响,进而剪除冗余部分,以实现更高效的模型压缩和性能提升。

技术框架:整体方法包括层冗余评分计算、动态剪枝决策和模型重训练三个主要模块。首先计算每层的LR评分,然后根据评分动态调整剪枝比例,最后对剪枝后的模型进行重训练以恢复性能。

关键创新:最重要的创新在于动态切片的引入,通过实时评估层的冗余程度,显著提高了模型的压缩效率和性能,区别于传统的静态剪枝方法。

关键设计:在设计中,LR评分的计算基于输入与输出的余弦相似度,剪枝比例设定为固定值以保证整体模型的稳定性,损失函数采用标准的交叉熵损失,同时在重训练阶段使用了适当的学习率调整策略。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,动态切片方法在多个基准测试中相较于SliceGPT基线提升了性能,具体表现为性能提升可达5%,困惑度降低幅度达到7%,验证了该方法的有效性和优越性。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理、对话系统和文本生成等场景,能够有效提升大语言模型的运行效率,降低计算资源消耗,适应更广泛的实际应用需求。未来,该方法有望推动大语言模型在实时应用中的普及与发展。

📄 摘要(原文)

This paper introduces a novel model compression approach through dynamic layer-specific pruning in Large Language Models (LLMs), enhancing the traditional methodology established by SliceGPT. By transitioning from constant to dynamic slicing, our method leverages the newly proposed Layer Redundancy (LR) score, which assesses how much change each layer changes its input by measuring the cosine similarity of the input to the output of the layer. We use this score to prune parts of individual layers based on redundancy in such a way that the average pruned percentage for all layers is a fixed value. We conducted extensive experiments using models like Llama3-8B and Mistral-7B on multiple datasets, evaluating different slicing bases and percentages to determine optimal configurations that balance efficiency and performance. Our findings show that our dynamic slicing approach not only maintains but, in many cases, enhances model performance compared to the baseline established by constant slicing methods. For instance, in several settings, we see performance improvements of up to 5% over the SliceGPT baseline. Additionally, a perplexity decrease by as much as 7% was observed across multiple benchmarks, validating the effectiveness of our method. The code, model weights, and datasets are open-sourced at https://github.com/RazvanDu/DynamicSlicing.