PromptWizard: Task-Aware Agent-driven Prompt Optimization Framework

Eshaan Agarwal, Vivek Dani, Tanuja Ganu, Akshay Nambi · DOI

Abstract

PromptWizard is a fully automated framework designed to optimize prompts for black-box Large Language Models (LLMs) such as GPT-4. By implementing a self-evolving feedback loop that iteratively critiques failures and refines both instructions and in-context examples in tandem, PromptWizard achieves state-of-the-art performance across 45 diverse tasks. Evaluation shows it is up to 60x more cost-efficient than existing discrete optimization methods, making high-quality prompt engineering accessible and scalable.

Introduction

Prompt engineering has become a cornerstone of effective interaction with Large Language Models (LLMs). However, finding the optimal prompt is often a labor-intensive "black art" due to the high sensitivity of models to specific wording. Existing automated solutions are often limited: gradient-based methods require internal model access (unavailable for closed-source models), while black-box methods like evolutionary algorithms can be inefficient and expensive. PromptWizard addresses these limitations by introducing a structured, agent-driven framework for discrete prompt optimization.

Methodology

The core of PromptWizard is a self-evolving mechanism that mimics human iterative refinement. It operates through two main stages: Iterative Instruction Refinement and Sequential Optimization of Instructions and Examples.

The PromptWizard framework architecture, illustrating the iterative refinement and sequential optimization stages.

In the refinement stage, a "Critique-and-Synthesis" loop uses an LLM to analyze why specific prompts failed on a mini-batch of data, then synthesizes improved versions. Simultaneously, the framework optimizes few-shot examples by selecting diverse training data and generating synthetic examples with Chain-of-Thought (CoT) reasoning to address identified weaknesses. Finally, the framework integrates Task Intent and Expert Personas to further align the model's behavior with human expectations.

Experimental Setup

The authors evaluated PromptWizard across 45 challenging tasks using several well-known benchmarks:

  • BIG-Bench Instruction Induction (BBII): 19 tasks focused on general language understanding.
  • Big Bench Hard (BBH): 23 tasks requiring multi-step reasoning.
  • Arithmetic Reasoning: Specialized math datasets including GSM8k, AQUARAT, and SVAMP.

The framework was tested using both GPT-3.5-Turbo and GPT-4 as the target models for optimization and inference.

Results and Discussion

PromptWizard demonstrated superior accuracy and efficiency compared to existing baselines. On the BBII benchmark, PromptWizard achieved the highest accuracy on 13 out of 19 tasks in a zero-shot setting and 16 out of 19 in a one-shot setting, consistently outperforming baselines like Instinct and APE.

Detailed performance comparison of PromptWizard (PW) against baselines on the BBII benchmark tasks using GPT-3.5-Turbo.

Beyond accuracy, efficiency is a primary advantage. PromptWizard is 16-60x cheaper than previous discrete methods, requiring just 69 API calls per task compared to the thousands required by methods like PromptBreeder. Key insights from the study include:

  • Critique vs. Mutation: Targeted reflection on errors is significantly faster and more effective than random text mutation.
  • Sequential Optimization: Instructions and examples are deeply intertwined; optimizing them in tandem captures task nuances that isolated optimization misses.
  • Cross-Model Optimization: Smaller models (e.g., Llama-3-70B) can generate optimized prompts that remain highly effective when used by more powerful models like GPT-4.

Conclusion

PromptWizard demonstrates that targeted critique and joint optimization of instructions and examples can significantly enhance LLM performance while drastically reducing computational costs. While the process is largely automated, the authors note that specialized tasks still benefit from human-guided intent and careful validation to mitigate potential biases. Future work will focus on refining synthetic example generation and applying the framework to resource-constrained real-world environments.

Summary updated

BibTeX
@misc{agarwal2024promptwizard,
  author = {Eshaan Agarwal and Vivek Dani and Tanuja Ganu and Akshay Nambi},
  title = {{PromptWizard: Task-Aware Agent-driven Prompt Optimization Framework}},
  year = {2024},
  eprint = {2405.18369},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2405.18369},
}
Figure