SliceGPT: Compress Large Language Models by Deleting Rows and Columns
作者: Saleh Ashkboos, Maximilian L. Croci, Marcelo Gennari do Nascimento, Torsten Hoefler, James Hensman
分类: cs.LG, cs.CL
发布日期: 2024-01-26 (更新: 2024-02-09)
备注: 22 pages, 8 figures, accepted at ICLR24
🔗 代码/项目: GITHUB
💡 一句话要点
提出SliceGPT以压缩大型语言模型的计算和内存需求
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 稀疏化技术 大型语言模型 后训练优化 计算不变性 自然语言处理 模型压缩 资源效率
📋 核心要点
- 现有稀疏化技术需要额外的数据结构,并且在当前硬件上速度提升有限,难以有效压缩大型语言模型。
- SliceGPT通过用更小的稠密矩阵替换权重矩阵,减少嵌入维度,从而实现后训练稀疏化,降低计算和内存需求。
- 实验结果表明,SliceGPT在LLAMA2-70B等模型上去除25%参数的同时,保持99%及以上的任务性能,计算需求显著降低。
📝 摘要(中文)
大型语言模型已成为自然语言处理的基石,但其使用伴随着巨大的计算和内存资源成本。稀疏化提供了解决方案,近期研究表明训练后的模型可以进行稀疏化。现有稀疏化技术面临额外数据结构需求和在当前硬件上速度提升受限的挑战。本文提出SliceGPT,一种新的后训练稀疏化方案,通过用更小的(稠密)矩阵替换每个权重矩阵,减少网络的嵌入维度。通过广泛实验,我们展示SliceGPT能够在保持高零-shot任务性能的同时,去除多达25%的模型参数。我们的切片模型在更少的GPU上运行且速度更快,计算需求显著降低。
🔬 方法详解
问题定义:本文旨在解决大型语言模型在计算和内存资源上的高需求,现有稀疏化方法在效率和硬件适应性上存在不足。
核心思路:SliceGPT的核心思路是通过用更小的稠密矩阵替换权重矩阵,减少模型的嵌入维度,从而实现有效的后训练稀疏化。这样的设计旨在在保持模型性能的同时,显著降低计算和内存需求。
技术框架:SliceGPT的整体架构包括模型的稀疏化过程,首先识别可删除的权重,然后用稠密矩阵替换,最后进行性能验证。主要模块包括权重选择、矩阵替换和性能评估。
关键创新:SliceGPT的关键创新在于引入了计算不变性这一新见解,使得模型在稀疏化后仍能保持高效性能,这与现有方法的本质区别在于不依赖额外的数据结构。
关键设计:在参数设置上,SliceGPT通过实验确定了最佳的稀疏比例和矩阵替换策略,损失函数设计上确保了模型性能的保持,网络结构上则优化了嵌入层的维度。
🖼️ 关键图片
📊 实验亮点
实验结果显示,SliceGPT在LLAMA2-70B模型上去除25%的参数,保持99%的零-shot任务性能;在40GB A100 GPU上,推理计算需求降低至66%。这些结果表明SliceGPT在资源利用率和性能保持方面的显著优势。
🎯 应用场景
SliceGPT的研究成果具有广泛的应用潜力,尤其在需要高效计算和内存管理的自然语言处理任务中。其技术可以应用于大型语言模型的部署,降低云计算成本,提高模型的可用性和响应速度,未来可能推动更多轻量级模型的开发与应用。
📄 摘要(原文)
Large language models have become the cornerstone of natural language processing, but their use comes with substantial costs in terms of compute and memory resources. Sparsification provides a solution to alleviate these resource constraints, and recent works have shown that trained models can be sparsified post-hoc. Existing sparsification techniques face challenges as they need additional data structures and offer constrained speedup with current hardware. In this paper we present SliceGPT, a new post-training sparsification scheme which replaces each weight matrix with a smaller (dense) matrix, reducing the embedding dimension of the network. Through extensive experimentation, we show that SliceGPT can remove up to 25% of the model parameters (including embeddings) for LLAMA2-70B, OPT 66B and Phi-2 models while maintaining 99%, 99% and 90% zero-shot task performance of the dense model respectively. Our sliced models run on fewer GPUs and run faster without any additional code optimization: on 24GB consumer GPUs we reduce the total compute for inference on LLAMA2-70B to 64% of that of the dense model; on 40GB A100 GPUs we reduce it to 66%. We offer a new insight, computational invariance in transformer networks, which enables SliceGPT and we hope it will inspire and enable future avenues to reduce memory and computation demands for pre-trained models. Code is available at: https://github.com/microsoft/TransformerCompression