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 Model (LLM) applications grow in complexity, prompts have evolved from simple instructions into massive documents often exceeding 2,000 words. These "long prompts" typically include nested instructions, few-shot examples, and strict formatting constraints. Existing automatic prompt optimization (APO) methods, such as OPRO or ProTeGi, treat prompts as flat text sequences. This approach often leads to significant information loss when the system attempts to rewrite a long prompt from scratch, causing the model to "forget" critical constraints. Furthermore, the inherent sensitivity of LLMs to small perturbations makes flat-text optimization unstable in complex contexts.
Methodology
SCULPT addresses these limitations by introducing Prompt Structuring, which transforms flat text into a hierarchical tree structure using Markdown headings as delimiters. This allows the system to isolate specific sections—such as "Instructions," "Examples," or "Output Format"—as distinct nodes for targeted refinement.
The optimization process follows a Critic-Actor architecture:
- Critic Module: Analyzes incorrect predictions and the prompt tree to generate Structural Reflections (identifying clarity issues) and Error Reflections (linking failures to specific nodes).
- Aggregation: Reflections are clustered to identify common error patterns and prevent overfitting to individual examples.
- Actor Module: Instead of a total rewrite, the Actor applies a toolbox of 8 structured actions, such as Node Merging, Example Refinement, or Structural Reordering, to modify the tree.
- Search Strategy: SCULPT employs Beam Search combined with an Upper Confidence Bound (UCB) algorithm to efficiently explore the prompt space while minimizing API costs.
Experimental Results
SCULPT was evaluated across diverse benchmarks requiring long prompts, including Big-Bench Hard (BBH), Responsible AI (RAI) safety tasks, and multi-label classification (GoEmotions).
Performance and Robustness
SCULPT consistently outperformed state-of-the-art baselines like OPRO and ProTeGi. On the GoEmotions dataset, it achieved a performance gain of over 10% compared to initial human-written prompts. The framework also demonstrated remarkable robustness; when subjected to adversarial perturbations (e.g., misspellings or translations), SCULPT was significantly more effective at recovering original performance levels than flat-text optimizers.
Information Preservation and Stability
A key advantage of SCULPT is its ability to maintain the integrity of the original task. Quantitative analysis using metrics like Semiotic Dissimilarity and Information Preservation shows that SCULPT applies more stable and meaningful modifications compared to baselines, which often "hallucinate" entirely new prompt structures that deviate from the intended task.
Efficiency
By refining a single structured prompt rather than concatenating multiple previous versions, SCULPT reduced computational costs by approximately 50% compared to ProTeGi while achieving superior results. The resulting prompts also proved to be model-agnostic, showing strong transferability from GPT-4o to other models like Llama-3.1-8B.
Conclusion
SCULPT represents a shift from "vibe-based" prompt engineering to a systematic, structural optimization process. By treating prompts as hierarchical trees, it enables surgical refinements that preserve essential context while improving performance and reducing costs. Future work will explore expanding the framework to multi-lingual prompts and integrating memory-based components to learn meta-strategies for optimization over time.
Summary updated