通过分段压缩提升长文本问答效率,显著加速推理并减少内存占用。
CompLLM: Compression for Long Context Q&A
- 将长文本分段独立压缩,实现线性计算复杂度
- 2倍压缩率下,长文本推理速度最高快4倍,缓存减半
- 支持跨查询复用压缩结果,适合大规模长文本场景
大语言模型处理长上下文时面临自注意力机制的二次计算复杂度挑战。现有软压缩方法通常整体压缩上下文,导致压缩复杂度为二次方,并无法在具有重叠上下文的查询间复用计算。本文提出CompLLM,将上下文分段后独立压缩,实现三个关键优势:效率上压缩复杂度随上下文长度线性增长;可扩展性使仅在1k令牌训练的模型可泛化至100k令牌上下文;可复用性允许压缩段缓存并跨查询重复使用。实验表明,在2倍压缩率下,长上下文场景中时间到首个词(TTFT)最高提速4倍,键值缓存大小降低50%。同时,性能与未压缩上下文相当,甚至在极长序列上表现更优,验证了其有效性和实用性。
原文摘要 · Abstract (English)
Large Language Models (LLMs) face significant computational challenges when processing long contexts due to the quadratic complexity of self-attention. While soft context compression methods, which map input text to smaller latent representations, have shown promise, their real-world adoption is limited. Existing techniques typically compress the context as a single unit, which leads to quadratic compression complexity and an inability to reuse computations across queries with overlapping contexts. In this work, we introduce CompLLM, a soft compression technique designed for practical deployment. Instead of processing the context holistically, CompLLM divides it into segments and compresses each one independently. This simple design choice yields three critical properties: efficiency, as the compression step scales linearly with the context length; scalability, enabling models trained on short sequences (e.g., 1k tokens) to generalize to contexts of 100k tokens; and reusability, allowing compressed segments to be cached and reused across different queries. Our experiments show that with a 2x compression rate, at high context lengths CompLLM speeds up Time To First Token (TTFT) by up to 4x and reduces the KV cache size by 50%. Furthermore, CompLLM achieves performance comparable to that obtained with the uncompressed context, and even surpasses it on very long sequences, demonstrating its effectiveness and practical utility.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。