Robust Instruction Optimization for Large Language Models with Distribution Shifts

Moxin Li, Wenjie Wang, Fuli Feng, Jizhi Zhang, Tat-Seng Chua · OpenReview

Abstract

Large Language Models (LLMs) have demonstrated significant ability in accomplishing a wide range of Natural Language Processing (NLP) tasks. However, their performance is highly sensitive to even minor changes in the phrasing of task instructions, leading to a line of research in automatic instruction optimization. Unfortunately, existing methods fail to consider the distribution shift between seen training data and unseen test data. Testing on an unseen group with a different distribution can lead to a significant performance drop. This paper investigates LLM instruction optimization across data groups with distribution shifts and proposes a framework to derive more robust instructions that improve performance on unseen data without sacrificing accuracy on the seen data.

The Generalization Gap in Prompt Optimization

LLMs are notoriously sensitive to how a task is phrased. To address this, researchers have developed "Automatic Prompt Optimization" (APO) techniques, such as Automatic Prompt Engineer (APE), which use labeled data to search for the most effective wording.

However, these methods often suffer from a "generalization gap." A prompt that works perfectly for sentiment analysis on one dataset (e.g., Amazon product reviews) might perform poorly on another (e.g., IMDB movie reviews) due to distribution shifts. These shifts can manifest as differences in vocabulary, linguistic habits, or label balance. In real-world applications, data is constantly shifting, and manually labeling every new "target" group to re-optimize prompts is often impractical.

The challenge of prompt optimization and deployment under distribution shift.

Generalized Prompt Optimization (GPO)

To bridge this gap, we introduce the Generalized Prompt Optimization (GPO) framework. GPO moves beyond standard optimization by incorporating unlabeled data from the target domain to find instructions that generalize across distributions. The framework operates in three main stages:

  1. Prompt Generation via Meta Prompt: Using the labeled source data, an LLM is prompted to generate $K$ different candidate instructions that describe the task.
  2. Prompt Ensemble Labeling: These $K$ candidate prompts are used as an ensemble to "pseudo-label" the unlabeled target data. To ensure the quality of these labels, a consistency threshold ($T$) is applied: only target samples where a high percentage of the candidate prompts agree on the label are retained.
  3. Joint Prompt Optimization: The labeled source data and the high-confidence pseudo-labeled target data are combined. A standard optimization tool (like APE) is then run on this combined set to derive a final prompt that is robust across both distributions.

This approach is "gradient-free," treating the LLM as a black box, which makes it compatible with popular API-based models like GPT-4.

Overview of the GPO framework, illustrating the ensemble labeling and joint optimization process.

Experimental Evaluation

The study evaluates GPO across 16 datasets covering six diverse NLP tasks, including Sentiment Analysis, Natural Language Inference, Textual Entailment, Commonsense QA, Multi-turn Dialog, and Reading Comprehension. Experiments were primarily conducted using gpt-3.5-turbo-0301, with additional validation on gpt-4 and open-source models like Vicuna-7B/13B.

Key Results

  • Superior Generalization: GPO consistently outperformed baseline methods (APE and APO) on target groups. For instance, on the Flipkart dataset (using Yelp as a source), GPO achieved 84.5% accuracy, compared to APE’s 81.3%.
  • Handling Difficult Tasks: On the complex Reading Comprehension task (DROP), GPO improved performance on the "Spans" target group from 18.2% (APE) to 26.7%.
  • Outperforming Human Baselines: GPO surpassed human-written prompts and commercial prompt engineering services in sentiment analysis and commonsense QA tasks.
  • Model Agnostic: The benefits of GPO were observed across different backbone models, proving the framework's versatility.

Insights into Robustness

The research yielded several key insights into why prompts fail and how to make them more robust:

  • Diversity as a Buffer: Source groups with high "n-gram diversity" (like OpenbookQA) tend to produce more robust prompts because they cover a wider variety of linguistic patterns.
  • Ensembles Beat Single Labels: Using a single prompt to pseudo-label target data is risky. By using an ensemble and a consistency threshold, GPO filters out noisy labels that would otherwise degrade optimization.
  • Distribution Metrics: The paper utilizes KL divergence for label shifts and n-gram similarity for input shifts to quantitatively predict potential prompt failure.

Limitations and Future Directions

While GPO shows significant promise, it requires access to the input features of the target group, meaning it cannot optimize for entirely unknown future distributions. Additionally, the study focused on zero-shot prompts; the impact of few-shot examples on robustness remains an area for further study. Future work will explore extending GPO to handle multiple heterogeneous target groups simultaneously and improving generalization to completely unseen domains.

Summary updated

BibTeX
@inproceedings{li2023robust,
  author = {Moxin Li and Wenjie Wang and Fuli Feng and Jizhi Zhang and Tat-Seng Chua},
  title = {{Robust Instruction Optimization for Large Language Models with Distribution Shifts}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.95},
}
Figure