短窗口注意力促进长时记忆,提升模型全局理解能力
Short window attention enables long-term memorization
- 采用随机变化的滑动窗口大小,强制模型兼顾短期与长期记忆
- 大窗口反而降低长上下文性能,小窗口更利于训练长时记忆
- 适用于需要平衡局部细节与全局依赖的任务,如长文本生成
近期研究表明,结合局部滑动窗口注意力与全局注意力的混合架构优于单一架构。然而,窗口长度的影响及两类层之间的相互作用仍缺乏深入研究。本文分析了短窗与长窗注意力在SWAX(滑动窗口注意力与xLSTM线性RNN结合)架构中的交互机制,发现更大窗口反而损害长上下文表现。这是因为大窗口使模型依赖局部softmax注意力,削弱了对xLSTM长时记忆的训练。在交替使用短窗口与全注意力的架构中,短层应保持较小以避免干扰长层。但窗口过小也会损害短上下文任务表现,可通过适度增大窗口获取信息。因此,我们通过随机调整滑动窗口大小进行训练,迫使模型同时利用短期窗口和长期记忆。该方法在短、长上下文任务上均显著优于固定窗口注意力。
原文摘要 · Abstract (English)
Recent works show that hybrid architectures combining local sliding window attention layers and global attention layers outperform either of these architectures taken separately. However, the impact of the window length and the interplay between local layers and global layers remain under-studied. In this work, we first analyze the interaction between short and long term memory by considering SWAX: a hybrid architecture consisting of sliding-window attention and xLSTM linear RNN layers. A counter-intuitive finding is that larger sliding windows hurts the long-context performance. In fact, short window attention encourages the model to better train the long-term memory of the xLSTM as it cannot rely on the local softmax attention mechanism for long context-retrieval. We also validate our findings on local-global architectures alternating short window and full attention layers: the short layers should be small in order not to hinder the usefulness of the long layers. However, employing too small sliding windows is detrimental even for short-context tasks, which could be solved with information from moderately larger sliding windows otherwise. Therefore, we train hybrid architectures by stochastically changing the sliding window size, forcing the model to leverage both the short term window and the long-term memory. Training with stochastic window sizes significantly outperforms regular window attention both on short and long-context problems.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。