The Key-Value (KV) cache is central to the efficiency of transformer-based large language models (LLMs), storing previously computed vectors to accelerate inference. Yet, as sequence length and batch size grow, the cache becomes a major memory bottleneck. Prior compression methods typically apply low-rank decomposition to keys alone or attempt to jointly embed queries and keys, but both approaches neglect that attention fundamentally depends on their inner products. In this work, we prove that such strategies are suboptimal for approximating the attention matrix. We introduce KQ-SVD, a simple and computationally efficient method that directly performs an optimal low-rank decomposition of the attention matrix via a closed-form solution. By targeting the true source of redundancy, KQ-SVD preserves attention outputs with higher fidelity under compression. Extensive evaluations on LLaMA and Mistral models demonstrate that our approach consistently delivers superior projection quality.


翻译:键值(KV)缓存是基于Transformer的大型语言模型(LLM)效率的核心,它存储先前计算得到的向量以加速推理。然而,随着序列长度和批处理规模的增加,缓存成为主要的内存瓶颈。现有的压缩方法通常仅对键进行低秩分解,或尝试联合嵌入查询和键,但这两种方法都忽略了注意力机制根本上依赖于它们的内积。在本工作中,我们证明了此类策略在近似注意力矩阵方面是次优的。我们提出了KQ-SVD,这是一种简单且计算高效的方法,它通过闭式解直接对注意力矩阵进行最优低秩分解。通过针对冗余的真实来源,KQ-SVD在压缩下以更高的保真度保留了注意力输出。在LLaMA和Mistral模型上的广泛评估表明,我们的方法始终能提供更优的投影质量。

0
下载
关闭预览

相关内容

奇异值分解(Singular Value Decomposition)是线性代数中一种重要的矩阵分解,奇异值分解则是特征分解在任意矩阵上的推广。在信号处理、统计学等领域有重要应用。
【CVPR2025】基于组合表示移植的图像编辑方法
专知会员服务
8+阅读 · 4月5日
【CVPR2020】用多样性最大化克服单样本NAS中的多模型遗忘
NAACL 2019 | 一种考虑缓和KL消失的简单VAE训练方法
PaperWeekly
20+阅读 · 2019年4月24日
Seq2seq强化,Pointer Network简介
机器学习算法与Python学习
15+阅读 · 2018年12月8日
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
国家自然科学基金
10+阅读 · 2014年12月31日
VIP会员
相关基金
国家自然科学基金
17+阅读 · 2017年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
国家自然科学基金
10+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员