Compressing Long Context into Answer-Aligned Memory Embeddings for LLM Inference
作者: Md Mostafizer Rahman, Md Faizul Ibne Amin, Md Shahajada Mia, Yutaka Watanobe, Fang Liu
分类: cs.CL, cs.AI
发布日期: 2026-09-22
💡 一句话要点
提出上下文到答案对齐的内存压缩框架以优化LLM推理
🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture) 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 长上下文压缩 内存嵌入 大规模语言模型 推理优化 答案目标蒸馏
📋 核心要点
- 现有方法在长上下文推理中面临自注意力和KV缓存的扩展问题,导致性能瓶颈。
- 本文提出的CMC框架通过压缩长输入上下文为对齐的内存嵌入,优化了推理过程。
- 实验结果显示,CMC在多个基准上显著提升性能,并有效降低了推理时间和能耗。
📝 摘要(中文)
大规模语言模型(LLM)推理受到自注意力的平方扩展和KV缓存的线性扩展的限制,导致延迟、能耗和GPU内存需求增加。现有的软压缩方法在推理时缺乏查询引导的内存选择,或未经过答案目标监督训练,或与特定解码器架构紧密耦合。本文提出了一种上下文到答案对齐的内存压缩(CMC)框架,将长输入上下文压缩为与任何冻结解码器的嵌入空间对齐的紧凑上下文内存嵌入(CME),在不修改解码器权重的情况下降低推理成本。CMC引入了一个两级KV缓存,结合了基于问题的CME选择和局部上下文窗口,并通过从冻结的LLM进行答案目标蒸馏来训练压缩器。实验表明,CMC在九种编码器-解码器组合和四个QA基准上均优于基线,在SQuAD上实现了最高7.3的EM和4.0的F1点提升,同时将推理时间和能耗降低了最高20%,峰值保留的GPU内存降低了最高50%。
🔬 方法详解
问题定义:本文旨在解决大规模语言模型推理中长上下文处理的效率问题,现有方法在自注意力和KV缓存扩展时存在显著的延迟和资源消耗。
核心思路:提出的CMC框架通过将长输入上下文压缩为与解码器嵌入空间对齐的上下文内存嵌入,来减少推理成本,而无需修改解码器的权重。
技术框架:CMC框架包括两个主要模块:问题引导的上下文内存嵌入选择和局部上下文窗口,结合使用以提高推理效率。训练过程中采用答案目标蒸馏,从冻结的LLM中获取知识。
关键创新:CMC的核心创新在于引入了两级KV缓存机制,能够有效地选择与问题相关的上下文内存嵌入,从而优化了信息的利用效率。
关键设计:在设计中,压缩器的训练采用了答案目标的蒸馏方法,确保了生成的内存嵌入与解码器的输出保持一致性,同时在参数设置上进行了优化,以适应不同的编码器-解码器组合。
🖼️ 关键图片
📊 实验亮点
实验结果表明,CMC在九种编码器-解码器组合和四个QA基准上均优于基线,在SQuAD上实现了最高7.3的EM和4.0的F1点提升。同时,推理时间和能耗降低了最高20%,峰值保留的GPU内存降低了最高50%。
🎯 应用场景
该研究的潜在应用领域包括自然语言处理中的问答系统、对话生成和信息检索等。通过优化LLM的推理效率,能够在实际应用中显著降低延迟和资源消耗,提高用户体验。未来,该方法有望推广到更多需要处理长上下文的任务中,推动智能系统的进一步发展。
📄 摘要(原文)
Large language model (LLM) inference is constrained by the quadratic scaling of self-attention and the linear scaling of the KV cache, increasing latency, energy consumption, and GPU memory demand as context length scales. Existing soft-compression methods either lack query-guided memory selection at inference time, train without answer-targeted supervision, or couple compression tightly to a specific decoder architecture. We propose a Context-to-Answer-Aligned Memory Compression (CMC) framework, which compresses long input contexts into compact Context Memory Embeddings (CMEs) aligned to any frozen decoder's embedding space, reducing inference costs without modifying decoder weights. CMC introduces a two-tier KV cache that combines question-guided CME selection with a local context window, and trains the compressor with answer-targeted distillation from a frozen LLM. Experiments across nine encoder-decoder combinations and four QA benchmarks show that CMC consistently outperforms the baseline, achieving up to 7.3 EM and 4.0 F1 point gains on SQuAD, while reducing inference time and energy consumption by up to 20% and peak reserved GPU memory by up to 50% at 3,000 generation tokens. Ablation studies confirm that each architectural component and training objective contributes to the performance.