LM-Infinite:大型语言模型的零样本极端长度泛化
LM-Infinite: Zero-Shot Extreme Length Generalization for Large Language Models
AI总结:
本研究提出LM-Infinite方法,无需参数更新即可让预训练于短文本的LLMs泛化至200M长度输入,保持困惑度并提升下游任务性能,同时实现2.7倍解码加速和7.5倍内存节省。
摘要:
当今的大型语言模型(LLMs)通常由于Transformer架构的二次复杂度而在短文本片段(例如,<4K个标记)上进行训练。因此,当输入长度超过训练时遇到的长度时,它们的性能会急剧下降,这极大地限制了它们在涉及长上下文的现实任务中的应用,如编码科学文章、代码库或长对话。通过理论分析和实证研究,这项工作确定了导致这种长度泛化失败的三个主要因素。我们的理论分析进一步揭示了常用的技术,如截断注意力窗口或相对位置编码,不足以解决这些问题。针对这些挑战,我们提出了LM-Infinite,一种简单有效的方法,用于增强LLMs处理长上下文的能力。LM-Infinite高度灵活,可以与大多数现代LLMs直接使用。无需任何参数更新,它允许预训练有2K或4K长片段的LLMs泛化到长达200M长度的输入,同时保持困惑度。它还提高了零样本设置下如Passkey Retrieval和Qasper等下游任务的性能。LM-Infinite带来了显著的效率提升:与原始模型相比,它实现了2.7倍的解码加速和7.5倍的内存节省。我们的代码发布在\url{https://github.com/Glaciohound/LM-Infinite}。
英文摘要:
Today's large language models (LLMs) typically train on short text segments (e.g., <4K tokens) due to the quadratic complexity of their Transformer architectures. As a result, their performance suffers drastically on inputs longer than those encountered during training, substantially limiting their applications in real-world tasks involving long contexts such as encoding scientific articles, code repositories, or long dialogues. Through theoretical analysis and empirical investigation, this work identifies three major factors contributing to this length generalization failure. Our theoretical analysis further reveals that commonly used techniques like truncating the attention window or relative positional encodings are inadequate to address them. Answering these challenges, we propose LM-Infinite, a simple and effective method for enhancing LLMs' capabilities of handling long contexts. LM-Infinite is highly flexible and can be used with most modern LLMs off-the-shelf. Without any parameter updates, it allows LLMs pre-trained with 2K or 4K-long segments to generalize to up to 200M length inputs while retaining perplexity. It also improves performance on downstream tasks such as Passkey Retrieval and Qasper in the zero-shot setting. LM-Infinite brings substantial efficiency improvements: it achieves 2.7x decoding speed up and 7.5x memory saving over the original model. Our codes are released at \url{https://github.com/Glaciohound/LM-Infinite}.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。