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

InstructZero: Efficient Instruction Optimization for Black-Box Large Language Models

Lichang Chen, Jiuhai Chen, Tom Goldstein, Heng Huang, Tianyi Zhou

TL;DR

InstructZero is a novel framework that automates the search for the optimal instruction for black-box Large Language Models (LLMs) like ChatGPT. By optimizing a low-dimensional "soft prompt" for a smaller, open-source LLM (which then generates the actual text instruction), it bypasses the need for gradients and efficiently navigates the complex, discrete space of natural language using Bayesian Optimization.

What Problem Does This Paper Address?

LLMs are notoriously sensitive to prompting. A slight change in how you phrase an instruction can be the difference between a brilliant answer and a complete hallucination. This sensitivity has led to the rise of "prompt engineering," which is often a time-consuming process of human trial-and-error.

Automating this process is challenging for two main reasons:

  1. The Black-Box Problem: Top-tier models like GPT-4 are accessible only via APIs. We cannot access their gradients, making it impossible to use standard backpropagation to "tune" an instruction directly.
  2. The Discrete Space Problem: Human language is discrete and combinatorial. Searching through every possible sentence to find the best instruction is computationally intractable.

Existing methods like APE (Automatic Prompt Engineer) attempt to solve this by using another LLM to generate candidate prompts, but they often lack a principled, mathematically grounded way to iteratively improve those candidates based on performance feedback.

Methods

The core innovation of InstructZero is shifting the optimization target. Instead of trying to optimize discrete text directly, the authors optimize a low-dimensional soft prompt ($p$) in a continuous latent space.

Here is the step-by-step optimization loop:

  1. Soft Prompting a Proxy: A small, open-source LLM (like Vicuna) acts as an "instruction generator." It takes a continuous soft prompt (projected into its input space) alongside a few task examples, and generates a discrete, human-readable instruction ($v$).
  2. Black-Box Evaluation: This generated instruction is sent to the black-box LLM (e.g., ChatGPT). The black-box model's zero-shot performance on the task is recorded as a score.
  3. Bayesian Optimization (BO): This score is fed back into a Bayesian Optimization algorithm. BO uses this data to update its surrogate model of which soft prompts lead to high-performing instructions, subsequently suggesting a new, better soft prompt to explore.
The InstructZero pipeline: optimizing soft prompts to generate discrete instructions for black-box models.

A key technical breakthrough in this pipeline is the Instruction-Coupled Kernel. Standard BO kernels do not inherently understand language. The authors developed a specialized kernel that aligns the latent space of the soft prompts with the semantic similarity of the instructions they produce and the outputs they trigger. This ensures the optimization process is grounded in the actual linguistic behavior of the models.

Datasets

The researchers evaluated InstructZero on a comprehensive benchmark of 32 tasks derived from BIG-Bench. This evaluation suite included:

  • 24 standard tasks used in previous auto-instruction research (e.g., Antonyms, Cause Selection, Word Sorting).
  • 8 new, challenging tasks introduced by the authors to test the limits of the method, such as "ASCII Art Recognition," "Code Debugging," and "Object Counting."

Key Insights

  • Breaking the Scaling Law: A surprising finding is that a relatively small open-source model (like Vicuna-13B) can successfully optimize instructions for a vastly more powerful, proprietary model (like ChatGPT). You don't need a giant model to "teach" another giant model; you just need a searchable, continuous interface.
  • Continuous Beats Discrete: By shifting the search from discrete words to a continuous latent space, the framework can leverage powerful mathematical tools like Bayesian Optimization, which are far more sample-efficient than random sampling or simple paraphrasing.
  • Alignment is Crucial: The success of the "Instruction-Coupled Kernel" demonstrates that for BO to work in NLP contexts, the optimizer needs a mechanism to map its continuous latent variables to actual textual meaning and downstream model behavior.

Key Results

InstructZero consistently outperformed previous state-of-the-art methods (like APE) and uniform sampling baselines across the board.

  • Universal Improvement: It achieved superior performance across the 32 evaluated tasks, showing a strong distribution of execution accuracy improvements over both APE and Uniform baselines.
  • Massive Gains on Hard Tasks: In highly specific tasks like "Taxonomy Animal" (extracting animals from a mixed list), baseline methods like APE struggled heavily (4% accuracy). InstructZero, however, successfully optimized the instruction to reach 92% accuracy.
InstructZero's performance improvements over baselines, highlighting the massive gain on the Taxonomy Animal task.

Furthermore, the instructions generated by InstructZero become visibly clearer and more task-aligned over just a few iterations of the BO loop, proving the efficacy of the iterative refinement process.

Limitations and Future Work

While powerful, InstructZero has a few limitations:

  • Proxy Dependency: The method relies entirely on the open-source LLM to generate the instructions. If the proxy model is too weak to follow the soft prompt's "steering," the optimization bottleneck shifts to the proxy's generation capabilities.
  • Computational Cost: While more sample-efficient than manual tuning, running multiple iterations of LLM API calls and BO updates still carries a cost in terms of API credits and compute time.

Future Directions: The authors suggest exploring different proxy models and more complex kernel functions. There is also significant potential to apply this framework to multi-modal models, such as optimizing text prompts for black-box image generators.

Ultimately, InstructZero represents a major step toward moving prompt engineering away from a "black art" and toward a rigorous, automated science of instruction optimization.

Summary updated

BibTeX
@inproceedings{chen2024instructzero,
  author = {Lichang Chen and Jiuhai Chen and Tom Goldstein and Heng Huang and Tianyi Zhou},
  title = {{InstructZero: Efficient Instruction Optimization for Black-Box Large Language Models}},
  booktitle = {International Conference on Machine Learning},
  year = {2024},
  url = {https://openreview.net/forum?id=rADFNrIss3},
}
Figure