arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2611.38402cs.LG
收藏

直接访问注意力:在计算量远小于Softmax注意力、线性注意力和状态空间模型的情况下实现关联记忆

Direct access attention: associative recall at a fraction of the compute of softmax, linear attention and state-space models

i14

Simon Dennis, Rivaan Patil, Hao Guo, Kevin Shabahang

AI总结:

该研究提出直接访问注意力,以整数查找替代上下文搜索,在关联记忆任务中,相比线性注意力和状态空间模型,在保留Softmax注意力准确率的同时大幅降低计算成本。

摘要:

直接访问注意力将上下文搜索替换为学习到的整数查找。每个token被投影到一个$d_k$维的编码,其符号选择$2^{d_k}$个记忆单元之一,对应的值被写入该单元;当查询的符号匹配时,每个头可在$O(d_k+d_v)$次操作中检索到该值,且操作量与上下文长度$T$无关。Softmax注意力将每个查询与所有上下文键进行比较,每个头的操作量为$O(T(d_k+d_v))$,可区分$2^{O(d_k)}$对;线性注意力将对叠加到固定宽度矩阵中,操作量为$O(d_k d_v)$,与$T$无关,但每个头仅能区分$O(d_k)$对。直接访问用键和值宽度的总和替代其乘积,并提供$2^{d_k}$个单元,代价是每个头需存储$2^{d_k} d_v$个值。一种高效的可微训练算法将地址学习分解为$d_k$个独立的比特概率,这使得梯度可调整地址;推理时每个比特变为确定的二元选择,实现整数查找,当这些概率趋近于0或1时,训练与推理过程一致。由于仅交叉熵无法可靠产生此类确定性,在模型学会将查询与正确键匹配后,我们添加地址熵惩罚。在上下文关联记忆任务中,参数数量匹配的单层模型在8到512个存储对的所有测试任务规模上,使用直接访问注意力或Softmax注意力均达到100%准确率;在512对时,线性注意力准确率为0.340,具有相同状态规模的选择性状态空间模型在超过32对时表现为随机水平。直接访问注意力在保留Softmax注意力准确率的同时,将注意力路由解码成本降低了三个数量级。

英文摘要:

Direct access attention replaces context search with a learned integer lookup. Each token is projected to a $d_k$-dimensional code whose signs select one of $2^{d_k}$ memory cells. Its value is written to that cell; a query with matching signs retrieves it in $O(d_k+d_v)$ operations per head, independent of context length $T$. Softmax attention compares each query with every context key, costing $O(T(d_k+d_v))$ operations per head and separating $2^{O(d_k)}$ pairs. Linear attention superposes pairs in a fixed-width matrix, costing $O(d_k d_v)$ operations, independent of $T$, but separating only $O(d_k)$ pairs per head. Direct access replaces the product of key and value widths with their sum and provides $2^{d_k}$ cells, at the cost of storing $2^{d_k} d_v$ values per head. An efficient differentiable training algorithm factorises address learning into $d_k$ independent bit probabilities. This lets gradients adjust addresses; at inference, each bit becomes a definite binary choice, enabling integer lookup. Training and inference agree when these probabilities approach zero or one. Because cross-entropy alone does not reliably produce such certainty, we add an address-entropy penalty after the model has learned to match queries to the correct keys. On in-context associative recall, one-layer models with matched parameter counts achieve perfect accuracy at every tested task size, from 8 to 512 stored pairs, using either direct access or softmax attention. At 512 pairs, linear attention achieves 0.340 accuracy; a selective state-space model with the same state size performs at chance beyond 32 pairs. Direct access preserves softmax's accuracy while reducing attention-route decoding cost by three orders of magnitude.

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

↑