Introduction
Finding the perfect prompt for a black-box Large Language Model (LLM) usually requires a validation set or a numeric scoring system—luxuries many users don't have. APOHF (Automated Prompt Optimization with Human Feedback) solves this by using a dueling bandit-inspired strategy to optimize prompts based solely on simple "A vs. B" human preferences, outperforming traditional methods with remarkably few feedback iterations.
The Challenge of Prompt Engineering
LLMs are notoriously sensitive to how a prompt is phrased. While "prompt engineering" has become a field of its own, automating it typically relies on having a numeric score (like accuracy on a test set) to evaluate each candidate prompt.
However, in real-world scenarios, a user interacting with a black-box model (like GPT-4) often doesn't have a validation set. Furthermore, humans are often inconsistent when providing numeric scores (e.g., distinguishing between a 7.4 and a 7.5) but are highly reliable at stating a preference (Response A is better than Response B). The authors address the challenge of Prompt Optimization with Human Feedback (POHF): finding the best possible prompt using only these relative preferences.
The APOHF Framework
The authors introduce APOHF, an algorithm that treats prompt optimization as a "dueling bandit" problem. The technical workflow is illustrated below:
- Continuous Representation: Instead of treating prompts as discrete strings, they use embeddings from a pre-trained language model to map prompts into a continuous vector space.
- Latent Score Modeling: They train a Multi-Layer Perceptron (MLP) to act as a surrogate model. This network takes a prompt embedding and predicts a "latent score" or utility.
- Principled Selection Strategy: In each iteration, the algorithm chooses two prompts to show the user:
- Prompt 1 is chosen greedily (the current predicted best).
- Prompt 2 is chosen using an Upper Confidence Bound (UCB) strategy to balance exploration of uncertain prompts with exploitation of known high-performers.
- Feedback Loop: The user compares responses from both prompts. This binary feedback updates the Neural Network via a Bradley-Terry-Luce (BTL) preference model.
Experimental Evaluation
The researchers evaluated APOHF across three distinct domains:
- Instruction Induction: 30 tasks (e.g., antonyms, sentiment analysis) aimed at finding the best instruction for specific input-output examples.
- Text-to-Image Generation: Using DALL-E 3, they optimized prompts to match complex scene descriptions.
- Response Optimization: Using the Anthropic Helpfulness and Harmlessness datasets to refine specific model responses.
Key Findings
APOHF demonstrated significant advantages over traditional baselines like Random Search, Linear Dueling Bandits, and Double Thompson Sampling (DoubleTS).
- Superior Performance: APOHF consistently outperformed all baselines across the 30 instruction tasks.
- Sample Efficiency: High-performing prompts were discovered within 50–100 iterations, significantly faster than competing methods.
- Robustness: The algorithm remained effective even under conditions of "human noise" (inconsistent preferences), maintaining its lead until noise levels became extreme.
- Cross-Modal Versatility: The framework proved effective for both text-to-text and text-to-image tasks, suggesting that learned "utility" is a universal metric applicable across different output formats.
Limitations and Future Work
While powerful, APOHF currently only handles pairwise comparisons (A vs. B). Future research aims to extend the strategy to multi-response rankings. Additionally, because performance is tied to the quality of pre-trained embeddings, improvements in embedding models will likely enhance APOHF. Finally, the authors note the importance of safety measures to prevent the optimization of prompts for harmful or malicious outputs.
Summary updated