用于高效长期记忆访问的硬件对齐分层稀疏注意力
Hardware-aligned Hierarchical Sparse Attention for Efficient Long-term Memory Access
AI总结:
提出分层稀疏注意力(HSA)机制增强RNNs的随机访问能力,结合硬件对齐内核与Mamba构建RAMba,在保持高效和恒定内存的同时显著提升了长上下文建模与检索性能。
摘要:
循环神经网络(RNNs)相较于Transformers的一个关键优势在于,其线性的计算和空间复杂度使其能够对长序列实现更快的训练和推理。然而,RNNs从根本上无法随机访问历史上下文,而简单地集成注意力机制可能会削弱其效率优势。为了克服这一局限性,我们提出了分层稀疏注意力(HSA),这是一种新颖的注意力机制,它通过长程随机访问灵活性来增强RNNs,同时保留其在效率和长度泛化方面的优势。HSA将输入划分为块,选择top-$k$个块并分层聚合信息。其核心创新在于基于每个块内部的细粒度token级信息来学习token到块的相关性。这种方法提高了在域内和域外上下文长度下块选择的精度。为了使HSA高效,我们进一步引入了硬件对齐的内核设计。通过将HSA与Mamba结合,我们提出了RAMba,它仅在4K长度上下文上进行预训练,却能在6400万上下文的密钥检索中实现完美的准确率,并且在各种下游任务上取得显著提升,同时保持几乎恒定的内存占用。这些结果表明RAMba在长上下文建模方面的巨大潜力。
英文摘要:
A key advantage of Recurrent Neural Networks (RNNs) over Transformers is their linear computational and space complexity enables faster training and inference for long sequences. However, RNNs are fundamentally unable to randomly access historical context, and simply integrating attention mechanisms may undermine their efficiency advantages. To overcome this limitation, we propose Hierarchical Sparse Attention (HSA), a novel attention mechanism that enhances RNNs with long-range random access flexibility while preserving their merits in efficiency and length generalization. HSA divides inputs into chunks, selects the top-$k$ chunks and hierarchically aggregates information. The core innovation lies in learning token-to-chunk relevance based on fine-grained token-level information inside each chunk. This approach enhances the precision of chunk selection across both in-domain and out-of-domain context lengths. To make HSA efficient, we further introduce a hardware-aligned kernel design. By combining HSA with Mamba, we introduce RAMba, which achieves perfect accuracy in passkey retrieval across 64 million contexts despite pre-training on only 4K-length contexts, and significant improvements on various downstream tasks, with nearly constant memory footprint. These results show RAMba's huge potential in long-context modeling.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。