Large Language Models as Optimizers

Chengrun Yang, Xuezhi Wang, Yifeng Lu, Hanxiao Liu, Quoc V. Le +2 more
2/12/2026

Official code: google-deepmind/opro (761 stars, Apache-2.0, last commit 2024-12-04). 3 more implementations below.

Abstract

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 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.

View on arXivView PDF

Code Implementations(4)

Apache-2.0

official code for "Large Language Models as Optimizers"

76193PythonOct 2, 20231 years agoApache-2.0

Official implementation for "GLaPE: Gold Label-agnostic Prompt Evaluation and Optimization for Large Language Models" (stay tuned & more will be updated)

81PythonJan 16, 20242 years ago
large-language-modelsprompt-evaluationprompt-optimization
MIT

Production implementation of OPRO (Wei et al., 2023) — gradient-free prompt optimization via LLM-as-optimizer. Implements p* = argmax f(p) over discrete natural language space. Built from the paper, no prompt libraries. arXiv:2309.03409

10TypeScriptMar 28, 20266 months agoMIT
anthropicgradient-free-optimizationllmmachine-learningnextjs+5 more

Implementing Tree of thought with Self-Consistency and Automatically refine prompts via iterative feedback (OPRO). Papers implementing https://arxiv.org/pdf/2203.11171 , https://arxiv.org/pdf/2305.10601 , https://arxiv.org/pdf/2309.03409

00PythonJun 24, 20251 years ago

Similar Papers

Cite this paper

@article{yang2026large,
  title  = {Large Language Models as Optimizers},
  author = {Chengrun Yang and Xuezhi Wang and Yifeng Lu and Hanxiao Liu and Quoc V. Le and Denny Zhou and Xinyun Chen},
  year   = {2026},
  eprint = {2309.03409},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/pdf/2309.03409},
  journal = {ICLR 2023 2023}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2309.03409.svg)](https://codeofpaper.com/paper/2309.03409)

Discussion