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

选择性注意力:通过有原则的上下文控制增强Transformer

Selective Attention: Enhancing Transformer through Principled Context Control

University of Michigan(密歇根大学);University of California, Riverside(加州大学河滨分校)

Xuechen Zhang, Xiangyu Chang, Mingchen Li, Amit Roy-Chowdhury, Jiasi Chen, Samet Oymak

AI总结:

本文提出选择性自注意力(SSA)层,通过有原则的温度缩放策略控制注意力稀疏性,缓解注意力稀释并抑制噪声令牌,仅增加不到0.5%参数即可在语言建模基准上取得一致提升。

摘要:

Transformer架构中的注意力机制使模型能够根据令牌与查询的相关性对其进行加权和组合。虽然自注意力已取得巨大成功,但它显著地以相同方式处理所有查询$q$,即应用映射$V^\ op\ ext{softmax}(Kq)$,其中$V,K$分别是值嵌入和键嵌入。在这项工作中,我们认为这种统一处理阻碍了控制上下文稀疏性和相关性的能力。作为解决方案,我们引入了选择性自注意力(Selective Self-Attention,SSA)层,该层通过一种有原则的温度缩放策略增强softmax非线性。通过控制温度,SSA使注意力图的上下文稀疏性适应查询嵌入及其在上下文窗口中的位置。通过理论和实验,我们证明这缓解了注意力稀释,有助于优化过程,并增强了模型控制单个查询的softmax尖峰程度的能力。我们还将温度缩放纳入值嵌入,并表明它提升了模型抑制不相关/噪声令牌的能力。值得注意的是,SSA是一种轻量级方法,通过权重共享策略引入不到0.5%的新参数,并且可以在现有LLM上进行微调。大量实证评估表明,配备SSA的模型在语言建模基准上取得了显著且一致的准确率提升。

英文摘要:

The attention mechanism within the transformer architecture enables the model to weigh and combine tokens based on their relevance to the query. While self-attention has enjoyed major success, it notably treats all queries $q$ in the same way by applying the mapping $V^\top\text{softmax}(Kq)$, where $V,K$ are the value and key embeddings respectively. In this work, we argue that this uniform treatment hinders the ability to control contextual sparsity and relevance. As a solution, we introduce the $\textit{Selective Self-Attention}$ (SSA) layer that augments the softmax nonlinearity with a principled temperature scaling strategy. By controlling temperature, SSA adapts the contextual sparsity of the attention map to the query embedding and its position in the context window. Through theory and experiments, we demonstrate that this alleviates attention dilution, aids the optimization process, and enhances the model's ability to control softmax spikiness of individual queries. We also incorporate temperature scaling for value embeddings and show that it boosts the model's ability to suppress irrelevant/noisy tokens. Notably, SSA is a lightweight method which introduces less than 0.5% new parameters through a weight-sharing strategy and can be fine-tuned on existing LLMs. Extensive empirical evaluations demonstrate that SSA-equipped models achieve a noticeable and consistent accuracy improvement on language modeling benchmarks.

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

↑