用特定注意力头压缩长文本,提速大模型推理
Efficient Prompt Compression with Evaluator Heads for Long-Context Transformer Inference
- 通过识别关键注意力头,筛选输入中重要词元
- 在预填充阶段仅处理前几层,加速推理过程
- 无需训练,适合部署于商业API长文本场景
尽管长上下文输入对大语言模型(LLMs)的应用至关重要,但其带来计算成本上升和性能下降。为此,我们提出一种无需训练的高效提示压缩方法,保留压缩后提示中的关键信息。我们发现变压器架构中某些特定注意力头(称为评估器头)能够识别长输入中最显著的词元。基于此,我们开发了基于评估器头的提示压缩方法(EHPC),使模型在预填充阶段仅利用前几层的评估器头快速“浏览”输入,随后将重要词元传递给模型进行推理。EHPC在两个主流基准上均达到当前最佳表现:提示压缩与长上下文推理加速。该方法有效降低了商业API调用的复杂度和成本。此外,我们证明了EHPC在性能上可媲美基于键值缓存的加速方法,展现出提升长上下文任务效率的巨大潜力。
原文摘要 · Abstract (English)
Although applications involving long-context inputs are crucial for the effective utilization of large language models (LLMs), they also result in increased computational costs and reduced performance. To address this challenge, we propose an efficient, training-free prompt compression method that retains key information within compressed prompts. We identify specific attention heads in transformer-based LLMs, which we designate as evaluator heads, that are capable of selecting tokens in long inputs that are most significant for inference. Building on this discovery, we develop EHPC, an Evaluator Head-based Prompt Compression method, which enables LLMs to rapidly "skim through" input prompts by leveraging only the first few layers with evaluator heads during the pre-filling stage, subsequently passing only the important tokens to the model for inference. EHPC achieves state-of-the-art results across two mainstream benchmarks: prompt compression and long-context inference acceleration. Consequently, it effectively reduces the complexity and costs associated with commercial API calls. We further demonstrate that EHPC attains competitive results compared to key-value cache-based acceleration methods, thereby highlighting its potential to enhance the efficiency of LLMs for long-context tasks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。