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

KV-Latent:基于频率感知旋转位置编码的维度级KV Cache缩减

KV-Latent: Dimensional-level KV Cache Reduction with Frequency-aware Rotary Positional Embedding

School of Computer Science, Wuhan University(武汉大学计算机学院);School of Artificial Intelligence, Wuhan University(武汉大学人工智能学院);Xiaomi(小米);School of Computer Science, Shanghai Jiao Tong University(上海交通大学计算机学院)

Luohe Shi, Zuchao Li, Lefei Zhang, Guoming Liu, Baoyuan Qi, Hai Zhao

AI总结:

提出KV-Latent范式,通过下采样KV向量至潜在空间并结合改进的旋转位置编码,以极低额外训练成本显著缩减KV Cache占用并提升推理效率。

摘要:

基于Transformer Decoder的大型语言模型(LLMs)已成为对话式生成AI的首选。尽管Decoder架构整体优越,但推理期间逐渐增加的Key-Value(KV)缓存在内存消耗和数据传输带宽限制方面已成为主要效率瓶颈。为应对这些挑战,我们提出了一种名为KV-Latent的范式。通过将Key-Value向量维度下采样到潜在空间,我们能显著减少KV Cache占用并提升推理速度,仅需少量额外训练,不到预训练的1%。此外,我们通过修改频率采样机制,增强了应用于低维向量的旋转位置编码(Rotary Positional Embedding)的稳定性,避免了高频引入的噪声,同时保留了位置衰减。我们的实验包括带有分组查询注意力(Grouped Query Attention)和不带该机制的模型,均取得了令人满意的结果。最后,我们进行了对比实验,研究分别缩减Key和Value组件对模型性能的影响。我们的方法允许构建更高效的语言模型系统,并为KV Cache节省和高效LLMs开辟了新可能。代码可在https://github.com/ShiLuohe/KV-Latent获取。

英文摘要:

Large language models (LLMs) based on Transformer Decoders have become the preferred choice for conversational generative AI. Despite the overall superiority of the Decoder architecture, the gradually increasing Key-Value (KV) cache during inference has emerged as a primary efficiency bottleneck, both in aspects of memory consumption and data transfer bandwidth limitations. To address these challenges, we propose a paradigm called KV-Latent. By down-sampling the Key-Value vector dimensions into a latent space, we can significantly reduce the KV Cache footprint and improve inference speed, only with a small amount of extra training, less than 1\% of pre-training takes. Besides, we enhanced the stability of Rotary Positional Embedding applied on lower-dimensional vectors by modifying its frequency sampling mechanism, avoiding noise introduced by higher frequencies while retaining position attenuation. Our experiments, including both models with Grouped Query Attention and those without, have yielded satisfactory results. Finally, we conducted comparative experiments to study the impact of separately reducing Key and Value components on model's performance. Our approach allows for the construction of more efficient language model systems, and opens the new possibility on KV Cache saving and efficient LLMs. Our code is available at https://github.com/ShiLuohe/KV-Latent.

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

↑