arXiv:2507.11273cs.CL2025-07ACL被引 8

通过降维压缩键值缓存,显著提升大模型推理效率

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

  • 将键值向量降维至潜空间,大幅减少缓存占用
  • 仅需不到1%预训练时间的微调,性能损失小
  • 改进旋转位置编码频率采样,提升低维向量稳定性

基于Transformer解码器的大语言模型已成为对话生成AI的首选。尽管解码器架构整体表现优异,但推理过程中键值(KV)缓存持续增长,成为内存消耗和数据传输带宽的主要瓶颈。为此,我们提出一种名为KV-Latent的新范式:通过将键值向量降维至潜空间,显著降低KV缓存占用并提升推理速度,仅需少于1%预训练时间的额外微调。同时,通过改进旋转位置编码的频率采样机制,增强了其在低维向量上的稳定性,避免高频噪声引入的同时保留位置衰减特性。实验涵盖使用分组查询注意力与未使用该机制的模型,均取得良好效果。此外,我们分别研究了降低键与值组件对模型性能的影响。本方法有助于构建更高效的语言模型系统,并为KV缓存压缩与高效大模型设计开辟新路径。代码已公开于https://github.com/ShiLuohe/KV-Latent。

原文摘要 · Abstract (English)

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.

大模型推理缓存优化旋转位置编码

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。