Learning to Compress Prompt in Natural Language Formats

📄 arXiv: 2402.18700v2 📥 PDF

作者: Yu-Neng Chuang, Tianwei Xing, Chia-Yuan Chang, Zirui Liu, Xun Chen, Xia Hu

分类: cs.CL, cs.AI, cs.LG

发布日期: 2024-02-28 (更新: 2024-04-02)


💡 一句话要点

提出Nano-Capsulator以解决长提示压缩与迁移性问题

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 长提示压缩 自然语言处理 迁移学习 奖励函数 语义保持 大型语言模型 Capsule Prompt

📋 核心要点

  1. 现有方法在长提示压缩上存在迁移性不足的问题,尤其是在API基础的LLMs中表现不佳。
  2. 本文提出Nano-Capsulator框架,通过自然语言格式压缩长提示,保持其有效性和迁移性。
  3. 实验结果显示,Capsule Prompt在长度、推理延迟和预算开销上均有显著提升,分别减少81.4%、降低4.5倍和节省80.1%。

📝 摘要(中文)

大型语言模型(LLMs)在处理多种自然语言处理任务时表现出色,但在长上下文处理、推理速度和计算成本方面存在限制。现有方法依赖于将长提示压缩为软提示,但这种方法在不同LLMs之间的迁移性有限。为此,本文提出了一种自然语言提示封装框架(Nano-Capsulator),旨在以自然语言形式压缩长提示,同时保持提示的有效性和迁移性。通过优化奖励函数和语义保持损失,Nano-Capsulator能够有效解决提示压缩中的挑战。实验结果表明,Capsule Prompt能够将原始长度减少81.4%,推理延迟降低至4.5倍,同时节省80.1%的预算开销,并在不同LLMs和数据集之间提供良好的迁移性。

🔬 方法详解

问题定义:本文旨在解决长提示压缩的迁移性问题,现有的软提示压缩方法在不同LLMs之间的适用性较差,且无法有效处理自然语言提示的反向传播和长度限制问题。

核心思路:Nano-Capsulator框架通过将长提示压缩为自然语言格式的Capsule Prompt,利用奖励函数和语义保持损失来优化提示的有效性和迁移性。

技术框架:该框架主要包括两个模块:一是优化奖励函数以处理反向传播问题,二是设计长度约束的奖励函数以解决长度灵活性不足的问题。

关键创新:Nano-Capsulator的最大创新在于其能够在保持提示有效性的同时,实现跨不同LLMs的迁移性,这一特性在现有方法中并未得到有效解决。

关键设计:在设计中,采用了特定的损失函数以保持语义一致性,并通过长度约束的奖励函数来优化提示的压缩效果。

📊 实验亮点

实验结果表明,Capsule Prompt能够将原始提示长度减少81.4%,推理延迟降低至4.5倍,同时节省80.1%的预算开销。这些结果显著优于现有的提示压缩方法,展示了Nano-Capsulator在不同LLMs和数据集上的良好迁移性。

🎯 应用场景

该研究的潜在应用领域包括大规模数据集的处理、自然语言生成任务以及多种NLP应用场景。通过提高长提示的处理效率,Nano-Capsulator能够帮助用户更有效地利用大型语言模型,降低计算成本,提升处理速度,具有重要的实际价值和未来影响。

📄 摘要(原文)

Large language models (LLMs) are great at processing multiple natural language processing tasks, but their abilities are constrained by inferior performance with long context, slow inference speed, and the high cost of computing the results. Deploying LLMs with precise and informative context helps users process large-scale datasets more effectively and cost-efficiently. Existing works rely on compressing long prompt contexts into soft prompts. However, soft prompt compression encounters limitations in transferability across different LLMs, especially API-based LLMs. To this end, this work aims to compress lengthy prompts in the form of natural language with LLM transferability. This poses two challenges: (i) Natural Language (NL) prompts are incompatible with back-propagation, and (ii) NL prompts lack flexibility in imposing length constraints. In this work, we propose a Natural Language Prompt Encapsulation (Nano-Capsulator) framework compressing original prompts into NL formatted Capsule Prompt while maintaining the prompt utility and transferability. Specifically, to tackle the first challenge, the Nano-Capsulator is optimized by a reward function that interacts with the proposed semantics preserving loss. To address the second question, the Nano-Capsulator is optimized by a reward function featuring length constraints. Experimental results demonstrate that the Capsule Prompt can reduce 81.4% of the original length, decrease inference latency up to 4.5x, and save 80.1% of budget overheads while providing transferability across diverse LLMs and different datasets.