Prompt engineering is critical for the development of LLM-based applications. However, it is usually done manually in a "trial and error" fashion that can be time consuming, ineffective, and sub-optimal. Even for the prompts which seemingly work well, there is always a lingering question: can the prompts be made better with further modifications? To address these problems, we investigate automated prompt engineering in this paper. Specifically, we propose PRewrite, an automated method to rewrite an under-optimized prompt to a more effective prompt. We instantiate the prompt rewriter using a LLM. The rewriter LLM is trained using reinforcement learning to optimize the performance on a given downstream task. We conduct experiments on diverse benchmark datasets, which demonstrates the effectiveness of PRewrite.
翻译:摘要:提示工程对于基于大语言模型(LLM)的应用开发至关重要。然而,这一过程通常采用人工"试错"方式进行,耗时且效率低下,难以达到最优效果。即便看似有效的提示,也始终存在一个悬而未决的问题:能否通过进一步修改使其更优?针对这些问题,本文对自动化提示工程展开研究。具体而言,我们提出PRewrite方法——一种将次优提示自动重写为更高效提示的自动化方案。该方法利用大语言模型实现提示重写器,并通过强化学习对重写器进行训练,以优化其在特定下游任务上的表现。在多个基准数据集上的实验结果表明了PRewrite的有效性。