arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2506.16640cs.CLcs.AI

长上下文泛化与稀疏注意力

Long-Context Generalization with Sparse Attention

Instituto Superior Técnico, Universidade de Lisboa(里斯本大学技术高级学院);Instituto de Telecomunicações(电信研究所);TransPerfect(TransPerfect公司);ELLIS Unit Lisbon(里斯本ELLIS单位)

Pavlo Vasylenko, Hugo Pitorro, André F. T. Martins, Marcos Treviso

AI总结:

本文提出ASEntmax,通过动态稀疏注意力机制提升长上下文泛化能力,在合成任务和语言建模中表现优于传统softmax和α-entmax方法。

摘要:

基于Transformer的架构传统上使用softmax计算注意力权重,这会产生对序列中所有token的密集分布。尽管在许多情况下有效,但这种密度已被证明对需要精确聚焦于固定大小模式的任务是有害的:随着序列长度增加,无信息的token积累注意力概率质量,导致分散和表示崩溃。本文展示,通过使用α-entmax的动态稀疏注意力机制可以避免这些问题,因为它们能够将无关token分配精确的零。此外,我们引入了自适应可扩展entmax(ASEntmax),它赋予α-entmax一个可学习的温度参数,使注意力分布能够在稀疏(模式聚焦)和密集(softmax-like)之间插值。我们在合成任务和语言建模上的实证评估表明,ASEntmax在合成基准上实现了高达1000倍长度外推,并在语言建模中实现了更优的长上下文泛化,同时保持短上下文性能,包括更好的困惑度趋势和在8倍训练长度下的更高检索准确性。

英文摘要:

Transformer-based architectures traditionally employ softmax to compute attention weights, which produces dense distributions over all tokens in a sequence. While effective in many settings, this density has been shown to be detrimental for tasks that demand precise focus on fixed-size patterns: as sequence length increases, non-informative tokens accumulate attention probability mass, leading to dispersion and representational collapse. We show in this paper that dynamically sparse attention mechanisms using $α$-entmax can avoid these issues, due to their ability to assign exact zeros to irrelevant tokens. Furthermore, we introduce Adaptive-Scalable Entmax (ASEntmax), which endows $α$-entmax with a learnable temperature parameter, allowing the attention distribution to interpolate between sparse (pattern-focused) and dense (softmax-like) regimes. Our empirical evaluation on synthetic tasks and language modeling demonstrates that ASEntmax substantially outperforms softmax, scalable softmax, and fixed-temperature $α$-entmax baselines, achieving up to 1000$\times$ length extrapolation on synthetic benchmarks and superior long-context generalization on language modeling while preserving short-context performance, including better perplexity trends and higher retrieval accuracies at 8$\times$ training length.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑