LaCache通过分层阶梯缓存与动态压缩,提升大模型长文本生成效率。
LaCache: Ladder-Shaped KV Caching for Efficient Long-Context Modeling of Large Language Models
- 采用阶梯式缓存结构,跨层存储键值对以扩展长距离依赖捕捉能力。
- 通过基于距离的迭代压缩机制,在固定缓存下持续生成新内容不溢出。
- 无需训练即可部署,适用于各类大模型的长上下文生成任务。
大语言模型(LLMs)在需要强长程建模能力的应用中日益重要,但序列长度增加导致键值(KV)对数量激增,成为性能瓶颈。本文提出一种无需训练的新型缓存优化方法LaCache,有效提升生成推理效率。该方法包含两项核心创新:(1) 阶梯状缓存模式,将KV对不仅按层内顺序存储,还跨层从浅到深分布,可在固定存储预算下扩展长程依赖捕捉范围;(2) 迭代压缩机制,根据令牌距离动态压缩旧缓存,释放空间用于新输入,支持受限缓存下的持续生成。在多个任务、基准和模型上的实验表明,LaCache能一致提升长程建模能力。代码已开源:https://github.com/GATECH-EIC/LaCache。
原文摘要 · Abstract (English)
Recent advancements in Large Language Models (LLMs) have spurred interest in numerous applications requiring robust long-range capabilities, essential for processing extensive input contexts and continuously generating extended outputs. As sequence lengths increase, the number of Key-Value (KV) pairs in LLMs escalates, creating a significant efficiency bottleneck. In this paper, we propose a new KV cache optimization paradigm called LaCache, a training-free method for efficient and accurate generative inference of LLMs. LaCache enables LLMs to simultaneously address both of the critical challenges in long-range modeling: robust long-range capabilities and continuous generation without running out-of-memory (OOM). Specifically, LaCache integrates two key innovations: (1) a ladder-shaped KV cache pattern that stores KV pairs not only sequentially (left-to-right within each layer) but also across layers (from shallow to deep), providing an extended span for capturing long-range dependencies under a fixed storage budget, thereby boosting long-range capabilities; and (2) an iterative compaction mechanism that progressively compresses older caches, freeing up space for new tokens within a fixed cache size. This token distance-based dynamic compression enables more effective continuous generation under constrained cache budgets. Experiments across various tasks, benchmarks, and LLM models consistently validate LaCache's effectiveness in enhancing LLMs' long-range capabilities. Our code is available at https://github.com/GATECH-EIC/LaCache.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。