Abstract
Prompt optimization is essential for effective utilization of large language models (LLMs) across diverse tasks. While existing optimization methods are effective in optimizing short prompts, they struggle with longer, more complex ones, often risking information loss and being sensitive to small perturbations. To address these challenges, we propose SCULPT (Systematic Tuning of Long Prompts), a framework that treats prompt optimization as a hierarchical tree refinement problem. SCULPT represents prompts as tree structures, enabling targeted modifications while preserving contextual integrity. It employs a Critic-Actor framework that generates reflections and applies actions to refine the prompt. Evaluations demonstrate SCULPT's effectiveness on long prompts, its robustness to adversarial perturbations, and its ability to generate high-performing prompts even without any initial human-written prompt. Compared to existing state of the art methods, SCULPT consistently improves LLM performance by preserving essential task information while applying structured refinements. Both qualitative and quantitative analyses show that SCULPT produces more stable and interpretable prompt modifications, ensuring better generalization across tasks.
Introduction
As Large Language Models (LLMs) are increasingly deployed for complex reasoning and multi-step tasks, the prompts used to guide them have evolved from simple instructions into extensive documents. These "long prompts" often contain hundreds of instructions, numerous few-shot examples, and intricate formatting requirements.
Existing Automatic Prompt Optimization (APO) tools, such as APE or OPRO, typically treat prompts as flat strings of text. This approach faces two significant hurdles when dealing with long prompts:
- Information Loss: Global rewriting often inadvertently removes critical context or subtle instructions necessary for task performance.
- Instability: Long prompts exhibit non-monotonic behavior, where minor changes can lead to disproportionately large and unpredictable performance drops.
SCULPT addresses these issues by shifting the abstraction of a prompt from a flat sequence of tokens to a hierarchical tree structure, allowing for surgical, localized refinements.
The SCULPT Framework
SCULPT optimizes prompts through a structured, iterative process involving three main components: Prompt Structuring, a Critic-Actor loop, and a guided search strategy.
Prompt Structuring
The framework first parses the initial prompt into a hierarchical tree. In this representation, headings and sections serve as parent nodes, while specific instructions, constraints, and examples are represented as child nodes. This structure allows the system to address and modify specific components of the prompt without affecting the integrity of the surrounding context.
The Critic-Actor Loop
Once structured, the prompt undergoes refinement through a specialized framework:
- Critic Module: This module analyzes model failures to generate two types of feedback: Structural reflections (evaluating the logical flow and clarity of the prompt) and Error-based reflections (identifying which specific node likely contributed to a misprediction).
- Aggregation: To avoid overfitting to individual errors, SCULPT aggregates similar reflections before passing them to the Actor.
- Actor Module: Rather than performing free-form rewriting, the Actor selects from a library of expert-inspired actions. These include updating instructions, adding or deleting examples, and pruning or merging nodes.
Search Strategy
To navigate the space of possible prompt variations, SCULPT employs a Beam Search combined with an Upper Confidence Bound (UCB) selection strategy. This approach balances the exploitation of high-performing prompt structures with the exploration of new variations, ensuring the optimization process does not get stuck in local optima.
Experimental Evaluation
SCULPT was evaluated across a diverse set of challenging tasks with prompts averaging 1,000 words, including Big-Bench Hard (BBH), Responsible AI (RAI) safety benchmarks, and multi-label classification tasks like GoEmotions and BeaverTails.
Key Results
- Performance Gains: SCULPT consistently outperformed state-of-the-art baselines like OPRO and ProTeGi. On complex multi-label tasks, it achieved performance improvements exceeding 10% over initial human-written prompts.
- Efficiency: By iterating on a single structured prompt rather than generating numerous unstructured candidates, SCULPT reduced computational costs by approximately 50% compared to ProTeGi.
- Robustness: The framework demonstrated remarkable resilience to "prompt decay." When tested against prompts degraded by misspellings or random insertions, SCULPT effectively "healed" the structure, whereas baseline methods often collapsed.
- Transferability: Prompts optimized using GPT-4o maintained high performance when transferred to other models, such as Llama-3.1-8B, indicating that the refinements capture fundamental task requirements rather than model-specific quirks.
Conclusion
SCULPT represents a significant advancement in prompt engineering by treating optimization as a surgical, hierarchical task. By preserving the contextual integrity of long prompts while applying targeted refinements, it offers a more stable, efficient, and interpretable path toward maximizing LLM performance. Future work will explore extending the framework to multi-lingual prompts and incorporating reinforcement learning to better predict the efficacy of specific Actor actions based on historical optimization trajectories.
Summary updated