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 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 our main application in 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. Code at https://github.com/google-deepmind/opro.
The paper introduces OPRO, a framework allowing LLMs to serve as optimizers by generating new solutions based on natural language prompts of previously evaluated solutions.
The framework is tested on classical optimization problems like linear regression and the Traveling Salesman Problem, showing competitive performance in small-scale settings and notable improvements in prompt-based optimization for LLM tasks.
The paper discusses theoretical and practical implications, such as the adaptability of LLMs to various tasks and the potential reduction in reliance on expert human prompt engineering, and lays out future directions to enhance the framework's robustness and scalability.
The paper "LLMs as Optimizers" by Chengrun Yang et al. introduces the concept of treating LLMs as effective optimization tools. This idea deviates from traditional optimization algorithms, particularly for derivative-free scenarios where gradient information is unavailable or infeasible to compute. The proposed framework, termed Optimization by PROmpting (OPRO), leverages the natural language capabilities of LLMs to iteratively improve solutions based on prior optimization states provided through prompting.
Optimization Framework (OPRO):
Applications in Mathematical Optimization:
Prompt Optimization:
Discussion of Results:
The concept of using LLMs as optimizers opens several theoretical and practical avenues. On the theoretical front, this approach challenges traditional optimization paradigms by incorporating natural language understanding into the optimization loop. Practically, it provides a flexible and powerful toolset for tasks where formal mathematical representations are cumbersome or impractical.
Theoretical Implications:
Practical Implications:
Future Work:
"LLMs as Optimizers" significantly contributes to the understanding of how LLMs can be harnessed for optimization tasks traditionally outside the purview of natural language processing. The OPRO framework not only demonstrates the versatility and power of prompt-based optimization but also sets the stage for future research in integrating natural language capabilities with optimization and other decision-making processes. By showcasing both theoretical advancements and practical applications, the paper paves the way for innovative uses of LLMs in AI and optimization.