arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2605.09778cs.LGcs.CL
收藏

Nectar: 通过回归估计缓存令牌注意力

Nectar: Neural Estimation of Cached-Token Attention via Regression

Apple(苹果公司)

João Monteiro, Michal Klein, Pierre Ablin, Marco Cuturi

AI总结:

Nectar通过回归方法估计缓存令牌注意力,减少长上下文中的计算成本,实验显示其精度接近完整注意力。

摘要:

评估固定长上下文中的softmax注意力需要为每个新查询令牌读取所有缓存的键值对。我们提出Nectar,为任务相关分布中的查询拟合紧凑的神经网络。Nectar为每个层和KV头拟合两个网络:目标网络预测注意力输出,评分网络预测log-normalizer。这对网络在推理时插入标准的掩码自注意力中,将O(n)的缓存注意力替换为成本不依赖于n的前向传递。每个模块携带每个层和KV头的|θ|参数,通常远小于相同粒度下的2nd KV缓存足迹。我们在五个长上下文数据集上测试了从1.7B到8B参数的模型。近似误差跟踪下一个令牌准确性与完整注意力的差距,非均匀分配容量可减少该差距。除了对指标的分析外,我们检查了配备Nectar模块的模型在文本生成(跟随问题提示)时,其语义内容与完全访问缓存的模型相同。

英文摘要:

Evaluating softmax attention over a fixed long context requires reading every cached key-value pair for each new query token. For a given context (a book, a manual, a legal corpus) the attention output is a deterministic function of the query. We propose Nectar, which fits a compact neural network to this function for queries drawn from a task-relevant distribution. Nectar fits two networks per layer and KV-head: a target network that predicts the attention output and a score network that predicts the log-normalizer. The pair plugs into the standard masked self-attention at inference time, replacing the $O(n)$ attention over the cache with a forward pass whose cost does not depend on $n$. Each module carries on the order of $|θ|$ parameters per layer and KV-head, typically much smaller than the $2nd$ KV-cache footprint at the same granularity. We report experiments on models from 1.7B to 8B parameters across five long-context datasets. The approximation error tracks the next-token accuracy gap to full attention, and allocating capacity non-uniformly across layers reduces that gap in our ablation. Beyond this analysis of metrics, we check that the text generations (following a question prompt) of a model equipped with a Nectar module match in semantic content those obtained by giving the same model access to the full cache.

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

↑