揭示并利用隐藏的注意力汇聚点:通过注意力校准在无需训练的情况下增强大语言模型
Unveiling and Harnessing Hidden Attention Sinks: Enhancing Large Language Models without Training through Attention Calibration
AI总结:
该研究发现大语言模型中存在序列后续位置的隐藏注意力汇聚点且部分汇聚点对准确率无正向影响,提出无需训练的输入自适应注意力校准技术ACT,可显著提升多类大模型的任务准确率。
摘要:
注意力是大语言模型(LLM)取得卓越成就背后的核心组件。然而,目前我们对注意力机制的理解,尤其是关于注意力分布如何形成的认知仍然有限。受近期探索初始token中存在注意力汇聚点(attention sink)的研究启发——这类初始token虽无语义重要性,却获得了不成比例的高注意力分数,本工作对这一现象展开了更深入的探究。我们旨在更深刻地理解LLM中注意力汇聚点的存在,并挖掘无需权重微调、通过直接优化注意力分布即可提升LLM可达到的准确率的方法。具体而言,本工作首先针对推理过程中不同输入和任务下LLM的注意力分布进行了全面可视化。基于这些可视化结果,据我们所知,我们首次发现:(1)注意力汇聚点不仅出现在序列起始位置,也存在于输入的后续token中;(2)并非所有注意力汇聚点都对LLM的可达到准确率有正向影响。基于上述发现,我们提出了一种无需训练的注意力校准技术(Attention Calibration Technique, ACT),该技术能够在推理过程中以输入自适应的方式实时自动优化注意力分布。大量实验验证表明,ACT在不同应用场景下均能持续提升各类LLM的准确率。具体来说,将ACT应用于Llama-30B时,在不同数据集上的准确率平均提升幅度最高可达7.30%。我们的代码可在https://github.com/GATECH-EIC/ACT 获取。
英文摘要:
Attention is a fundamental component behind the remarkable achievements of large language models (LLMs). However, our current understanding of the attention mechanism, especially regarding how attention distributions are established, remains limited. Inspired by recent studies that explore the presence of attention sink in the initial token, which receives disproportionately large attention scores despite their lack of semantic importance, this work delves deeper into this phenomenon. We aim to provide a more profound understanding of the existence of attention sinks within LLMs and to uncover ways to enhance the achievable accuracy of LLMs by directly optimizing the attention distributions, without the need for weight finetuning. Specifically, this work begins with comprehensive visualizations of the attention distributions in LLMs during inference across various inputs and tasks. Based on these visualizations, to the best of our knowledge, we are the first to discover that (1) attention sinks occur not only at the start of sequences but also within later tokens of the input, and (2) not all attention sinks have a positive impact on the achievable accuracy of LLMs. Building upon our findings, we propose a training-free Attention Calibration Technique (ACT) that automatically optimizes the attention distributions on the fly during inference in an input-adaptive manner. Extensive experiments validate that ACT consistently enhances the accuracy of various LLMs across different applications. Specifically, ACT achieves an average improvement of up to 7.30% in accuracy across different datasets when applied to Llama-30B. Our code is available at https://github.com/GATECH-EIC/ACT.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。