动态压缩提示词,让大模型推理更快更省资源
Dynamic Compressing Prompts for Efficient Inference of Large Language Models
- 将提示压缩建模为马尔可夫决策过程,逐步删冗余词
- 在高压缩率下仍保持性能,比现有方法提升显著
- 无需外部模型,适合部署在资源受限场景
大语言模型在多种任务中表现优异,部分归功于先进的提示技术。然而,这些技术常需长提示,增加计算开销,并因上下文窗口有限而影响性能。虽然提示压缩是直接解决方案,但现有方法面临保留关键信息、适应上下文变化及跨任务有效性等挑战。为此,我们提出一种无任务依赖的方法——动态压缩提示(LLM-DCP)。该方法通过建模为马尔可夫决策过程,使压缩代理(DCP-Agent)能根据上下文动态逐次删除冗余词,同时保留核心内容。设计奖励函数平衡压缩率、输出质量与关键信息保留,实现不依赖外部黑盒模型的压缩。受课程学习渐进难度启发,引入分层提示压缩训练策略,逐步提高压缩难度,使代理学会保持信息完整性的有效压缩方法。实验表明,本方法在高压缩率下优于现有最优技术,代码已开源。
原文摘要 · Abstract (English)
Large Language Models (LLMs) have shown outstanding performance across a variety of tasks, partly due to advanced prompting techniques. However, these techniques often require lengthy prompts, which increase computational costs and can hinder performance because of the limited context windows of LLMs. While prompt compression is a straightforward solution, existing methods confront the challenges of retaining essential information, adapting to context changes, and remaining effective across different tasks. To tackle these issues, we propose a task-agnostic method called Dynamic Compressing Prompts (LLM-DCP). Our method reduces the number of prompt tokens while aiming to preserve the performance as much as possible. We model prompt compression as a Markov Decision Process (MDP), enabling the DCP-Agent to sequentially remove redundant tokens by adapting to dynamic contexts and retaining crucial content. We develop a reward function for training the DCP-Agent that balances the compression rate, the quality of the LLM output, and the retention of key information. This allows for prompt token reduction without needing an external black-box LLM. Inspired by the progressive difficulty adjustment in curriculum learning, we introduce a Hierarchical Prompt Compression (HPC) training strategy that gradually increases the compression difficulty, enabling the DCP-Agent to learn an effective compression method that maintains information integrity. Experiments demonstrate that our method outperforms state-of-the-art techniques, especially at higher compression rates. The code for our approach will be available at https://github.com/Fhujinwu/DCP.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。