用强化学习自动优化提示词,提升大模型表现
GRL-Prompt: Towards Knowledge Graph based Prompt Optimization via Reinforcement Learning
- 基于知识图谱构建结构化提示,用强化学习自动选例
- 在多个指标上超越现有方法,平均提升0.07以上
- 适合需要高效提示工程的NLP应用开发者
大语言模型在自然语言处理任务中表现出色,但其性能高度依赖输入提示。现有提示工程多靠人工试错,效率低且难以找到最优解。为此,我们提出GRL-Prompt框架,一种不依赖特定大模型的端到端提示优化方法,通过强化学习自动构造最优提示。该方法构建知识图谱,更准确地编码用户查询与候选示例之间的关联,并设计策略网络按可奖励顺序选择示例生成提示。同时采用基于嵌入的奖励塑造机制,稳定训练过程。实验表明,GRL-Prompt在多个指标上优于当前最优方法:ROUGE-1平均提升0.10,ROUGE-2提升0.07,ROUGE-L提升0.07,BLEU提升0.05。
原文摘要 · Abstract (English)
Large language models (LLMs) have demonstrated impressive success in a wide range of natural language processing (NLP) tasks due to their extensive general knowledge of the world. Recent works discovered that the performance of LLMs is heavily dependent on the input prompt. However, prompt engineering is usually done manually in a trial-and-error fashion, which can be labor-intensive and challenging in order to find the optimal prompts. To address these problems and unleash the utmost potential of LLMs, we propose a novel LLMs-agnostic framework for prompt optimization, namely GRL-Prompt, which aims to automatically construct optimal prompts via reinforcement learning (RL) in an end-to-end manner. To provide structured action/state representation for optimizing prompts, we construct a knowledge graph (KG) that better encodes the correlation between the user query and candidate in-context examples. Furthermore, a policy network is formulated to generate the optimal action by selecting a set of in-context examples in a rewardable order to construct the prompt. Additionally, the embedding-based reward shaping is utilized to stabilize the RL training process. The experimental results show that GRL-Prompt outperforms recent state-of-the-art methods, achieving an average increase of 0.10 in ROUGE-1, 0.07 in ROUGE-2, 0.07 in ROUGE-L, and 0.05 in BLEU.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。