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

Localized Zeroth-Order Prompt Optimization

Wenyang Hu, Yao Shu, Zongmin Yu, Zhaoxuan Wu, Xiaoqiang Lin, Zhongxiang Dai, See-Kiong Ng, Bryan Kian Hsiang Low

TL;DR

Prompt optimization for black-box LLMs usually relies on expensive global search algorithms that struggle under tight API budgets. This paper introduces Localized Zeroth-Order Prompt Optimization (ZOPO), which shifts the focus to finding "good enough" local optima using a highly query-efficient, gradient-free approach. By mapping discrete text prompts into continuous embeddings and using a Neural Tangent Kernel (NTK) Gaussian process to estimate gradients, ZOPO achieves state-of-the-art performance while drastically reducing the number of required model queries.

The Problem with Global Prompt Optimization

To extract the best performance from a black-box LLM (like ChatGPT or Claude via API), users must engineer the perfect text prompt. Because these models only accept discrete text and hide their internal weights, standard gradient descent cannot be used to optimize the prompt directly.

Recent automated methods (such as InstructZero or APE) frame this as a global optimization problem. They use techniques like Bayesian optimization or evolutionary algorithms to search the vast space of all possible prompts. However, global search is incredibly query-inefficient. Under a limited budget (e.g., restricting optimization to just 150 API calls to save time and money), global methods waste too many queries exploring poor regions of the prompt space and often fail to converge on a good solution.

This raises a critical question: Do we really need to find the absolute global best prompt, or is a high-performing local optimum sufficient?

Methodology: Introducing ZOPO

To solve the query-efficiency problem, the authors propose ZOPO, which abandons global search in favor of a targeted, localized approach.

  1. Domain Transformation: Because mathematical optimization cannot be performed directly on discrete words, ZOPO first uses an LLM to generate a pool of candidate text prompts. It then uses an embedding model (like SBERT) to map these discrete prompts into a continuous, dense numerical space.
  2. Localized Zeroth-Order Optimization (ZOO): Instead of searching the entire space, ZOPO picks a starting point in this continuous space and performs local gradient descent. Since it lacks access to the black-box LLM's actual gradients (hence "zeroth-order"), it estimates them based purely on the inputs and the resulting accuracy scores.
  3. Derived NTK-GP: To estimate these gradients efficiently without wasting queries, ZOPO uses a surrogate model: a Gaussian Process (GP). Crucially, instead of standard mathematical kernels, it uses a Neural Tangent Kernel (NTK), which is theoretically proven to better mimic the behavior of deep neural networks.
  4. Uncertainty-Informed Exploration: If the surrogate model is highly uncertain about the gradient in a specific local area, ZOPO strategically queries a few neighboring points to sharpen its estimates and keep the optimization on track.

Key Insights and Ideas

  • Insight I: Local optima are the hidden gems of prompt engineering. By visualizing the loss landscape of prompt embeddings, the authors found that the absolute "global optimum" is incredibly rare and hard to find. However, there are many local optima that perform exceptionally well. Targeting these local peaks is a much smarter use of a limited query budget.
  • Insight II: Your choice of embedding shapes the landscape. How you represent the prompt mathematically matters. Using structured embeddings (like SBERT) creates a smoother landscape with easier-to-find local optima compared to random numerical projections or raw last-token embeddings.
Performance landscapes across different embeddings
  • Better generators = better starting lines. Using a highly capable black-box model (like ChatGPT) to generate the initial pool of candidate prompts yields a much higher baseline of quality than using smaller, open-source white-box models (like Vicuna-13B).

Key Results

The authors evaluated ZOPO across a wide variety of NLP benchmarks, including 30 Instruction Induction tasks, 3 Arithmetic Reasoning tasks (for Chain-of-Thought prompts), and the GLUE Benchmark.

  • High Query Efficiency and Superior Accuracy: Under a strict budget of just 165 queries, ZOPO significantly outperformed strong baselines (APE, InstructZero, INSTINCT, EvoPrompt, OPRO). Across the board, ZOPO reached higher validation and test accuracies in fewer API calls than global optimization methods.
Test and validation accuracy versus number of queries
  • Connecting ChatGPT with ZOPO: When using ChatGPT to generate the initial prompts and SBERT to embed them, the framework achieved even higher accuracy on complex tasks like second_word_letter and sentence_similarity.
  • Better Chain-of-Thought: ZOPO successfully discovered better zero-shot reasoning prompts than the standard "Let's think step by step." For example, on the GSM8K math dataset, ZOPO found the prompt "Let's find the solution by using the given information," which boosted accuracy from 71.80% to 75.36%.

Limitations and Future Work

The authors note a lack of a strict, theoretical principle for selecting the best combination of prompt generation LLM and embedding model, as the optimal pairing can currently be task-dependent. Future research should focus on developing automated, principled ways to evaluate and select the best embedding spaces prior to running the optimization, which could boost ZOPO's performance even further.

Summary updated

BibTeX
@inproceedings{hu2024localized,
  author = {Wenyang Hu and Yao Shu and Zongmin Yu and Zhaoxuan Wu and Xiaoqiang Lin and Zhongxiang Dai and See-Kiong Ng and Bryan Kian Hsiang Low},
  title = {{Localized Zeroth-Order Prompt Optimization}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=hS1jvV3Dk3},
}
Figure