arXiv:2409.01227cs.CLcs.LG2024-09AAAI被引 62

用句子级相关性评分压缩提示,提速超10倍且更保信息。

Prompt Compression with Context-Aware Sentence Encoding for Fast and Improved LLM Inference

  • 基于上下文感知的句向量编码器,为每句打相关性分。
  • 在多个数据集上超越已有方法,推理速度最快提升10.93倍。
  • 适合长文本问答场景,尤其在短约束下表现更优。

大语言模型(LLMs)推动了上下文压缩研究,旨在降低计算成本的同时保留有用信息。现有基于标记的删减方法虽常见,但高压缩率下易丢失语义,且效率不足。本文提出上下文感知提示压缩(CPC),一种句子级压缩技术,核心是新颖的上下文感知句编码器,可为每句生成与问题的相关性得分。我们构建新数据集,包含问题、正样本(相关句)和负样本(无关句),采用对比学习训练编码器以学习上下文感知的句表示。CPC在基准数据集上显著优于现有方法,推理速度比最优标记级方法快最多10.93倍。此外,在多数基准中,短长度约束下提升更明显,证明其有效压缩关键信息的能力。代码与数据集已开源:https://github.com/Workday/cpc。

原文摘要 · Abstract (English)

Large language models (LLMs) have triggered a new stream of research focusing on compressing the context length to reduce the computational cost while ensuring the retention of helpful information for LLMs to answer the given question. Token-based removal methods are one of the most prominent approaches in this direction, but risk losing the semantics of the context caused by intermediate token removal, especially under high compression ratios, while also facing challenges in computational efficiency. In this work, we propose context-aware prompt compression (CPC), a sentence-level prompt compression technique where its key innovation is a novel context-aware sentence encoder that provides a relevance score for each sentence for a given question. To train this encoder, we generate a new dataset consisting of questions, positives, and negative pairs where positives are sentences relevant to the question, while negatives are irrelevant context sentences. We train the encoder in a contrastive setup to learn context-aware sentence representations. Our method considerably outperforms prior works on prompt compression on benchmark datasets and is up to 10.93x faster at inference compared to the best token-level compression method. We also find better improvement for shorter length constraints in most benchmarks, showing the effectiveness of our proposed solution in the compression of relevant information in a shorter context. Finally, we release the code and the dataset for quick reproducibility and further development: https://github.com/Workday/cpc.

提示压缩大模型推理上下文感知高效生成

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。