Skip to main content
QUICK REVIEW

[论文解读] A Simple and Effective Pruning Approach for Large Language Models

Ming-Jie Sun, Zhuang Liu|arXiv (Cornell University)|Jun 20, 2023
Topic ModelingComputer Science被引用 52
一句话总结

Wanda 引入了一种对预训练大型语言模型无再训练的裁剪方法,使用由权重幅值与输入激活范数乘积形成的权重重要性得分,按输出进行裁剪,在 LLaMA/LLaMA-2 上实现强的零-shot 与 perplexity 结果,并获得有竞争力的加速。

ABSTRACT

As their size increases, Large Languages Models (LLMs) are natural candidates for network pruning methods: approaches that drop a subset of network weights while striving to preserve performance. Existing methods, however, require either retraining, which is rarely affordable for billion-scale LLMs, or solving a weight reconstruction problem reliant on second-order information, which may also be computationally expensive. In this paper, we introduce a novel, straightforward yet effective pruning method, termed Wanda (Pruning by Weights and activations), designed to induce sparsity in pretrained LLMs. Motivated by the recent observation of emergent large magnitude features in LLMs, our approach prunes weights with the smallest magnitudes multiplied by the corresponding input activations, on a per-output basis. Notably, Wanda requires no retraining or weight update, and the pruned LLM can be used as is. We conduct a thorough evaluation of our method Wanda on LLaMA and LLaMA-2 across various language benchmarks. Wanda significantly outperforms the established baseline of magnitude pruning and performs competitively against recent method involving intensive weight update. Code is available at https://github.com/locuslab/wanda.

研究动机与目标

  • 激发并解决在不重新训练或大量权重更新的情况下裁剪十亿参数级别的LLMs的挑战。
  • 提出 Wanda,一种简单、以校准数据为驱动的裁剪度量,结合权重与激活。
  • 研究按输出(按行)分组的裁剪策略,以维持LLMs的性能。
  • 在 LLaMA 与 LLaMA-2 上通过零样本和语言建模基准对 Wanda 进行实证评估,并与 magnitude pruning 和 SparseGPT 进行比较。
  • 分析 Wanda 的速度与鲁棒性,并讨论其向结构化稀疏性及潜在微调效应的扩展。

提出的方法

  • 定义裁剪度量 Sij = |Wij| * ||Xj||2,利用权重幅值与输入激活范数来评估权重的重要性。
  • 按输出逐组进行裁剪,将连接到同一输出神经元(按行)的一组权重聚合,并移除最低的 Sij 权重以达到目标稀疏度 s%。
  • 使用一个小型校准数据集估计输入激活范数,从而实现零重新训练或全数据访问。
  • 在单次前向传递中完成裁剪,不进行权重更新,并与基线(magnitude pruning)及 SparseGPT 进行比较。
  • 可选地将 Wanda 扩展到结构化的 N:M 稀疏,并讨论与 Optimal Brain Damage/Surgeon 视角的联系。
  • 提供以 O(d_hidden^2) 复杂度、且无需 Hessian 逆矩阵的裁剪度量快速计算。
  • 提供实现 Wanda 的代码并描述其如何整合到现有的前向传递中。

实验结果

研究问题

  • RQ1一个简单的裁剪度量(将权重幅值乘以输入激活范数)是否能有效地在预训练 LLMs 中识别需要裁剪的权重?
  • RQ2按输出(按行)裁剪是否优于层级裁剪或全局裁剪在大型语言模型中的表现?
  • RQ3在零样本和语言建模基准下,Wanda 与 magnitude pruning 和 SparseGPT 相较在无需再训练的情况下表现如何?
  • RQ4Wanda 对校准数据大小和稀疏度水平的速度与鲁棒性特性如何?
  • RQ5Wanda 能否扩展到结构化稀疏(N:M),并且它与经典裁剪方法有何关系?

主要发现

  • Wanda 在零样本任务上在无结构与结构化稀疏性方面均优于标准的幅值裁剪。
  • Wanda 在 perplexity 和零样本结果方面具有与 SparseGPT 接近的竞争力,且不需要任何权重更新。
  • 裁剪度量对校准数据大小具有鲁棒性,即使在非常小的校准集下也能保持有效。
  • 在许多情况下,具有 50% 稀疏度的大型稀疏 LLM(如 65B/70B)可达到与其密集版本相当的零-shot 表现。
  • Wanda 的计算速度显著快于 SparseGPT,不需要 Hessian 逆或迭代权重更新。
  • 与 Wanda 的结构化稀疏在线性层带来显著推理加速(约 1.6x),在某些模型上实现端到端的提升。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。