🤖 AI Summary
To address the high cost and poor generalizability of manually engineered prompts for large language models (LLMs), this paper proposes EvoPrompt—a discrete prompt optimization framework based on evolutionary algorithms. EvoPrompt is the first method to achieve deep synergy between evolutionary operators (selection, crossover, mutation) and LLMs (e.g., GPT-3.5, Alpaca): LLMs generate candidate prompts, while an evolutionary algorithm drives gradient-free, parameter-free iterative optimization guided by unsupervised adaptability evaluation on a development set. The resulting prompts are human-readable, semantically coherent, and highly task-adapted. Evaluated across 31 benchmarks—including BIG-Bench Hard (BBH)—EvoPrompt significantly outperforms both manual prompts and existing automated methods, achieving up to a 25% absolute accuracy gain on BBH tasks. It is compatible with both closed- and open-source LLMs, demonstrating strong robustness and cross-model generalization capability.
📝 Abstract
Large Language Models (LLMs) excel in various tasks, but they rely on carefully crafted prompts that often demand substantial human effort. To automate this process, in this paper, we propose a novel framework for discrete prompt optimization, called EvoPrompt, which borrows the idea of evolutionary algorithms (EAs) as they exhibit good performance and fast convergence. To enable EAs to work on discrete prompts, which are natural language expressions that need to be coherent and human-readable, we connect LLMs with EAs. This approach allows us to simultaneously leverage the powerful language processing capabilities of LLMs and the efficient optimization performance of EAs. Specifically, abstaining from any gradients or parameters, EvoPrompt starts from a population of prompts and iteratively generates new prompts with LLMs based on the evolutionary operators, improving the population based on the development set. We optimize prompts for both closed- and open-source LLMs including GPT-3.5 and Alpaca, on 31 datasets covering language understanding, generation tasks, as well as BIG-Bench Hard (BBH) tasks. EvoPrompt significantly outperforms human-engineered prompts and existing methods for automatic prompt generation (e.g., up to 25% on BBH). Furthermore, EvoPrompt demonstrates that connecting LLMs with EAs creates synergies, which could inspire further research on the combination of LLMs and conventional algorithms.