三元线性注意力:用于长上下文序列建模的三维循环状态
研究论文 · 2026/10/05
循环神经网络将历史上下文压缩为固定大小的记忆状态,从而实现常数时间推理。记忆状态大小是其性能的关键因素,线性注意力通过将普通RNN的向量隐藏状态扩展到矩阵隐藏状态而表现出色。线性注意力利用键和值向量的外积写入矩阵状态,参数效率高。我们推广了这一构造,提出三元线性注意力,将键、第二键和值的三元外积写入三阶(即3D)张量状态,并通过两个查询与两个键轴收缩来读取。一个E维的第二键使状态大小增加E倍,仅增加两个投影。三元线性注意力兼容数据依赖遗忘、delta规则和分块并行训练。应用于Gated DeltaNet和标量门控线性注意力,三元线性注意力显著改善了长上下文语言建模和召回,优于扩大状态的其他替代方案。
该工作通过简单而有效的三元外积推广,在几乎不增加参数的情况下大幅提升循环模型的长上下文记忆能力,为长序列建模提供了新思路。
Recurrent neural networks (RNNs) compress the historical context into a memory state of fixed size, thus allowing for constant-time inference. The memory state size is a crucial factor in their performance, as exemplified by the strong performance and resurgence of linear attention, which extends the vector-valued hidden states of ordinary RNNs to matrix-valued hidden states. Crucially, linear attention does so in a parameter-efficient way, in particular by using an outer product of the key and value vectors to write to the matrix-valued hidden state. We generalize this construction and propose triadic linear attention, which writes the triadic outer product of a key, a second key, and a value, into a third-order (i.e., 3D) tensor state, and reads from it by contracting both key axes with two queries. An E-dimensional second key thus yields an E-fold increase in state size while adding only two projections. Triadic linear attention is compatible with data-dependent forgetting, the delta rule, and chunkwise-parallel training. Applied to Gated DeltaNet and scalar-gated linear attention, triadic linear attention substantially improves long-context language modeling and recall, outperforming alternatives that enlarge the state.