PromptIntern: Saving Inference Costs by Internalizing Recurrent Prompt during Large Language Model Fine-tuning

📄 arXiv: 2407.02211v2 📥 PDF

作者: Jiaru Zou, Mengyu Zhou, Tao Li, Shi Han, Dongmei Zhang

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

发布日期: 2024-07-02 (更新: 2024-10-15)

备注: This paper has been accepted by EMNLP 2024


💡 一句话要点

PromptIntern:通过内化循环Prompt来节省大语言模型微调的推理成本

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

关键词: 大语言模型 微调 Prompt工程 推理加速 成本优化

📋 核心要点

  1. 大语言模型微调在特定领域任务中取得了显著进展,但依赖重复冗长的prompt,导致计算成本高昂。
  2. PromptIntern通过将循环prompt知识内化到模型参数中,减少对复杂prompt的依赖,从而降低推理成本。
  3. 实验表明,PromptIntern在NL2Code任务中显著减少了输入token,加速了推理,并降低了货币成本。

📝 摘要(中文)

本文提出了一种名为PromptIntern的新方法,旨在通过在模型微调过程中内化prompt知识,从而实现高效推理并节省成本。与压缩vanilla模型的prompt不同,PromptIntern致力于将循环prompt直接嵌入到模型参数中。我们设计了一个微调流程,包括指令模板压缩、少量样本吸收和渐进式内化策略,从而有效地减少了推理过程中对复杂prompt的需求。在具有挑战性的NL2Code任务上的综合实验表明,我们的方法减少了90%以上的输入token,加速了4.2倍的推理速度,并降低了88.3%的货币推理成本。

🔬 方法详解

问题定义:现有的大语言模型微调方法依赖于重复且冗长的prompt,这导致了高昂的计算成本、更多的资源需求和更慢的推理速度。尤其是在需要多次迭代或复杂推理的任务中,prompt的长度和复杂性会进一步加剧这些问题。因此,如何减少对复杂prompt的依赖,降低推理成本,是当前大语言模型微调面临的一个重要挑战。

核心思路:PromptIntern的核心思路是将prompt的知识直接嵌入到模型参数中,而不是像传统方法那样依赖于在推理时提供prompt。通过将prompt信息“内化”到模型中,可以减少或消除对外部prompt的依赖,从而降低推理所需的计算量和时间。这种方法类似于将知识从外部“记忆”转移到模型自身的“能力”中。

技术框架:PromptIntern的微调流程主要包含三个阶段:1) 指令模板压缩:对原始的指令模板进行压缩,减少冗余信息。2) 少量样本吸收:利用少量样本进行微调,使模型初步学习prompt的知识。3) 渐进式内化策略:逐步将prompt的知识内化到模型参数中,通过特定的训练目标和优化方法,使模型能够独立完成任务,而无需依赖外部prompt。

关键创新:PromptIntern的关键创新在于将prompt的知识内化到模型参数中。与传统的prompt压缩方法不同,PromptIntern不是简单地减少prompt的长度,而是将prompt的语义信息融入到模型的权重中。这种方法使得模型在推理时能够直接利用prompt的知识,而无需显式地提供prompt。

关键设计:PromptIntern的具体实现细节包括:1) 使用特定的损失函数来鼓励模型学习prompt的知识。2) 设计了一种渐进式的训练策略,逐步增加prompt内化的程度。3) 采用了特定的网络结构或参数初始化方法,以促进prompt知识的有效嵌入。具体的参数设置和超参数选择可能需要根据具体的任务和数据集进行调整。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,PromptIntern在NL2Code任务中表现出色,能够减少超过90%的输入token,加速推理速度达4.2倍,并降低货币推理成本88.3%。这些结果表明,PromptIntern能够有效地将prompt知识内化到模型中,从而显著提高推理效率和降低成本。与传统的微调方法相比,PromptIntern具有明显的优势。

🎯 应用场景

PromptIntern具有广泛的应用前景,尤其是在资源受限或对推理速度有较高要求的场景中。例如,在移动设备上部署大语言模型、在边缘计算环境中进行实时推理、以及在需要大规模并行推理的应用中,PromptIntern可以显著降低计算成本,提高效率。此外,该方法还可以应用于各种自然语言处理任务,如文本生成、机器翻译、问答系统等。

📄 摘要(原文)

Recent advances in fine-tuning large language models (LLMs) have greatly enhanced their usage in domain-specific tasks. Despite the success, fine-tuning continues to rely on repeated and lengthy prompts, which escalate computational expenses, require more resources, and lead to slower inference. In this paper, we present a novel approach, PromptIntern, which internalizes prompt knowledge during model fine-tuning to achieve efficient inference and save costs. Instead of compressing the prompts for a vanilla model, PromptIntern aims to embed the recurrent prompt directly into the model parameters. We design a fine-tuning pipeline that includes instruction template compression, few-shot example absorption, and a progressive internalization strategy, effectively diminishing the need for intricate prompts during inference. Comprehensive experiments on challenging NL2Code tasks demonstrate that our method reduces input tokens by more than 90%, accelerates inference by 4.2 times, and reduces monetary inference costs by 88.3%.