Optimization is ubiquitous. While derivative-based algorithms have been powerful tools for various problems, the absence of gradient imposes challenges on many real-world applications. In this work, we propose Optimization by PROmpting (OPRO), a simple and effective approach to leverage large language models (LLMs) as optimizers, where the optimization task is described in natural language. In each optimization step, the LLM generates new solutions from the prompt that contains previously generated solutions with their values, then the new solutions are evaluated and added to the prompt for the next optimization step. We first showcase OPRO on linear regression and traveling salesman problems, then move on to prompt optimization where the goal is to find instructions that maximize the task accuracy. With a variety of LLMs, we demonstrate that the best prompts optimized by OPRO outperform human-designed prompts by up to 8% on GSM8K, and by up to 50% on Big-Bench Hard tasks.
翻译:优化无处不在。尽管基于导数的算法已成为各类问题的有力工具,但梯度的缺失给许多实际应用带来了挑战。在本工作中,我们提出基于提示的优化方法(Optimization by PROmpting,OPRO),这是一种简单而有效的方法,利用大语言模型(LLMs)作为优化器,其中优化任务以自然语言描述。在每个优化步骤中,LLM从包含先前生成解及其对应值的提示中生成新解,随后评估新解并将其加入提示以进行下一步优化。我们首先在线性回归和旅行商问题上展示OPRO,随后转向提示优化——目标是最大化任务准确率的指令寻找。通过多种LLM,我们证明OPRO优化的最佳提示在GSM8K上比人工设计的提示性能高出最多8%,在Big-Bench Hard任务上高出最多50%。