Skip to main content
QUICK REVIEW

[论文解读] Compact Language Models via Pruning and Knowledge Distillation

Saurav Muralidharan, Sharath Turuvekere Sreenivas|arXiv (Cornell University)|Jul 19, 2024
Natural Language Processing TechniquesComputer Science被引用 10
一句话总结

本文表明,通过对宽度和深度轴进行结构化裁剪,随后进行基于知识蒸馏的再训练,可以压缩大型LLM,产生 Minitron 模型(8B 和 4B),在同等规模的模型中达到或超越,同时使用的训练标记数量大幅减少。

ABSTRACT

Large language models (LLMs) targeting different deployment scales and sizes are currently produced by training each variant from scratch; this is extremely compute-intensive. In this paper, we investigate if pruning an existing LLM and then re-training it with a fraction (<3%) of the original training data can be a suitable alternative to repeated, full retraining. To this end, we develop a set of practical and effective compression best practices for LLMs that combine depth, width, attention and MLP pruning with knowledge distillation-based retraining; we arrive at these best practices through a detailed empirical exploration of pruning strategies for each axis, methods to combine axes, distillation strategies, and search techniques for arriving at optimal compressed architectures. We use this guide to compress the Nemotron-4 family of LLMs by a factor of 2-4x, and compare their performance to similarly-sized models on a variety of language modeling tasks. Deriving 8B and 4B models from an already pretrained 15B model using our approach requires up to 40x fewer training tokens per model compared to training from scratch; this results in compute cost savings of 1.8x for training the full model family (15B, 8B, and 4B). Minitron models exhibit up to a 16% improvement in MMLU scores compared to training from scratch, perform comparably to other community models such as Mistral 7B, Gemma 7B and Llama-3 8B, and outperform state-of-the-art compression techniques from the literature. We have open-sourced Minitron model weights on Huggingface, with corresponding supplementary material including example code available on GitHub.

研究动机与目标

  • 评估在对现有 LLM 进行裁剪并用少量数据进行再训练是否可以替代对较小变体的全量再训练。
  • 制定跨深度、宽度、注意力和 MLP 裁剪并结合知识蒸馏的实用压缩最佳实践。
  • 通过从 Nemotron-4 15B 推导出 Minitron 模型(8B 和 4B)来演示该方法,并在语言任务中与社区模型进行对比。

提出的方法

  • 在轴向进行结构化裁剪:深度(层数)、宽度(注意力头、MLP 隐藏通道)和嵌入通道,并使用基于激活的重要性评分。
  • 使用轻量级再训练阶段(约 1.8B 个标记),并通过来自未裁剪教师模型的知识蒸馏来恢复准确性。
  • 在受限候选空间内使用轻量级神经架构搜索,在参数预算内选择裁剪后的架构。
  • 训练基于蒸馏的损失,结合 logits 与中间状态,并在 logits 损失与中间状态损失之间采用动态权重。
  • 以迭代步骤(两阶段)进行裁剪,以提升最终性能并维持能力。
  • 将裁剪后再训练的模型与从头训练的基线以及其他压缩模型在一组下游任务上进行对比。
Figure 1: Results for Minitron . Compression results in significant reduction of training costs for additional models ( $40\times$ ) while producing better results.
Figure 1: Results for Minitron . Compression results in significant reduction of training costs for additional models ( $40\times$ ) while producing better results.

实验结果

研究问题

  • RQ1是否可以对一个大型 LLM 进行裁剪并用少量数据进行再训练,以产生更小且性能较高的变体?
  • RQ2最有效的裁剪轴(深度、宽度、嵌入)应先裁剪哪一个,应该如何组合?
  • RQ3与传统再训练相比,知识蒸馏在裁剪后恢复准确性方面有多有效?
  • RQ4哪些实用的最佳实践在不降低或提升性能的前提下最大化压缩效率?

主要发现

  • 裁剪与宽度相关的组成部分(注意力头、MLP 通道、嵌入)通常比仅进行深度裁剪在重新训练后获得更好的性能,且再训练能够提升效果。
  • 对于参数量在 15B 以内的模型,宽度裁剪通常优于深度裁剪,特别是在轻量级再训练后。
  • 在再次训练期间从未裁剪的教师模型进行知识蒸馏,在下游任务性能方面显著优于传统训练。
  • 从 Nemotron-4 15B 推导 Minitron 8B 和 4B 需要最多比训练标记少 40 倍,整体族系的训练成本节省约 1.8 倍。
  • Minitron 8B 在若干基准测试上优于 Nemotron-3 8B 和 LLaMa-2 7B,并且与 Mistral-7B、Gemma-7B、Llama-3-8B 相当,同时使用的标记远少于它们(比 Nemotron-3 8B 少 40 倍)。
  • Minitron-4B 超越 Gemma2,并且与多种深度/宽度裁剪基线相比具有竞争力,指令微调版本在指令跟随和 RAG 能力方面表现出色。
Figure 2: High-level overview of our proposed iterative pruning and distillation approach to train a family of smaller LLMs.
Figure 2: High-level overview of our proposed iterative pruning and distillation approach to train a family of smaller LLMs.

阅读本论文

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

在 Nubint 中阅读本论文

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