Collaborative Discrete-Continuous Black-Box Prompt Learning for Language Models

Hualin Zhang, Haozhen Zhang, Zhekai Liu, Bin Gu, Yi Chang

Overview: The Black-Box Challenge

As Large Language Models (LLMs) become increasingly powerful, they are frequently deployed as "Language-Model-as-a-Service" (LMaaS) via APIs (e.g., OpenAI's GPT-4). In these environments, the model acts as a black box: users cannot access the underlying parameters or calculate gradients to fine-tune the model for specific tasks.

To adapt these models, researchers typically rely on prompt learning. Current black-box methods generally focus on one of two approaches:

  1. Discrete Prompting: Searching for the optimal string of text tokens.
  2. Continuous Prompting: Optimizing a continuous vector within the model's embedding space.

The limitation of existing continuous methods is that they often initialize with randomly chosen words, severely capping their potential. Conversely, discrete methods struggle to capture the fine-grained, continuous nuances that embedding vectors can represent. Until now, there hasn't been an effective way to optimize both simultaneously in a black-box setting. This paper introduces ZO-PoG, a novel framework that collaboratively optimizes both the discrete text of a prompt and its continuous embedding, significantly outperforming existing methods without requiring access to internal model gradients.

The ZO-PoG Framework

The authors introduce ZO-PoG (Zeroth-Order and Policy Gradient), a framework that treats prompt optimization as a collaborative, two-player system:

  • Discrete Optimization (Policy Gradient): Instead of relying on random token initialization, the system learns a probability distribution over the entire vocabulary. It utilizes the Gumbel-Softmax trick to smooth the process and applies Policy Gradient (a reinforcement learning technique) to update which words are most likely to minimize the task loss.
  • Continuous Optimization (Zeroth-Order Gradient): Once a discrete prompt is sampled, the system fine-tunes it within a low-dimensional "intrinsic" subspace. Because true gradients are inaccessible, it employs Zeroth-Order (ZO) optimization, estimating the gradient by applying slight perturbations to the input and observing the resulting changes in the output loss.
  • Collaborative Alternating Strategy: The framework alternates between these two steps. This ensures that the discrete "starting point" and the continuous "fine-tuning" work in harmony to find an optimal prompt.

Crucially, the authors provide mathematical proof that this alternating approach converges to a stable solution at a sub-linear rate under mild assumptions.

Comparison between standard Black-Box Tuning (BBT) and the proposed ZO-PoG framework.

Experimental Results

The researchers evaluated ZO-PoG across several challenging benchmarks, including the GLUE Benchmark (CoLA, MNLI, QNLI, SNLI, WNLI) and GSM8K (grade-school math reasoning). The framework was tested on models including RoBERTa-large, GPT2-XL, and Llama3.

Key Performance Leaps: * GLUE Benchmark: ZO-PoG consistently outperformed established methods like Black-Box Tuning (BBT) and Policy Gradient-based Discrete Prompt Learning (BDPL). For instance, on the WNLI dataset using RoBERTa-Large, ZO-PoG achieved a 5.17% improvement over the best existing baseline. * Few-Shot Learning: In 16-shot learning scenarios using Llama3, ZO-PoG demonstrated superior adaptability and performance across nearly all tested GLUE tasks. * Math Reasoning: On the complex GSM8K dataset using GPT-4, ZO-PoG reached an impressive accuracy of 89.94%, surpassing specialized instruction optimization methods like InstructZero.

Performance comparison of ZO-PoG against baseline methods on various GLUE benchmark tasks.

Key Insights

  1. Initialization is Critical: The study proves that starting with an optimized discrete prompt is vastly superior to starting with random tokens and attempting to correct them purely in the continuous space.
  2. The Collaborative Edge: Ablation studies confirmed that removing either the discrete (Policy Gradient) or continuous (Zeroth-Order) component results in a performance drop, proving the two methods provide complementary optimization signals.
  3. Subspace Efficiency: By projecting high-dimensional embeddings into a smaller "intrinsic" space (e.g., 500 dimensions), Zeroth-Order optimization becomes computationally feasible even for massive models.
  4. Grammar vs. Performance: Interestingly, the learned discrete prompts often appear as gibberish to humans. However, they provide a much stronger task-specific signal to the LLM than human-written, grammatically correct prompts.

Limitations and Future Work

While highly effective, ZO-PoG has a few limitations:

  • Query Efficiency: Zeroth-Order optimization requires numerous forward passes (API calls) to estimate a single gradient, which can be expensive and slow when using paid commercial APIs.
  • Hyperparameter Sensitivity: The framework's success relies heavily on tuning the "temperature" of the Gumbel-Softmax and the smoothing parameter for the ZO gradient.
  • Interpretability: Because optimized discrete prompts are not human-readable, future work could explore "constrained" optimization to maintain linguistic meaning without sacrificing performance.
  • Scaling Overhead: While successfully tested on models like Llama3, the computational overhead of alternating two optimization loops on massive models (70B+ parameters) remains an area for future exploration.

Summary updated

BibTeX
@inproceedings{zhang2025collaborative,
  author = {Hualin Zhang and Haozhen Zhang and Zhekai Liu and Bin Gu and Yi Chang},
  title = {{Collaborative Discrete-Continuous Black-Box Prompt Learning for Language Models}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=sdLGY9Dj5r},
}
Figure