arXiv:2504.13981cs.LGcs.AI2025-04被引 1

用缓存机制提升长文本注意力效率,降低困惑度8.5%。

CacheFormer: High Attention-Based Segment Caching

  • 借鉴计算机缓存原理,按段落动态加载高注意力区域的原始数据。
  • 在相同模型规模下,平均困惑度降低8.5%,优于现有最优方法。
  • 适合需要高效处理长序列的场景,如文档理解与生成。

在基于Transformer的语言模型中,高效处理长上下文且保持低困惑度仍是研究热点。尽管近期提出如Linformer、Longformer、Performer及结构化状态空间模型(SSMs)等方法,仍未完全解决该问题。这些模型致力于降低注意力机制的二次时间复杂度,同时尽量减少因压缩长上下文带来的性能损失。受计算机缓存与虚拟内存机制启发——缓存未命中时不仅获取所需数据,还会一并加载邻近数据——我们将其应用于长上下文处理,将上下文划分为小段。当压缩级别下检测到高段级注意力时,系统会以未压缩形式检索附近段落。所提增强包括:短滑动窗口注意力、长压缩分段注意力、动态检索顶部k个高注意力未压缩段落,以及在长段注意力中引入重叠以避免段落碎片化。该架构在相似模型规模下,平均困惑度相比现有最先进方法提升8.5%。

原文摘要 · Abstract (English)

Efficiently handling long contexts in transformer-based language models with low perplexity is an active area of research. Numerous recent approaches like Linformer, Longformer, Performer, and Structured state space models (SSMs)., have not fully resolved this problem. All these models strive to reduce the quadratic time complexity of the attention mechanism while minimizing the loss in quality due to the effective compression of the long context. Inspired by the cache and virtual memory principle in computers, where in case of a cache miss, not only the needed data is retrieved from the memory, but the adjacent data is also obtained, we apply this concept to handling long contexts by dividing it into small segments. In our design, we retrieve the nearby segments in an uncompressed form when high segment-level attention occurs at the compressed level. Our en-hancements for handling long context include aggregating four attention mechanisms consisting of short sliding window attention, long compressed segmented attention, dynamically retrieving top k high attention uncompressed segments, and overlapping segments in long segment attention to avoid segment fragmentation. These enhancements result in an architecture that outperforms ex-isting SOTA architectures with an average perplexity improvement of 8.5% over similar model sizes.

注意力机制长文本处理缓存优化

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。