Hyperband-based Bayesian Optimization for Black-box Prompt Selection

Lennart Schneider, Martin Wistuba, Aaron Klein, Jacek Golebiowski, Giovanni Zappella, Felice Antonio Merra

Abstract

Finding the optimal prompt for a black-box Large Language Model (LLM) is often a slow, expensive game of trial and error. This paper introduces HbBoPs (Hyperband-based Bayesian Optimization for black-box Prompt selection), a novel method that combines smart resource scheduling with a specialized "structural-aware" Gaussian Process. By doing so, it identifies high-performing prompts using significantly fewer API calls than current state-of-the-art techniques.

The Challenge: Black-Box Prompt Optimization

LLMs are notoriously sensitive to how they are prompted. A slight change in instructions or the choice of few-shot examples can lead to wild swings in performance. In a "black-box" setting—where models like Claude or GPT-4 are accessed via API—researchers lack access to gradients to guide optimization.

This creates a "combinatorial explosion." For instance, combining 10 possible instructions with 50 sets of few-shot examples yields 500 candidate prompts. Evaluating every candidate on a full validation set is prohibitively expensive and slow. The core challenge is navigating this massive search space to find the best prompt while minimizing LLM queries.

The Solution: Introducing HbBoPs

HbBoPs tackles this challenge through two primary mechanisms:

  1. Structural-aware Deep Kernel Gaussian Process (DK-GP): Standard Bayesian Optimization typically treats an entire prompt as a single, long string. HbBoPs introduces a "structural-aware" approach by creating separate embeddings for the instruction and the few-shot exemplars. These are fed into a deep neural network to learn a joint latent representation. This modular understanding significantly improves the surrogate model's ability to predict prompt performance.
  2. Hyperband as a Multi-Fidelity Scheduler: To manage the computational budget (LLM API calls), HbBoPs uses Hyperband. It evaluates many prompts on a tiny subset of validation data (low fidelity), discards the underperformers, and promotes the winners to be tested on larger subsets (higher fidelity).
  3. Integration: Unlike standard Hyperband, which samples new candidates randomly, HbBoPs uses its specialized DK-GP to propose which prompts to evaluate next. This makes the search both sample-efficient (finding good prompts with fewer candidates) and query-efficient (using fewer validation instances).

Experimental Setup

The researchers evaluated HbBoPs across ten diverse benchmarks and three LLMs (Claude 3 Haiku, Llama 3 8B Instruct, and Mistral 7B Instruct). Tasks spanned reasoning and math (AI2 ARC, GSM8K) and language tasks (BIG-bench subsets, instruction induction tasks like sentiment analysis and object counting). The search space for each task consisted of 250 candidate prompts (5 instructions × 50 exemplar sets).

Key Insights & Results

  • Modularity Matters: Treating a prompt as a collection of distinct components (instruction + examples) is far superior to treating it as a monolithic text block. Separate embeddings allow the surrogate model to better generalize across the search space.
  • Fidelity as Sample Size: The authors cleverly define "fidelity" as the number of validation instances. A terrible prompt can be identified with just 10 examples, reserving the full 1,000-example evaluations for distinguishing between the top 1% of candidates.
  • Superior Efficiency & Anytime Performance: HbBoPs identifies strong prompts much earlier in the process than competitors. At a limited budget (25% of total possible LLM calls), HbBoPs outperformed the best full-fidelity method (HDBO) by 35% and the best multi-fidelity competitor (TRIPLE-SH) by 24%.
  • Lower Error & Robustness: Across all benchmarks, HbBoPs achieved an average normalized test error of 0.150, significantly lower than Random Search (0.214), MIPROv2 (0.198), or EASE (0.195). Furthermore, the method proved robust to the choice of the underlying embedding model (BERT, MPNet, DistillRoBERTa), highlighting the strength of the structural-aware architecture.

Limitations & Future Directions

  • Fixed Candidate Pool: The current study focuses on selecting from a predefined pool rather than generating or mutating prompts dynamically.
  • Prompt Complexity: Real-world prompts often include formatting constraints (e.g., "return JSON") or output guidance, which were not explicitly modeled in this structural-aware kernel.
  • Multi-Objective Optimization: Future work could balance prompt performance against latency. Adding more few-shot examples might increase accuracy but simultaneously makes the LLM slower and more expensive in production.

Summary updated

BibTeX
@inproceedings{schneider2025hyperband,
  author = {Lennart Schneider and Martin Wistuba and Aaron Klein and Jacek Golebiowski and Giovanni Zappella and Felice Antonio Merra},
  title = {{Hyperband-based Bayesian Optimization for Black-box Prompt Selection}},
  booktitle = {International Conference on Machine Learning},
  year = {2025},
  url = {https://openreview.net/forum?id=zPgASahv2s},
}
Figure