Abstract
Prompt engineering is pivotal in harnessing the capabilities of large language models (LLMs) for diverse applications. While existing prompt optimization methods enhance prompt effectiveness, they often induce prompt drifting, where newly generated prompts may detrimentally affect previously successful cases while correcting failures. Moreover, these methods heavily rely on LLMs’ intrinsic capabilities for prompt optimization tasks. In this paper, we introduce STRAGO (Strategic-Guided Optimization), a novel approach that mitigates prompt drifting by leveraging both successful and failed cases to identify critical factors to achieve the objectives. Furthermore, STRAGO adopts a how-to-do approach, integrating in-context learning to develop specific, actionable strategies that offer detailed, step-by-step guidance for prompt optimization. Extensive experiments across various tasks—such as reasoning, natural language understanding, domain-specific knowledge, and industrial applications—demonstrate STRAGO’s superior performance. It sets a new state-of-the-art in prompt optimization, showcasing its capability to deliver stable and effective prompt improvements.
Introduction
Prompt engineering has become a cornerstone of effective interaction with Large Language Models (LLMs). However, the manual refinement of prompts is often tedious and inconsistent. Automatic prompt optimizers have emerged to address this, yet they face two significant challenges:
- Prompt Drifting: Most existing optimizers focus exclusively on correcting errors. In doing so, they often introduce new instructions that inadvertently break the logic responsible for previously successful outputs. This "one step forward, two steps back" phenomenon is known as prompt drifting.
- Lack of Actionable Guidance: Methods like Automatic Prompt Optimization (APO) or Optimization by PROmpting (OPRO) typically rely on the LLM's internal "black box" logic to improve based on raw feedback. They lack a structured "how-to" methodology, which is critical for complex, domain-specific tasks where simple reflection is insufficient.
To overcome these hurdles, we propose STRAGO (Strategic-Guided Optimization), a framework designed to stabilize and enhance the prompt optimization process through strategic, step-by-step guidance.
Methodology: The STRAGO Pipeline
STRAGO moves beyond simple trial-and-error by implementing a structured three-stage pipeline that emphasizes learning from both success and failure.
1. The Analyzer
Unlike traditional methods that only sample failed cases, the Analyzer examines both successful and failed examples. It extracts "positive experiences" (identifying what worked) and "negative experiences" (identifying what went wrong). This dual perspective ensures the optimizer understands the boundaries of success, preventing it from disrupting effective logic.
2. The Refiner
The Refiner is the core innovation of STRAGO. It uses in-context learning to transform extracted experiences into actionable strategies—detailed, step-by-step execution plans. To maintain high quality, a separate "judge" model (such as Claude) scores these strategies based on clarity and feasibility, filtering out suboptimal guidance.
3. The Optimizer
The final stage employs an evolutionary approach. It generates revised prompts based on the refined strategies. It then performs a Crossover operation, combining elements from success-based and failure-based prompts, followed by a Paraphrase step to ensure the final prompt is polished and coherent.
Experimental Setup
We evaluated STRAGO across a diverse set of benchmarks to test its versatility:
- Reasoning: Big-Bench Hard (BBH) subtasks including logical deduction and movie recommendation.
- Natural Language Understanding (NLU): SST-5 (sentiment analysis) and TREC (question classification).
- Domain-Specific Knowledge: MedQA and MedMCQA (medical license exam questions).
- Industrial Application: A Personalized Intent Query task using real-world search data to determine if search results should be reordered based on user history.
Results and Discussion
STRAGO establishes a new state-of-the-art (SOTA) across all evaluated benchmarks, demonstrating both superior accuracy and stability.
Superior Accuracy and Stability
As shown in the results table, STRAGO consistently outperforms baselines like OPRO and EvoPrompt. Notably, it achieved 79.77% on BBH and 87.21% on TREC, outperforming previous methods by significant margins. In knowledge-intensive medical tasks, where other optimizers often stalled or degraded performance, STRAGO saw gains exceeding 1.2%.
A key metric in our study was the Adverse Correction Rate (ACR)—the percentage of previously correct cases that became incorrect after optimization. STRAGO consistently demonstrated the lowest ACR, proving its effectiveness in mitigating prompt drifting.
Efficiency and Strategic Guidance
One of the most significant findings is STRAGO's efficiency. By providing clear "strategic guidance" rather than raw error feedback, the model converges much faster. For instance, in the TREC task, STRAGO reached an 80% score in just 10 iterations, whereas the APO baseline required over 90. This suggests that actionable strategies unlock latent LLM capabilities that simple reflection cannot reach.
Conclusion
STRAGO represents a significant advancement in prompt optimization by introducing strategic guidance and dual-experience learning. While the multi-stage pipeline increases token consumption and benefits most from high-tier models like GPT-4, the resulting stability and performance gains are substantial. Future work will explore expanding the search space and further optimizing the computational efficiency of the strategy refinement process.
Summary updated