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

局部与全局注意力的双重维度

Dual Dimensionality for Local and Global Attention

UC Santa Barbara(加州大学圣塔芭芭拉分校)

Zhiyuan Wang, Xuan Luo, Sirui Zeng, Xifeng Yan

AI总结:

提出距离自适应表示(DAR),对局部上下文保留全维度表示,对远距离token使用低维表示,在保持性能的同时减少KV缓存。

摘要:

解码器仅Transformer计算前面token的KV缓存上的注意力。键(和值)通常以相同的维度表示,无论其与预测目标的距离如何。然而,在自然语言中,下一个词受紧邻的前一个词影响最大。我们假设局部和远距离token对表示能力有不对称需求:局部token对预测即时输出更关键,因此需要更丰富的表示,而远距离token主要作为长期记忆,低维表示可能就足够了。我们将这一思想形式化为距离自适应表示(DAR),在受控设置中实现,该设置在局部上下文窗口内保留全维度表示,同时为超出该窗口的token分配降维表示(例如原始维度的1/4)。在多个预训练规模(70M到410M参数)以及1B规模模型上的持续监督微调中,该方法与全维度基线的性能紧密匹配。相比之下,在所有token位置上均匀降低维度会导致性能下降。这些结果挑战了键和值维度应在所有token位置上均匀的常见假设。我们的发现为设计注意力架构提供了新方向,该架构可自适应地跨序列分配表示能力,从而在推理期间进一步减少KV缓存。

英文摘要:

Decoder-only Transformers compute attention over the KV cache of preceding tokens. Keys and Values are typically represented with the same dimensionality, regardless of their distance from the prediction target. In natural language, however, the next word is most strongly influenced by the immediately preceding tokens. We hypothesize that local and distant tokens impose asymmetric demands on representational capacity: local tokens are more critical for predicting immediate outputs and thus require richer representations, whereas distant tokens primarily serve as long-range memory, for which lower-dimensional representations may suffice. We formalize this idea as Distance-Adaptive Representation (DAR), which preserves full-dimensional representations within a local context window while assigning reduced-dimensional representations (e.g. 1/2 or 1/4 of the original dimensionality) to tokens beyond that window. Across multiple pretraining scales (70M to 410M parameters), as well as continued supervised fine-tuning on a 1B-scale model, this approach closely matches the performance of full-dimensional baselines. In contrast, uniformly reducing dimensionality across all token positions leads to worse performance. These results challenge the common assumption that key and value dimensionality should be uniform across token positions. We further develop an efficient realization of DAR that achieves model quality comparable to the MLA baseline while reducing the average KV-cache size by 68.8\% at 8K context and achieving up to a $1.9\times$ decoding speedup at 128K context on the evaluated models. Our findings suggest a new direction for designing attention architectures that allocate representational capacity according to token distance to reduce KV-cache during inference.

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

↑