arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2409.01227cs.CLcs.LG
收藏

面向快速且改进的LLM推理的基于上下文感知句子编码的提示压缩

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

Alterra AI(Alterra人工智能公司);Queen’s University(女王大学);Workday Inc.(Workday公司)

Barys Liskavets, Maxim Ushakov, Shuvendu Roy, Mark Klibanov, Ali Etemad, Shane Luke

AI总结:

提出上下文感知提示压缩方法CPC,通过对比学习训练句子编码器进行句子级提示压缩,在基准数据集上显著优于现有方法且推理速度最高提升10.93倍。

摘要:

大型语言模型(LLMs)引发了一股新的研究热潮,专注于压缩上下文长度以降低计算成本,同时确保保留有助于LLMs回答给定问题的信息。基于token的移除方法是该方向最突出的方法之一,但面临丢失由中间token移除导致的上下文语义的风险,特别是在高压缩率下,同时在计算效率上也面临挑战。在本工作中,我们提出了上下文感知提示压缩(CPC),这是一种句子级别的提示压缩技术,其关键创新是一种新颖的上下文感知句子编码器,能够为给定问题的每个句子提供相关性得分。为了训练该编码器,我们生成了一个由问题、正样本和负样本对组成的新数据集,其中正样本是与问题相关的句子,而负样本是不相关的上下文句子。我们在对比学习设置中训练该编码器,以学习上下文感知的句子表示。我们的方法在基准数据集上的提示压缩任务上显著优于先前的工作,并且与最佳的token级压缩方法相比,推理速度最高提升了10.93倍。我们还发现在大多数基准测试中,对于较短长度的约束有更好的提升,这表明我们提出的解决方案在较短上下文中压缩相关信息方面的有效性。最后,我们发布了代码和数据集以便快速复现和进一步开发:https://github.com/Workday/cpc。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑