不靠自编码训练,用锚点直接压缩长文本,提升大模型推理速度。
Autoencoding-Free Context Compression for LLMs via Contextual Semantic Anchors
- 用可学习的锚点标记原始文本,直接聚合上下文信息
- 在问答和摘要任务中,不同压缩比下均优于现有方法
- 适合需要高效处理长文本的部署场景
上下文压缩通过将长输入转换为紧凑表示来加速大语言模型(LLM)推理。现有方法主要依赖自编码任务训练特殊压缩标记以表征语义,但此类任务可能与下游任务需求冲突,阻碍模型学习对实际应用更有益的特征。基于此,我们提出语义锚点压缩(SAC),将压缩能力从自编码任务转移到架构本身。SAC不通过自编码训练模型压缩上下文,而是直接从原始上下文中选择锚点标记,并将其键值(KV)表示用于聚合上下文信息。为确保锚点有效收集信息,SAC引入两项关键设计:(1) 锚点嵌入,即附加于选定锚点的可学习嵌入向量,用于标识压缩载体;(2) 双向注意力修改,使锚点能整合整个上下文信息。实验表明,SAC在不同压缩比率和模型规模下,于问答和长文本摘要任务中持续优于现有压缩方法。数据、模型与代码已开源至 https://github.com/lx-Meteors/SAC。
原文摘要 · Abstract (English)
Context compression is an advanced technique that accelerates large language model (LLM) inference by converting long inputs into compact representations. Existing methods primarily rely on autoencoding tasks to train special compression tokens to represent contextual semantics. While autoencoding tasks enable compression tokens to acquire compression capabilities, we remark that such capabilities potentially conflict with actual downstream task requirements, prevent the models from learning the features more beneficial for real-world usage. Based on this observation, we propose Semantic-Anchor Compression (SAC), a novel method that shifts from autoencoding task based compression to an architecture that is equipped with this compression capability \textit{a priori}. Instead of training models to compress contexts through autoencoding tasks, SAC directly selects so-called anchor tokens from the original context and aggregates contextual information into their key-value (KV) representations. To ensure that anchors can effectively collect information, SAC introduces two key designs: (1) anchor embedding, a learnable embedding vector attached to the selected anchor tokens to mark compression carriers and (2) bidirectional attention modification, which enables anchor tokens to integrate information from the entire context. Experimental results show that SAC consistently outperforms existing context compression methods across different compression ratios and model sizes on question-answering and long-context summarization tasks. Our data, model and code have been released at \href{https://github.com/lx-Meteors/SAC}{https://github.com/lx-Meteors/SAC}.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。