ProSparse: Introducing and Enhancing Intrinsic Activation Sparsity within Large Language Models

📄 arXiv: 2402.13516v7 📥 PDF

作者: Chenyang Song, Xu Han, Zhengyan Zhang, Shengding Hu, Xiyu Shi, Kuai Li, Chen Chen, Zhiyuan Liu, Guangli Li, Tao Yang, Maosong Sun

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

发布日期: 2024-02-21 (更新: 2025-01-07)

备注: 19 pages, 4 figures, 9 tables


💡 一句话要点

提出ProSparse以提升大语言模型的激活稀疏性

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

关键词: 激活稀疏性 大语言模型 推理效率 ReLU 逐步稀疏正则化 自然语言处理 模型优化

📋 核心要点

  1. 现有大型语言模型大多使用不具备激活稀疏性的激活函数,导致推理效率低下。
  2. 论文提出ProSparse方法,通过将激活函数替换为ReLU并采用逐步稀疏正则化,提升激活稀疏性。
  3. 实验结果表明,ProSparse在多个模型上实现了高达89.32%的激活稀疏性,并显著提升了推理速度。

📝 摘要(中文)

激活稀疏性指的是激活输出中存在大量贡献较弱的元素。作为使用ReLU激活函数模型的普遍特性,激活稀疏性已被证明是提升模型推理效率的有效范式。然而,大多数大型语言模型(LLMs)采用的激活函数(如GELU和Swish)并不具备内在的激活稀疏性。本文提出了一种简单有效的稀疏化方法“ProSparse”,旨在提高LLMs的激活稀疏性,同时保持相当的性能。通过将LLMs的激活函数替换为ReLU,ProSparse采用逐步稀疏正则化,避免激活分布的剧烈变化,从而增强激活稀疏性并减轻性能下降。实验结果显示,LLaMA2-7B、LLaMA2-13B和MiniCPM-1B的激活稀疏性分别达到89.32%、88.80%和87.89%,并且推理速度提升可达4.52倍。

🔬 方法详解

问题定义:本文旨在解决大型语言模型中激活函数缺乏内在稀疏性的问题,导致推理效率低下。现有方法难以在保持模型性能的同时实现高稀疏性。

核心思路:ProSparse方法通过将激活函数替换为ReLU,并引入逐步稀疏正则化,旨在提高激活稀疏性,避免激活分布的剧烈变化,从而减轻性能下降。

技术框架:ProSparse的整体架构包括激活函数替换、逐步稀疏正则化和多阶段正弦曲线的调节。该方法通过平滑的稀疏因子增加,逐步提升激活稀疏性。

关键创新:ProSparse的主要创新在于结合了ReLU激活函数与逐步稀疏正则化,显著提高了激活稀疏性,同时保持了模型的性能,超越了以往的稀疏化方法。

关键设计:在ProSparse中,稀疏因子的设置采用多阶段正弦曲线,确保激活分布的平滑过渡,避免了激活输出的剧烈波动,从而有效提升了稀疏性。具体参数设置和损失函数设计在实验部分进行了详细描述。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果显示,使用ProSparse方法的LLaMA2-7B、LLaMA2-13B和MiniCPM-1B模型的激活稀疏性分别达到了89.32%、88.80%和87.89%。此外,推理速度提升可达4.52倍,显著优于基线模型ReluLLaMA-7B和ReluLLaMA-13B。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理、对话系统和文本生成等。通过提升大语言模型的推理效率,ProSparse能够在资源受限的环境中实现更高效的模型部署,具有重要的实际价值和广泛的应用前景。

📄 摘要(原文)

Activation sparsity refers to the existence of considerable weakly-contributed elements among activation outputs. As a prevalent property of the models using the ReLU activation function, activation sparsity has been proven a promising paradigm to boost model inference efficiency. Nevertheless, most large language models (LLMs) adopt activation functions without intrinsic activation sparsity (e.g., GELU and Swish). Some recent efforts have explored introducing ReLU or its variants as the substitutive activation function to help LLMs achieve activation sparsity and inference acceleration, but few can simultaneously obtain high sparsity and comparable model performance. This paper introduces a simple and effective sparsification method named "ProSparse" to push LLMs for higher activation sparsity while maintaining comparable performance. Specifically, after substituting the activation function of LLMs with ReLU, ProSparse adopts progressive sparsity regularization with a factor smoothly increasing along the multi-stage sine curves. This can enhance activation sparsity and mitigate performance degradation by avoiding radical shifts in activation distributions. With ProSparse, we obtain high sparsity of 89.32% for LLaMA2-7B, 88.80% for LLaMA2-13B, and 87.89% for end-size MiniCPM-1B, respectively, achieving comparable performance to their original Swish-activated versions. These present the most sparsely activated models among open-source LLaMA versions and competitive end-size models, considerably surpassing ReluLLaMA-7B (66.98%) and ReluLLaMA-13B (71.56%). Our inference acceleration experiments further demonstrate the significant practical acceleration potential of LLMs with higher activation sparsity, obtaining up to 4.52$\times$ inference speedup.