arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2407.20485cs.CLcs.LG
收藏

A2SF:面向Transformer解码器中令牌剪枝的带遗忘因子的累积注意力评分

A2SF: Accumulative Attention Scoring with Forgetting Factor for Token Pruning in Transformer Decoder

Sungkyunkwan University(成均馆大学)

Hyun-rae Jo, Dongkun Shin

AI总结:

本文提出带遗忘因子的累积注意力评分方法A2SF,解决Transformer解码器中因掩码导致令牌注意力累积次数不同而比较不公平的问题,从而更有效地进行KV缓存令牌剪枝,并在LLaMA 2上实现最高7.8%的准确率提升。

摘要:

近年来,基于Transformer的大语言模型(LLM)由于KV缓存而面临内存瓶颈问题,尤其是在处理长序列时。先前的研究提出了KV缓存压缩技术,这些技术基于累积注意力评分(Accumulative Attention Scores)识别不重要的令牌,并从KV缓存中移除其项,并指出只有少数令牌在注意力运算中发挥重要作用。然而,我们观察到现有的累积注意力评分并不适用于Transformer解码器结构。在解码器模型中,由于掩码的影响,注意力评分累积的次数会因令牌出现的顺序而异,从而导致令牌之间的比较不公平。为了解决这一问题,我们提出了带遗忘因子的累积注意力评分(A2SF)技术,该技术在注意力评分累积过程中引入了遗忘因子。A2SF通过随时间反复将遗忘因子乘以注意力评分,对由旧令牌产生的过去注意力评分施加惩罚。因此,较旧的令牌会受到更大的惩罚,从而在不同年龄的令牌之间提供公平性。通过在令牌之间进行公平比较,我们可以更有效地选择重要令牌。我们通过在OPT和LLaMA模型中使用A2SF验证了准确率的提升,A2SF在1-shot和0-shot设置下将LLaMA 2的准确率分别提高了最多7.8%和5.1%。

英文摘要:

Recently, large language models (LLM) based on transformers are facing memory bottleneck issues due to KV cache, especially in long sequence handling. Previous researches proposed KV cache compression techniques that identify insignificant tokens based on Accumulative Attention Scores and removes their items from KV cache, noting that only few tokens play an important role in attention operations. However, we have observed that the existing Accumulative Attention Score is not suitable for the transformer decoder structure. In the decoder model, the number of times the Attention Score accumulates varies depending on the order of token appearance due to the effect of masking, causing an uneven comparison between tokens. To solve this, we propose Accumulative Attention Score with Forgetting Factor (A2SF) technique, which introduces a Forgetting Factor in the Attention Score accumulation process. A2SF applies a penalty to the past Attention Score generated from old tokens by repeatedly multiplying the Forgetting Factor to the Attention Score over time. Therefore, older tokens receive a larger penalty, providing fairness among different ages of tokens. Through the fair comparison among tokens, we can more effectively select important tokens. We have verified the accuracy improvement through A2SF in the OPT and LLaMA models and A2SF improves the accuracy of LLaMA 2 by up to 7.8% and 5.1% on 1-shot and 0-shot.

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

↑