用语法树结构压缩提示词,兼顾长度与内容质量。
Parse Trees Guided LLM Prompt Compression
- 基于语法规则构建句子解析树,计算节点信息熵。
- 通过全局树结构传播调整节点值,实现高效压缩。
- 在长提示和多模型上表现优异,保持内容连贯性。
为大型语言模型(LLMs)提供丰富上下文可提升任务性能,但过长的提示会增加计算开销并超出输入限制。现有压缩方法或生成式易产生幻觉,或选择式忽略语言规则与全局结构。为此,本文提出新选择式压缩方法PartPrompt:首先依据语法规则为每句构建解析树,并计算各节点局部信息熵;再根据句子、段落、章节等层级关系整合为全局树;随后设计根向叶与叶向根传播机制调整节点值;最后基于调整后的值递归剪枝全局树。实验表明,PartPrompt在多个数据集、指标、压缩率及目标LLM上均达到领先性能。消融实验验证了设计有效性,额外实验还证明其在长提示场景下保持压缩后提示的连贯性优势。
原文摘要 · Abstract (English)
Offering rich contexts to Large Language Models (LLMs) has shown to boost the performance in various tasks, but the resulting longer prompt would increase the computational cost and might exceed the input limit of LLMs. Recently, some prompt compression methods have been suggested to shorten the length of prompts by using language models to generate shorter prompts or by developing computational models to select important parts of original prompt. The generative compression methods would suffer from issues like hallucination, while the selective compression methods have not involved linguistic rules and overlook the global structure of prompt. To this end, we propose a novel selective compression method called PartPrompt. It first obtains a parse tree for each sentence based on linguistic rules, and calculates local information entropy for each node in a parse tree. These local parse trees are then organized into a global tree according to the hierarchical structure such as the dependency of sentences, paragraphs, and sections. After that, the root-ward propagation and leaf-ward propagation are proposed to adjust node values over the global tree. Finally, a recursive algorithm is developed to prune the global tree based on the adjusted node values. The experiments show that PartPrompt receives the state-of-the-art performance across various datasets, metrics, compression ratios, and target LLMs for inference. The in-depth ablation studies confirm the effectiveness of designs in PartPrompt, and other additional experiments also demonstrate its superiority in terms of the coherence of compressed prompts and in the extreme long prompt scenario.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。