TL;DR
This paper introduces UniPrompt, a novel method for automatically generating high-quality, human-like prompts for large language models (LLMs) from scratch. UniPrompt leverages a two-stage training process, first using a large dataset of sectioned prompts curated by GPT-4, and then fine-tuning with Direct Preference Optimization (DPO) based on GPT-4's feedback, enabling it to generate effective prompts across diverse tasks without task-specific optimization.
What Problem Does This Paper Address?
The effectiveness of Large Language Models (LLMs) like GPT-3.5 and GPT-4 is heavily dependent on the quality of the prompts they receive. Crafting these prompts, known as prompt engineering, is a complex and iterative process that often relies on manual heuristics and significant effort. While some research has focused on automating prompt optimization by editing existing prompts, generating high-quality prompts from scratch remains a significant challenge due to the vast search space of possible prompt structures and phrasings. Human-written prompts are often detailed and structured into multiple sections, providing crucial context and guidance to LLMs. This paper aims to bridge this gap by developing a system that can automatically generate such structured, human-like prompts from a simple task description.
Methods
UniPrompt employs a two-stage training approach using an auxiliary language model (smaller than the target "solver" LLM).
- Supervised Finetuning (SFT): The auxiliary model is first finetuned on a novel dataset containing over 500 diverse tasks. This dataset was curated using GPT-4, which generated sectioned prompts (e.g., Introduction, Task Description, Background Knowledge, Tricks, Output Format) for each task based on a simple task description. This stage imbues the model with the ability to generate structured, human-like prompt components.
- Feedback-Based Optimization (DPO): To further align the generated prompts with the performance of the solver LLM, a second stage of finetuning is performed using Direct Preference Optimization (DPO). This involves:
- Generating prompts using the SFT model.
- Evaluating these prompts with the target solver LLM (e.g., GPT-4) on a validation set.
- Using GPT-4 to provide feedback on why prompts perform poorly and to suggest improved prompts.
- Creating a preference dataset where pairs of prompts (initial vs. improved) are ranked based on their performance.
- Finetuning the auxiliary model using DPO to optimize for preferred prompts, effectively teaching it to generate prompts that lead to higher accuracy from the solver LLM.
A key aspect of UniPrompt is its task-agnostic nature; once trained, it can generate prompts for new, unseen tasks.
Datasets
- Training Data: A novel dataset of approximately 12,000 task-prompt pairs was curated using GPT-4. This dataset covers over 500 diverse tasks, with prompts structured into multiple sections.
- Evaluation Datasets: The model was evaluated on three publicly available datasets not used during training:
- MedQA: A dataset of multiple-choice medical questions from USMLE exams.
- CauseEffectPairs: A dataset of cause-effect relationships across various domains.
- Ethos: A multi-label hate speech detection dataset.
Key Insights and Ideas
- Structure Matters: Human-generated prompts often benefit from a structured, multi-section format. UniPrompt explicitly models this by generating prompts with sections like Introduction, Task Description, and Tricks.
- GPT-4 as a Teacher and Critic: The paper effectively leverages GPT-4 for both generating initial high-quality prompts (teacher) and providing feedback for refinement (critic), demonstrating its utility in the prompt generation pipeline.
- DPO for Alignment: Direct Preference Optimization proves to be a stable and effective method for aligning the prompt generator with the solver LLM's performance, avoiding the complexities of traditional Reinforcement Learning from Human Feedback (RLHF).
- Task-Agnosticism is Achievable: By training on a diverse set of tasks, UniPrompt demonstrates the ability to generalize and generate effective prompts for novel tasks without requiring task-specific optimization during inference.
- Examples Can Sometimes Hurt: The paper notes an interesting finding where providing in-context examples in prompts can sometimes decrease performance, suggesting that prompt design is nuanced and not always about adding more information.
Key Results
UniPrompt consistently outperformed various baselines across the evaluated datasets and solver LLMs (GPT-3.5 and GPT-4).
- Against Human-Generated Prompts: UniPrompt (SFT+DPO) showed significant improvements, for example, outperforming human prompts on the Ethos dataset by up to 11.1% (with GPT-3.5) and on the Causal dataset by up to 7.4% (with GPT-3.5).
- Against Zero-Shot GPT-4: UniPrompt (SFT+DPO) also demonstrated superiority over zero-shot GPT-4, achieving up to 19.4% higher accuracy on Ethos (with GPT-3.5) and 12.4% on Causal (with GPT-3.5).
- Against Existing Prompt Optimization Techniques: UniPrompt outperformed methods like APO and LLM Optimizer, achieving up to 19.2% better performance on Ethos (with GPT-3.5) and 15.6% on Causal (with GPT-3.5).
Limitations and Future Work
- GPT-4 Feedback Granularity: The current method prompts GPT-4 to provide feedback on the entire prompt. The authors suggest that for highly elaborate, sectioned prompts, GPT-4 might struggle to provide specific, granular edits.
- Prompt Space Exploration: Exploring the prompt space using language feedback might not be the most optimal approach.
- Future Directions:
- Developing more principled approaches to explore the prompt space.
- Gaining finer control over the prompt generator's output.
- Investigating the impact of incorporating examples into the prompt generation process more systematically.
Summary updated