TL;DR
Automatic prompt optimization methods help tailor Large Language Model (LLM) instructions to specific tasks, but they are highly vulnerable to distribution shifts between training and deployment data. To address this, the authors introduce the Generalized Prompt Optimization (GPO) framework, which leverages unlabeled target data and an ensemble pseudo-labeling strategy to generate robust prompts that generalize effectively across different data distributions.
What Problem Does This Paper Address?
As LLMs are increasingly deployed via black-box APIs, developers rely on gradient-free prompt optimization methods (like Automatic Prompt Engineer, or APE) to automatically find the best phrasing for a task. Typically, these methods optimize a prompt using a labeled "source" dataset.
However, real-world applications frequently face distribution shifts—such as a sentiment analysis tool trained on restaurant reviews (Yelp) but deployed on product reviews (Flipkart). The authors demonstrate that prompts optimized for a specific source distribution often overfit to that context, leading to significant performance drops when deployed on a target distribution.
The core challenge is: How can we optimize a single, robust prompt that performs well on both source and target distributions without incurring the high labor cost of manually labeling new target data?
Methods
The authors propose the Generalized Prompt Optimization (GPO) framework, which incorporates unlabeled data from the target group into the prompt optimization loop. GPO operates in three main steps:
- Prompt Generation via Meta-Prompt: Using different splits of the labeled source data ($G_s$), an LLM is fed a "Meta-Prompt" to infer the underlying task and generate $K$ distinct candidate prompts.
- Prompt Ensemble Labeling Strategy: To utilize the unlabeled target data ($\{x_t\}$), GPO uses the $K$ generated prompts to pseudo-label the target data. To mitigate the risk of noisy or incorrect labels, they apply a consistency threshold ($T$). Only target samples where more than $T$ percent of the prompts agree on the label are kept, creating a high-quality filtered target dataset ($G_t^*$).
- Joint Prompt Optimization: The labeled source data ($G_s$) and the filtered, upsampled pseudo-labeled target data ($G_t^*$) are mixed together. This combined dataset is then run through a standard prompt optimization pipeline (like APE) to produce the final, robust prompt.
Datasets
The authors evaluated prompt robustness across 16 datasets spanning six popular NLP tasks:
- Sentiment Analysis: Yelp, Flipkart, IMDB, Amazon
- Commonsense QA: SocialIQA, PIQA, OpenbookQA
- Numerical QA: DROP (split into Number and Spans sub-groups)
- Natural Language Inference: MNLI, ANLI
- Textual Entailment: RTE, HANS
- Dialog: DSTC7, Ubuntu Dialog, MuTual
Key Insights and Ideas
- Prompts Overfit to Context: Standard optimization tools include highly specific background information in the prompt (e.g., explicitly mentioning "customer reviews of a product" for Flipkart). While helpful for the source data, this text hinders generalization to other domains. GPO forces the LLM to generate more abstract, universally applicable instructions.
- Data Diversity Breeds Robustness: Surprisingly, prompts optimized on a highly diverse source dataset (like OpenbookQA) sometimes outperformed prompts optimized directly on the target dataset. A more diverse training set naturally covers heterogeneous patterns, yielding a more resilient prompt.
- LLMs Generalize Better on Logic Than Domain: Distribution shifts caused massive performance gaps in sentiment analysis and QA tasks, but had almost no impact on Natural Language Inference (NLI) and Textual Entailment. The inherent reasoning capabilities of LLMs appear robust to distribution shifts in logical tasks, but vulnerable in domain-specific ones.
Key Results
The GPO framework was tested against state-of-the-art baselines like APE and APO (Automatic Prompt Optimization) using gpt-3.5-turbo-0301 as the backbone model.
- Superior Target Performance: GPO consistently outperformed baselines on target groups. For instance, when generalizing from Yelp to Flipkart, GPO achieved an ensemble accuracy of 84.5%, compared to APE's 81.3% and APO's 76.4%.
- Preserved Source Performance: GPO achieved these target gains without sacrificing accuracy on the original source domain.
- Labeling Accuracy Matters: The consistency threshold was proven vital. As shown in the ablation studies, manually injecting incorrect labels into the target training data caused a direct degradation in final deployment accuracy.
The framework also proved effective across different model architectures, providing substantial boosts when using smaller open-source models like Vicuna-7B and Vicuna-13B, as well as GPT-4.
Limitations and Future Work
- Zero-Shot Only: This study focused strictly on zero-shot prompting. The impact of distribution shifts on in-context learning (few-shot prompting with examples) remains unexplored.
- Requires Target Inputs: GPO assumes that unlabeled target inputs ($\{x_t\}$) are accessible during the optimization phase. It does not solve the problem of generalizing to completely unseen target domains at test time.
- Instruction-Dependent: GPO relies on black-box LLMs that already possess strong instruction-following capabilities to generate and filter prompts, making it less applicable to smaller, non-instruction-tuned language models (like standard BERT or T5).
Summary updated