Abstract
Large Language Models (LLMs) face significant challenges in processing long sequences due to the quadratic complexity of self-attention and the limitations of unidirectional causal memory. We present ATTENDRE, a novel architecture that enables bidirectional attention in a streaming context by delaying query processing. By buffering queries in a dedicated memory and utilizing importance-based eviction policies (LRA/LFA), ATTENDRE achieves superior performance and memory efficiency compared to standard FIFO-based memory systems.
Introduction
The ability to process long contexts is critical for tasks like multi-document reasoning and long-form summarization. While chunking and Key-Value (KV) memory provide a partial solution, they are typically constrained by causality—queries can only attend to past tokens. This prevents the use of bidirectional architectures in streaming scenarios. Furthermore, standard memory management often relies on First-In, First-Out (FIFO) eviction, which fails to preserve the most relevant information.
Methodology
The ATTENDRE Layer
The core innovation of this work is the ATTENDRE layer, which introduces a "wait-and-see" approach to attention. Instead of immediate execution, queries are stored in a Query-memory (Q-memory). As the model ingests subsequent text chunks into its KV-memory, the buffered queries eventually reach their "future" context.
When a query is evicted from the Q-memory, it performs retrieval against the current state of the KV-memory, which now contains tokens that were originally ahead of it in the sequence. This mechanism effectively bridges the gap between streaming efficiency and bidirectional modeling.
Streaming and Temporal Shifting
To maintain consistency across layers, the model employs a temporal shift. This ensures that at any given step, the memory contains a sufficient window of context for the delayed queries to produce meaningful outputs.
Smart Eviction Policies
Beyond the architectural shift, we propose two attention-aware eviction policies:
- Least Recently Attended (LRA): Prioritizes tokens that have been frequently accessed by recent queries.
- Least Frequently Attended (LFA): Maintains tokens with high cumulative attention scores over the entire sequence.
These policies treat attention scores as a proxy for token importance, allowing the model to retain "globally useful" information while discarding noise.
Experimental Setup
We evaluated ATTENDRE on the TriviaQA dataset, a benchmark for long-context reading comprehension. We tested two primary model architectures:
- PaLM 2-S: A decoder-only model.
- FLAN-T5 XXL: An encoder-decoder model, which traditionally requires bidirectional attention for optimal performance.
Results and Discussion
Our experiments demonstrate that ATTENDRE significantly improves both efficiency and accuracy.
- Memory Efficiency: Smart eviction (LRA/LFA) allows a memory of just 128 slots to match the performance of a 2,048-slot FIFO memory, representing a 16x improvement in memory utilization.
- Performance Gains: On TriviaQA, the PaLM 2-S model with ATTENDRE achieved an Exact Match (EM) score of 63.40, outperforming the full-sequence baseline (59.27).
- Bidirectional Support: ATTENDRE enabled FLAN-T5 XXL to scale to long contexts in a streaming fashion, a feat previously difficult for encoder-decoder models using standard causal memory.
Conclusion
ATTENDRE offers a robust solution for long-context processing by rethinking the temporal constraints of attention. By delaying queries and using importance-based memory management, we can achieve bidirectional capabilities with high memory efficiency. Future work will explore differentiable eviction mechanisms and broader task evaluations.
Summary updated