Skip to main content
QUICK REVIEW

[论文解读] LLM Pruning and Distillation in Practice: The Minitron Approach

Sharath Turuvekere Sreenivas, Saurav Muralidharan|arXiv (Cornell University)|Aug 21, 2024
Metallurgical Processes and ThermodynamicsEngineering被引用 3
一句话总结

本文提出了 Minitron 方法,通过结构化剪枝和知识蒸馏,将 Llama 3.1 8B 和 Mistral NeMo 12B 模型压缩至 4B 和 8B 参数。通过引入「教师模型校正」——在蒸馏数据集上对教师模型进行微调——该方法在仅使用 150 倍少的训练 token 情况下实现了最先进性能,生成的 MN-Minitron-8B 模型在基准测试中优于所有同规模的开源模型。

ABSTRACT

We present a comprehensive report on compressing the Llama 3.1 8B and Mistral NeMo 12B models to 4B and 8B parameters, respectively, using pruning and distillation. We explore two distinct pruning strategies: (1) depth pruning and (2) joint hidden/attention/MLP (width) pruning, and evaluate the results on common benchmarks from the LM Evaluation Harness. The models are then aligned with NeMo Aligner and tested in instruct-tuned versions. This approach produces a compelling 4B model from Llama 3.1 8B and a state-of-the-art Mistral-NeMo-Minitron-8B (MN-Minitron-8B for brevity) model from Mistral NeMo 12B. We found that with no access to the original data, it is beneficial to slightly fine-tune teacher models on the distillation dataset. We open-source our base model weights on Hugging Face with a permissive license.

研究动机与目标

  • 通过将大型语言模型家族压缩为更小、更高效的变体,降低其训练的计算和数据成本。
  • 解决在无法获取原始训练数据时,因数据分布不匹配导致蒸馏失败的挑战。
  • 在最小化微调的前提下,实现压缩模型在准确率和推理速度方面的最先进性能。
  • 证明即使在无法访问原始数据的情况下,通过教师模型校正的知识蒸馏也能实现卓越性能,尤其适用于从更大模型进行压缩。

提出的方法

  • 应用结构化权重剪枝压缩教师模型,采用两种策略:深度剪枝(移除整个层)和宽度剪枝(移除注意力头、MLP 维度和嵌入通道)。
  • 引入「教师模型校正」——在剪枝和蒸馏前,对教师模型在蒸馏数据集上进行轻量级微调,使其输出分布与目标数据对齐。
  • 使用知识蒸馏恢复剪枝过程中损失的准确率,训练学生模型以模仿剪枝并校正后的教师模型的 logits 输出。
  • 使用 NVIDIA TensorRT-LLM 优化推理,采用 FP8 精度,提升 H100 GPU 上的吞吐量和延迟表现。
  • 在多个基准测试(包括 LM-Evaluation Harness、IFEval、MT-Bench 和 ChatRAG)上评估性能,对不同模型变体进行一致的消融实验与对比分析。
  • 在 Hugging Face 上以宽松许可证开源基础模型权重,供社区使用和进一步研究。
Figure 1: High-level overview of our proposed pruning and distillation approach. The total number of tokens used for each step is indicated in parentheses.
Figure 1: High-level overview of our proposed pruning and distillation approach. The total number of tokens used for each step is indicated in parentheses.

实验结果

研究问题

  • RQ1在无法获取原始训练数据的情况下,对教师模型在蒸馏数据集上进行微调(即教师模型校正)是否能显著提升蒸馏性能?
  • RQ2在蒸馏后,深度剪枝与宽度剪枝策略在准确率和推理效率方面如何比较?
  • RQ3尽管仅使用 3800 亿个训练 token,压缩后的 8B 模型(MN-Minitron-8B)是否能在与其它开源 8B 模型对比中实现最先进性能?
  • RQ4在剪枝后,知识蒸馏在下游任务(如 GSM8k 和 HumanEval)上是否能恢复甚至提升性能?
  • RQ5结构化剪枝对指令微调变体在推理和指令遵循能力方面有何影响?

主要发现

  • MN-Minitron-8B 模型在所有基准测试中均优于所有同规模的开源模型,包括在 Hellaswag 上达到 85.3%,在 MMLU 上达到 70.1%,尽管其训练 token 数量仅为 3800 亿,远低于教师模型的 15 万亿。
  • Llama-3.1-Minitron-4B-Width 变体在 MMLU 上达到 60.5%,在 GSM8k 上达到 41.2%,优于教师模型 Llama 3.1 8B 和上一代 Minitron-4B 模型。
  • Llama-3.1-Minitron-4B-Depth 变体在单张 H100 GPU 上实现 2.7 倍的吞吐量加速,而宽度变体在 FP8 推理中实现 1.8 倍加速。
  • 教师模型校正使语言模型验证损失降低超过 6%,证明其在缓解蒸馏过程中数据分布不匹配问题方面具有关键作用。
  • MN-Minitron-8B 模型在两个基准测试中优于教师模型 Mistral NeMo 12B:GSM8k(58.5% vs. 55.7%)和 HumanEval(36.2% vs. 23.8%),且未进行额外训练,仅依赖蒸馏过程。
  • 保留注意力头、剪枝 MLP 和嵌入维度的宽度剪枝策略,在准确率上优于深度剪枝,尤其在推理和函数调用类任务中表现更优。
Figure 2: Pruning and distillation process outlined in the original paper [ 1 ] . We follow the same approach in this work.
Figure 2: Pruning and distillation process outlined in the original paper [ 1 ] . We follow the same approach in this work.

阅读本论文

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

在 Nubint 中阅读本论文

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