Sheared LLaMA: Accelerating Language Model Pre-training via Structured Pruning

📄 arXiv: 2310.06694v2 📥 PDF

作者: Mengzhou Xia, Tianyu Gao, Zhiyuan Zeng, Danqi Chen

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

发布日期: 2023-10-10 (更新: 2024-04-11)

备注: The code and models are available at https://github.com/princeton-nlp/LLM-Shearing


💡 一句话要点

提出Sheared LLaMA以加速语言模型预训练

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

关键词: 结构化剪枝 语言模型 预训练 动态批量加载 小型模型 自然语言处理 高效训练

📋 核心要点

  1. 现有大型语言模型的训练成本高昂,限制了小型模型的开发与应用。
  2. 提出通过结构化剪枝和动态批量加载技术,从预训练的大型模型中高效生成小型语言模型。
  3. Sheared-LLaMA模型在多个评估任务中表现优异,且计算资源消耗显著低于从头训练的模型。

📝 摘要(中文)

LLaMA及其他中型大型语言模型的流行凸显了构建更小但强大的语言模型的潜力。然而,从头开始训练这些模型的成本依然很高。本文研究了结构化剪枝作为从预训练的大型模型中开发更小语言模型的有效手段。我们的方法采用了两项关键技术:目标结构化剪枝和动态批量加载。通过Sheared-LLaMA系列,我们将LLaMA2-7B模型剪枝至1.3B和2.7B参数,结果表明,Sheared-LLaMA模型在多种下游任务和指令调优评估中超越了同类开源模型,同时仅需3%的计算资源,相较于从头训练模型更具成本效益。

🔬 方法详解

问题定义:本文旨在解决从头训练大型语言模型的高成本问题,现有方法在资源消耗和效率上存在不足。

核心思路:通过结构化剪枝技术,从预训练的大型模型中提取出小型模型,结合动态批量加载以优化训练过程。

技术框架:整体方法包括两个主要模块:目标结构化剪枝模块和动态批量加载模块。前者负责模型的剪枝,后者根据不同领域的损失动态调整训练数据。

关键创新:最重要的创新在于结合了目标结构化剪枝与动态批量加载,使得模型在剪枝后仍能保持高效的训练性能。

关键设计:在剪枝过程中,针对特定目标形状移除层、头和中间维度,动态批量加载则根据损失变化调整样本组成,以提高训练效率。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

Sheared-LLaMA模型在多个下游任务和指令调优评估中表现优于同类开源模型,如Pythia和TinyLlama,且训练所需计算资源仅为从头训练的3%。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理、对话系统和智能助手等。通过降低训练成本,Sheared LLaMA可以促进小型语言模型的广泛应用,推动相关技术的普及与发展。

📄 摘要(原文)

The popularity of LLaMA (Touvron et al., 2023a;b) and other recently emerged moderate-sized large language models (LLMs) highlights the potential of building smaller yet powerful LLMs. Regardless, the cost of training such models from scratch on trillions of tokens remains high. In this work, we study structured pruning as an effective means to develop smaller LLMs from pre-trained, larger models. Our approach employs two key techniques: (1) targeted structured pruning, which prunes a larger model to a specified target shape by removing layers, heads, and intermediate and hidden dimensions in an end-to-end manner, and (2) dynamic batch loading, which dynamically updates the composition of sampled data in each training batch based on varying losses across different domains. We demonstrate the efficacy of our approach by presenting the Sheared-LLaMA series, pruning the LLaMA2-7B model down to 1.3B and 2.7B parameters. Sheared-LLaMA models outperform state-of-the-art open-source models of equivalent sizes, such as Pythia, INCITE, OpenLLaMA and the concurrent TinyLlama models, on a wide range of downstream and instruction tuning evaluations, while requiring only 3% of compute compared to training such models from scratch. This work provides compelling evidence that leveraging existing LLMs with structured pruning is a far more cost-effective approach for building competitive small-scale LLMs