Accelerating LLaMA Inference by Enabling Intermediate Layer Decoding via Instruction Tuning with LITE

📄 arXiv: 2310.18581v2 📥 PDF

作者: Neeraj Varshney, Agneet Chatterjee, Mihir Parmar, Chitta Baral

分类: cs.CL

发布日期: 2023-10-28 (更新: 2023-11-07)


💡 一句话要点

通过LITE方法加速LLaMA推理以解决推理效率问题

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

关键词: 大型语言模型 推理效率 指令调优 动态早期退出 中间层解码

📋 核心要点

  1. 现有大型语言模型推理速度慢且计算成本高,限制了其广泛应用。
  2. 提出通过中间层解码的指令调优方法(LITE),实现动态信心基础的早期退出,提升推理效率。
  3. 实验结果显示,动态早期退出在保持生成质量的同时,显著降低了推理计算成本。

📝 摘要(中文)

大型语言模型(LLMs)在多种自然语言任务中表现出色,但其庞大的体积导致推理速度慢且计算成本高。为了解决这一问题,本文提出了一种通过中间层解码的指令调优方法(LITE),使得中间层能够在不影响最终层生成能力的情况下,获得良好的生成能力。通过在中间层进行动态信心基础的早期退出,显著提高了文本生成的效率,同时保持了生成质量。实验结果表明,针对LLaMA-2模型的调优在多个测试集上实现了显著的推理计算成本改进,7B模型和13B模型的效率分别提升了37.86%和46.35%。

🔬 方法详解

问题定义:本文旨在解决大型语言模型推理过程中的效率问题,现有方法由于模型体积庞大,导致推理速度慢且计算成本高。

核心思路:通过对大型语言模型进行指令调优,增加来自中间层的显式损失,使得中间层能够独立获得良好的生成能力,同时不影响最终层的生成效果。

技术框架:整体架构包括指令调优模块和动态信心基础的早期退出机制。指令调优模块负责训练中间层,而早期退出机制则在生成过程中根据中间层的信心动态决定是否提前结束生成。

关键创新:最重要的创新在于引入了中间层解码的指令调优方法(LITE),通过动态信心基础的早期退出,显著提高了推理效率,与传统方法相比,能够在保持生成质量的同时减少计算负担。

关键设计:在损失函数设计上,增加了来自中间层的损失项,以指导中间层的学习;在网络结构上,确保中间层与最终层的生成能力相辅相成,避免相互干扰。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,采用动态早期退出机制后,7B模型的推理计算成本降低了37.86%,而13B模型的降低幅度更是达到46.35%。这些结果在多个测试集上均表现出一致性和显著性,证明了方法的有效性。

🎯 应用场景

该研究的潜在应用领域包括自然语言处理、对话系统和智能助手等。通过提高大型语言模型的推理效率,可以使其在实时应用中更具实用性,推动其在各行业的广泛应用,尤其是在需要快速响应的场景中。

📄 摘要(原文)

Large Language Models (LLMs) have achieved remarkable performance across a wide variety of natural language tasks; however, their large size makes their inference slow and computationally expensive. Focusing on this problem, we propose to instruction tune LLMs with additional explicit losses from the intermediate layers (LITE) and show that it enables these layers to acquire 'good' generation ability without affecting the generation ability of the final layer. We perform 'dynamic confidence-based early exiting' at token level from the intermediate layers which improves the efficiency of text generation without compromising the quality of the generation. We conduct comprehensive experiments by instruction tuning LLaMA-2 models on the Alpaca dataset and holistically evaluate on four different human-instruction test sets. We show that dynamic early exiting achieves consistent and considerable inference computation cost improvements (37.86% for 7B and 46.35% for 13B model) while maintaining the generation quality of the responses. We further conduct a thorough analysis of the results over several important aspects, such as comparing the semantic similarity of the outputs and dissecting the efficiency improvements by comparing the number of tokens generated in the output. In summary, our work contributes to improving the efficiency of LLM inference while maintaining the generation quality, a crucial step en route to enabling their widespread adoption.