Multi-Token Attention

AK's Picks LLM PTSAD Long Context
2025年04月01日
软注意力是大型语言模型(LLMs)用于在给定上下文中定位相关部分的关键机制。然而,单个注意力权重仅由单一查询向量和键向量的相似性决定。这种“单标记注意力”限制了用于区分相关部分与其余上下文的信息量。为了解决这一问题,我们提出了一种新的注意力方法——多标记注意力(Multi-Token Attention, MTA),它使大型语言模型能够同时基于多个查询向量和键向量来调整注意力权重。这是通过在查询、键和头(heads)上应用卷积操作实现的,从而允许邻近的查询和键相互影响其注意力权重,以实现更精确的注意力分配。因此,我们的方法能够利用更丰富、更细致的信息来定位相关上下文,这些信息超出了单一向量的能力范围。通过广泛的实验评估,我们证明MTA在多个流行的基准测试中表现优异。特别是在标准的语言建模任务中,MTA超越了Transformer基线模型;而在需要在长上下文中搜索信息的任务中,我们的方法利用更丰富信息的能力显得尤为有利。
Soft attention is a critical mechanism powering LLMs to locate relevant parts within a given context. However, individual attention weights are determined by the similarity of only a single query and key token vector. This "single token attention" bottlenecks the amount of information used in distinguishing a relevant part from the rest of the context. To address this issue, we propose a new attention method, Multi-Token Attention (MTA), which allows LLMs to condition their attention weights on multiple query and key vectors simultaneously. This is achieved by applying convolution operations over queries, keys and heads, allowing nearby queries and keys to affect each other's attention weights for more precise attention. As a result, our method can locate relevant context using richer, more nuanced information that can exceed a single vector's capacity. Through extensive evaluations, we demonstrate that MTA achieves enhanced performance on a range of popular benchmarks. Notably, it outperforms Transformer baseline models on standard language modeling tasks, and on tasks that require searching for information within long contexts, where our method's ability to leverage richer information proves particularly beneficial.
许愿