大型语言模型作为优化器
Large Language Models as Optimizers
September 7, 2023
作者: Chengrun Yang, Xuezhi Wang, Yifeng Lu, Hanxiao Liu, Quoc V. Le, Denny Zhou, Xinyun Chen
cs.AI
摘要
优化是无处不在的。虽然基于导数的算法一直是各种问题的强大工具,但梯度缺失给许多现实世界应用带来了挑战。在这项工作中,我们提出了一种名为PROmpting优化(OPRO)的简单而有效的方法,利用大型语言模型(LLMs)作为优化器,其中优化任务用自然语言描述。在每个优化步骤中,LLM从包含先前生成的解及其值的提示中生成新解,然后评估这些新解并将其添加到下一个优化步骤的提示中。我们首先展示了OPRO在线性回归和旅行推销员问题上的应用,然后转向提示优化,目标是找到最大化任务准确性的指令。通过多种LLM,我们证明了OPRO优化的最佳提示在GSM8K上比人类设计的提示提高了高达8%,在Big-Bench Hard任务上提高了高达50%。
English
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.