Liger: Linearizing Large Language Models to Gated Recurrent Structures
本文提出了一种名为Liger的新方法,通过线性化预训练的大语言模型(LLMs)为门控循环结构,从而实现高效的部署和性能恢复。
更新于 2025-03-04。作者:Disen Lan、Weigao Sun、Jiaxi Hu、Jusen Du、Yu Cheng。
中文摘要
线性循环建模的Transformer提供线性时间训练和常数内存推理。尽管它们展示了高效和良好的性能,但从零开始预训练这种非标准架构仍然成本高昂且风险较大。大型语言模型(LLMs)的线性化将预训练的标准模型转换为线性循环结构,从而实现更高效的部署。然而,当前的线性化方法通常引入额外的特征图模块,这些模块需要大量的微调,并且忽略了最先进的线性循环模型中使用的门控机制。为了解决这些问题,本文提出了Liger,即“将LLMs线性化至门控循环结构”。Liger是一种新颖的方法,可以将预训练的LLMs转换为门控线性循环模型,而无需添加额外的参数。它重新利用预训练的关键矩阵权重来构建各种门控机制,便于形成不同的门控循环结构,同时避免从头开始训练额外组件的需求。使用轻量级微调结合低秩自适应(LoRA),Liger将线性化后的门控循环模型性能恢复到与原始LLMs相匹配。此外,我们还引入了Liger Attention,这是一种层内混合注意力机制,在线性化过程中,它显著恢复了Transformer-based LLM的93%,在预训练标记为0.02%的情况下,在多个基准测试中实现了具有竞争力的结果,这已在从1B到8B参数的模型上得到验证。代码可在https://github.com/OpenSparseLLMs/Linearization获取。
英文摘要
Transformers with linear recurrent modeling offer linear-time training and constant-memory inference. Despite their demonstrated efficiency and performance, pretraining such non-standard architectures from scratch remains costly and risky. The linearization of large language models (LLMs) transforms pretrained standard models into linear recurrent structures, enabling more efficient deployment. However, current linearization methods typically introduce additional feature map modules that require extensive fine-tuning and overlook the gating mechanisms used in state-of-the-art linear recurrent models. To address these issues, this paper presents Liger, short for Linearizing LLMs to gated recurrent structures. Liger is a novel approach for converting pretrained LLMs into gated linear recurrent models without adding extra parameters. It repurposes the pretrained key matrix weights to construct diverse gating mechanisms, facilitating the formation of various gated recurrent structures while avoiding the need to train additional components from scratch. Using lightweight fine-tuning with Low-Rank Adaptation (LoRA), Liger restores the performance of the linearized gated recurrent models to match that of the original LLMs. Additionally, we introduce Liger Attention, an intra-layer hybrid attention mechanism, which significantly recovers 93\% of the Transformer-based LLM at 0.02\% pre-training tokens during the linearization process, achieving competitive results across multiple benchmarks, as validated on models ranging from 1B to 8B parameters. Code is available at https://github.com/OpenSparseLLMs/Linearization.
解读
一句话总结
本文提出了一种名为Liger的新方法,通过线性化预训练的大语言模型(LLMs)为门控循环结构,从而实现高效的部署和性能恢复。
问题1:这篇论文想要解决什么具体问题?
- 问题背景:现有的LLMs基于Transformer架构,其计算复杂度为二次方,导致训练和推理效率低下,尤其是在处理长序列时。
- 现有方案不足:线性化LLMs的方法通常需要引入额外的特征映射模块,这需要大量的微调,并且忽略了门控机制在先进线性循环模型中的作用。
- 研究目标:提出一种新的方法,将预训练的LLMs转换为门控线性循环模型,而不增加额外的参数,同时通过轻量级微调恢复模型性能。
问题2:论文的核心创新点是什么?
- 技术创新:Liger通过重新利用预训练的关键矩阵权重来构建门控机制,避免了复杂的关键转移过程。
- 方法改进:Liger引入了Liger Attention,这是一种层内混合注意力机制,结合了滑动窗口softmax注意力和线性循环建模。
- 优势:Liger在保持预训练LLMs性能的同时,实现了高效的线性推理效率。
问题3:实验结果如何验证了方法的有效性?
- 关键实验:Liger在多个基准测试中进行了评估,包括PiQA、ARC-e、ARC-c、HellaSwag、WinoGrande和MMLU。
- 性能提升:Liger在语言建模和理解任务上优于现有的线性化方法,如SUPRA、MambaInLlama和LoLCATs。
- 对比结果:Liger在Llama3系列模型(1B至8B参数)上实现了高效的线性化,并且在性能上优于其他方法。
问题4:这个研究的实际应用价值是什么?
- 应用场景:Liger可以用于自然语言理解、基因组序列分析、时间序列预测等需要长序列处理和高效计算的任务。
- 实施建议:Liger可以通过轻量级微调应用于各种LLMs,以实现高效的线性化。
- 局限与展望:Liger在处理非常长的序列时可能存在限制,未来可以探索更有效的线性化方法来处理更长的序列。