NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Unleashing the Potential of Large Language Models as Prompt Optimizers: Analogical Analysis with Gradient-based Model Optimizers

Xinyu Tang, Xiaolei Wang, Wayne Xin Zhao, Siyuan Lu, Yaliang Li, Ji-Rong Wen

Introduction

Large Language Models (LLMs) exhibit remarkable capabilities but remain highly sensitive to prompt engineering. Minor linguistic variations can significantly impact performance, leading to a search for automated prompt optimization methods. While existing approaches have made strides, they often rely on "black-box" heuristics or require internal model access (e.g., gradients or logits), which is unavailable for proprietary models like GPT-4.

Researchers from Renmin University, BUPT, and Alibaba Group have introduced GPO (Gradient-inspired LLM-based Prompt Optimizer). This framework establishes a formal analogy between traditional gradient-based model training and iterative prompt refinement, providing a principled methodology for automatic prompt optimization.

The GPO Framework

The core innovation of GPO lies in its systematic translation of optimization theory into natural language instructions for an LLM-based optimizer. By treating prompt refinement like model training, the authors decompose the optimization process into two primary factors: the Update Direction and the Update Method.

The GPO framework translates gradient-based optimization concepts into natural language instructions for LLMs.

1. Update Direction: Defining the "Where"

In traditional optimization, gradients and momentum dictate the direction of weight updates. GPO replicates this through:

  • Current Information (Descent Direction): The optimizer is provided with the current prompt and its corresponding performance score.
  • Trajectory (Momentum): Instead of relying solely on the most recent iteration, GPO retrieves $k$ relevant prompts from the optimization history. The researchers found that semantic relevance-based retrieval is more effective than simple chronological history, effectively mimicking momentum in a discrete space.

2. Update Method: Defining the "How"

The update method governs how the prompt is modified based on the identified direction, analogous to descent strategies and learning rates:

  • Refinement Strategy (Descent): GPO employs a generation-based approach. Rather than asking the LLM to "edit" a prompt, it provides a trajectory of past successes and failures as demonstrations, prompting the LLM to generate a new, improved version from scratch.
  • Edit Distance (Learning Rate): To ensure stability and convergence, GPO implements a Cosine Decay strategy for edit distance. This limits the number of words the LLM can change, starting with broad exploration and gradually tightening constraints as the process nears an optimal solution.

Experimental Evaluation

GPO was evaluated across diverse benchmarks, including Big-Bench Hard (BBH) for complex reasoning, MMLU for knowledge-intensive tasks, and GSM8K for mathematical reasoning. The experiments utilized various models, including Llama-2, Llama-3, GPT-3.5-turbo, and GPT-4.

Key Insights

  • The Reflection Trap: Interestingly, asking LLMs to "reflect" on failures—a common heuristic—often degraded performance. The authors hypothesize that LLMs may generate inaccurate self-feedback, leading the optimizer astray.
  • Momentum and History: Incorporating a trajectory of past prompts significantly outperformed methods that only considered the current state.
  • Generation over Editing: Generating new prompts from scratch based on historical context proved more robust than direct editing of existing prompts.

Results and Efficiency

GPO demonstrated substantial performance gains over established baselines such as APE, OPRO, and APO. Specifically, it achieved improvements of up to 56.8% on BBH and 62.6% on MMLU relative to the best baseline methods.

GPO achieves higher accuracy faster and with significantly lower token consumption compared to existing methods.

Beyond raw accuracy, GPO is remarkably efficient. As shown in the optimization curves and token consumption analysis, GPO converges to higher accuracy levels more rapidly and consumes significantly fewer tokens than competing methods like OPRO or PE2. Furthermore, prompts optimized by GPO showed strong generalizability, transferring effectively across related datasets.

Conclusion

GPO represents a significant step toward making prompt engineering a more scientific discipline. By leveraging the analogy of gradient-based optimization, it provides a structured and efficient framework for unleashing the full potential of LLMs. Future work may explore second-order optimization analogies or the integration of more granular numerical feedback signals to further refine the optimization process.

Summary updated

BibTeX
@inproceedings{tang2025unleashing,
  author = {Xinyu Tang and Xiaolei Wang and Wayne Xin Zhao and Siyuan Lu and Yaliang Li and Ji-Rong Wen},
  title = {{Unleashing the Potential of Large Language Models as Prompt Optimizers: Analogical Analysis with Gradient-based Model Optimizers}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i24.34713},
}
Figure