Megalodon: Efficient LLM Pretraining and Inference with Unlimited Context Length

📄 arXiv: 2404.08801v2 📥 PDF

作者: Xuezhe Ma, Xiaomeng Yang, Wenhan Xiong, Beidi Chen, Lili Yu, Hao Zhang, Jonathan May, Luke Zettlemoyer, Omer Levy, Chunting Zhou

分类: cs.LG, cs.CL

发布日期: 2024-04-12 (更新: 2024-04-16)

备注: 9 pages, 6 figures and 8 tables

🔗 代码/项目: GITHUB


💡 一句话要点

提出Megalodon以解决长序列建模效率问题

🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture)

关键词: 长序列建模 高效训练 神经网络架构 复杂指数移动平均 归一化机制

📋 核心要点

  1. 现有的Transformer模型在处理长序列时面临二次复杂度和弱长度外推的问题,限制了其扩展能力。
  2. Megalodon通过引入复杂指数移动平均和其他技术组件,旨在实现无限上下文长度的高效序列建模。
  3. 在与Llama2的对比实验中,Megalodon在效率和训练损失上均表现优异,显示出其在大规模训练中的潜力。

📝 摘要(中文)

论文介绍了Megalodon,这是一种高效的神经网络架构,旨在解决Transformer在长序列建模中的二次复杂度和弱长度外推问题。Megalodon在Mega架构的基础上,进一步引入了复杂指数移动平均(CEMA)、时间步归一化层、归一化注意力机制和双跳残差配置的预归一化等多个技术组件,以提高其能力和稳定性。在与Llama2的对比实验中,Megalodon在70亿参数和2万亿训练标记的规模下,展现出比Transformer更好的效率,训练损失为1.70,介于Llama2-7B(1.75)和13B(1.67)之间。

🔬 方法详解

问题定义:论文要解决的是Transformer在处理长序列时的二次复杂度和弱长度外推问题,这导致其在大规模训练中的效率低下和性能不足。

核心思路:Megalodon的核心思路是通过引入复杂指数移动平均(CEMA)和其他技术组件,提升序列建模的效率和稳定性,从而实现无限上下文长度的处理能力。

技术框架:Megalodon的整体架构基于Mega,包含多个模块,如复杂指数移动平均层、时间步归一化层、归一化注意力机制和双跳残差配置的预归一化层,这些模块协同工作以提高模型性能。

关键创新:Megalodon的关键创新在于其复杂指数移动平均(CEMA)和归一化注意力机制,这些设计使得模型在处理长序列时能够保持高效性和准确性,显著优于传统Transformer模型。

关键设计:在参数设置上,Megalodon采用了70亿参数的配置,训练过程中使用了2万亿的训练标记,损失函数设计为适应长序列建模的需求,确保模型在训练过程中的稳定性和收敛性。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

在与Llama2的对比实验中,Megalodon在70亿参数和2万亿训练标记的规模下,训练损失为1.70,优于Llama2-7B(1.75)和接近13B(1.67),显示出其在效率和性能上的显著提升,验证了其在长序列建模中的优势。

🎯 应用场景

Megalodon的研究成果在自然语言处理、长文本生成和对话系统等领域具有广泛的应用潜力。其高效的长序列建模能力可以为实时翻译、智能问答和内容生成等任务提供更强的支持,推动相关技术的发展与应用。未来,Megalodon可能会在更大规模的数据集上展现出更优异的性能,进一步拓展其应用范围。

📄 摘要(原文)

The quadratic complexity and weak length extrapolation of Transformers limits their ability to scale to long sequences, and while sub-quadratic solutions like linear attention and state space models exist, they empirically underperform Transformers in pretraining efficiency and downstream task accuracy. We introduce Megalodon, a neural architecture for efficient sequence modeling with unlimited context length. Megalodon inherits the architecture of Mega (exponential moving average with gated attention), and further introduces multiple technical components to improve its capability and stability, including complex exponential moving average (CEMA), timestep normalization layer, normalized attention mechanism and pre-norm with two-hop residual configuration. In a controlled head-to-head comparison with Llama2, Megalodon achieves better efficiency than Transformer in the scale of 7 billion parameters and 2 trillion training tokens. Megalodon reaches a training loss of 1.70, landing mid-way between Llama2-7B (1.75) and 13B (1.67). Code: https://github.com/XuezheMax/megalodon