让大模型长文本处理更高效,压缩缓存几乎不损失性能。
KV-Distill: Nearly Lossless Learnable Context Compression for LLMs
- 通过知识蒸馏将长上下文缓存压缩成短表示,无需依赖问题
- 在问答和摘要任务中接近原始性能,最长可压缩99%
- 适配预训练模型,支持多种模型大小和架构
序列生成任务通常需要长上下文,但标准Transformer的自注意力具有二次复杂度,难以实现。生成过程中,存储于所谓KV缓存中的临时表示占用了大量GPU内存,且随上下文长度线性增长。我们提出KV-Distill,一种可学习的上下文压缩框架,能以与问题无关的方式将长上下文的KV缓存压缩为显著更短的表示。该方法可作为参数高效的适配器训练,实现任意上下文片段的压缩并保持预训练模型能力。我们将压缩后-未压缩的缓存视为学生-教师对,使用类KL散度匹配生成结果。在最坏情况的抽取式任务中,其表现优于其他压缩技术;在长上下文问答和摘要任务中接近无压缩性能。可在特定领域微调,使上下文长度减少高达99%的同时保持下游性能。我们在多种模型规模和架构上验证了其通用性。
原文摘要 · Abstract (English)
Sequence-to-sequence tasks often benefit from long contexts, but the quadratic complexity of self-attention in standard Transformers renders this non-trivial. During generation, temporary representations -stored in the so-called KV cache-account for a large portion of GPU memory usage and scale linearly with context length. We introduce KV-Distill, a Transformer compression framework that distills long context KV caches into significantly shorter representations in a question-independent fashion. KV-Distill can be trained as a parameter-efficient adaptor for pretrained models, and enables the compression of arbitrary spans of a context while preserving pre-trained model capabilities. We treat a compressed-uncompressed cache as a student-teacher pairing and apply a KL-type divergence to match the generated outputs. KV-Distill outperforms other compression techniques in worst-case extractive tasks and approaches uncompressed performance in long context question answering and summarization, and it can be fine-tuned on domain-specific contexts to reduce lengths by up to 99% while preserving downstream performance. We demonstrate the generalizability of KV-Distill across various model sizes and architectures.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。