通过对齐长短序列输出分布,提升大模型长文本建模能力。
Long-Short Alignment for Effective Long-Context Modeling in LLMs
- 用输出分布一致性替代传统位置编码关注点
- 提出长-短不一致度量,与长文本泛化性能强相关
- 训练时加入对齐正则项,显著提升长上下文表现
大型语言模型在生成任务中表现出色,但其性能受限于Transformer架构的固定上下文窗口,尤其在长上下文建模方面面临挑战。其中,长度泛化——即模型对训练中未见的更长序列的适应能力——是一个基础性难题。本文提出新视角:从关注输入特征(如位置编码)转向关注模型输出分布。通过合成任务分析,发现输出分布的长-短序列一致性(长-短对齐)至关重要。进一步提出长-短不一致度量(Long-Short Misalignment),在自然语言任务中验证其与长度泛化性能强相关。基于此,设计一种训练正则项以促进对齐。大量实验表明该方法有效,为实现更高效的长上下文建模提供新思路。代码已开源。
原文摘要 · Abstract (English)
Large language models (LLMs) have exhibited impressive performance and surprising emergent properties. However, their effectiveness remains limited by the fixed context window of the transformer architecture, posing challenges for long-context modeling. Among these challenges, length generalization -- the ability to generalize to sequences longer than those seen during training -- is a classical and fundamental problem. In this work, we propose a fresh perspective on length generalization, shifting the focus from the conventional emphasis on input features such as positional encodings or data structures to the output distribution of the model. Specifically, through case studies on synthetic tasks, we highlight the critical role of \textbf{long-short alignment} -- the consistency of output distributions across sequences of varying lengths. Extending this insight to natural language tasks, we propose a metric called Long-Short Misalignment to quantify this phenomenon, uncovering a strong correlation between the metric and length generalization performance. Building on these findings, we develop a regularization term that promotes long-short alignment during training. Extensive experiments validate the effectiveness of our approach, offering new insights for achieving more effective long-context modeling in LLMs. Code is available at https://github.com/PKU-ML/LongShortAlignment.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。