Papers
Topics
Authors
Recent
Gemini 2.5 Flash
Gemini 2.5 Flash
80 tokens/sec
GPT-4o
59 tokens/sec
Gemini 2.5 Pro Pro
43 tokens/sec
o3 Pro
7 tokens/sec
GPT-4.1 Pro
50 tokens/sec
DeepSeek R1 via Azure Pro
28 tokens/sec
2000 character limit reached

Long-Context Generalization with Sparse Attention (2506.16640v1)

Published 19 Jun 2025 in cs.CL and cs.AI

Abstract: 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 sparse attention mechanisms using $\alpha$-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 $\alpha$-entmax with a learnable temperature parameter, allowing the attention distribution to interpolate between sparse (pattern-focused) and dense (softmax-like) regimes. Finally, we show that the ability to locate and generalize fixed-size patterns can be further improved through a careful design of position encodings, which impacts both dense and sparse attention methods. By integrating ASEntmax into standard transformer layers alongside proper positional encodings, we show that our models greatly outperform softmax, scalable softmax, and fixed-temperature $\alpha$-entmax baselines on long-context generalization.

Long-Context Generalization with Sparse Attention: A Critical Evaluation

The paper, titled "Long-Context Generalization with Sparse Attention," rigorously examines the limitations of traditional softmax-based attention in transformer architectures for processing long sequences. It addresses critical issues such as representational collapse, over-squashing, and attention dispersion by advocating for the adoption of sparse attention mechanisms, specifically α\alpha-entmax, which assigns exactly zero probability to irrelevant tokens. This transformative approach is posited to maintain focus on pertinent tokens regardless of sequence length, a hypothesis supported by both theoretical insights and empirical evidence.

Theoretical Insights

The authors explore the foundational properties of α\alpha-entmax that make it suitable for long-context tasks. A substantial advantage of α\alpha-entmax over softmax is its ability to retain focus on specific tokens even as sequence length increases, thus preventing the dilution of attention. Lemma 1 demonstrates this non-vanishing property by illustrating that α\alpha-entmax maintains consistent token-wise attention probabilities, unlike softmax, which systematically decreases these probabilities as sequence length grows.

Further theoretical investigation reveals α\alpha-entmax's promising concentration properties. For bounded sequences, softmax disperses attention, evidenced by entropy scaling with sequence length log(n)\log(n). In contrast, α\alpha-entmax maintains entropy levels of O(logs)\mathcal{O}(\log s), where ss is the support size of non-zero attention weights, signifying concentration resilience. This entropy resilience is key in sustaining meaningful attention patterns in long sequences.

Through Proposition 4, the authors clarify how α\alpha-entmax alleviates over-squashing. By reducing gradient paths from O(nL)\mathcal{O}(n^L) to O(sL)\mathcal{O}(s^L), where LL is the number of layers, this mechanism supports effective gradient transmission across the network, thus addressing issues of gradient dilution inherent in deep transformer architectures utilizing softmax.

Empirical Evidence

The paper supports theoretical assertions with robust empirical evaluations, employing various synthetic tasks designed to test distinct aspects of long-context modeling. Among the noteworthy results are those from the Multi-query Multi-token Associative Recall (MQMTAR) tasks, where ASEntmax achieved striking performance extending 1000×\times the training length, outperforming traditional softmax significantly in sequence length generalization.

Moreover, the empirical studies highlight the adaptive scaling capabilities of ASEntmax, which tailors the attention sparsity according to sequence length and context-specific content. This adaptability is underscored by substantial performance enhancements across tasks, validating the theoretical proposition that sparse attention mechanisms, when coupled with proper scaling and positional encoding strategies, can significantly improve long-context generalization.

Positional Encoding Interaction

The authors propose NAPE (NoPE + ALiBi Positional Encoding), a hybrid approach exploiting sparse attention’s strengths alongside adaptive positional biases. They argue that this configuration synergizes well with α\alpha-entmax, enhancing robust long-context generalization. Empirical analyses show that NAPE outperforms standalone positional encoding methods like RoPE, revealing how positional information interacts with sparse attention to modulate focus effectively.

Implications and Future Prospects

This paper holds considerable implications for practical and theoretical advancements in AI, particularly in fields requiring efficient processing of extensive datasets or long dependencies. Sparse attention mechanisms, elucidated in this paper, promise to overcome limitations in current architectures, bolstering performance by maintaining meaningful token distinctions and gradient efficacy across extended inputs.

For future work, expanding sparse attention exploration in larger, production-scale models could validate the scalability of these approaches while potentially informing multi-phase strategies in extending context-length capabilities for modern LLMs. This direction could pioneer new methodologies for constructing more efficient, adaptive, and accurate LLMs.

In conclusion, "Long-Context Generalization with Sparse Attention" offers a comprehensive framework that not only tackles entrenched problems in attention mechanisms but also extends the theoretical boundaries of sequence modeling, suggesting promising avenues for future innovation in AI and machine learning domains.

User Edit Pencil Streamline Icon: https://streamlinehq.com
Authors (3)
  1. Pavlo Vasylenko (5 papers)
  2. Marcos Treviso (17 papers)
  3. André F. T. Martins (113 papers)
Youtube Logo Streamline Icon: https://streamlinehq.com