Abstract
Automatic Prompt Engineering (APE) typically employs global optimization strategies, treating entire prompts as monolithic blocks for mutation. This approach often fails on complex, "production-grade" prompts where expert-written logic must be preserved and the search space is prohibitively large. We present Local Prompt Optimization (LPO), a modular framework that identifies specific problematic tokens for targeted editing. LPO significantly reduces the optimization search space and improves performance across diverse benchmarks, including a 6% accuracy increase on an 8,000-token production prompt.
Introduction
The performance of Large Language Models (LLMs) is highly contingent on prompt phrasing. While APE frameworks have automated the search for optimal instructions, they generally rely on Global Optimization. This method mutates the entire prompt, which is inefficient for long sequences and can inadvertently destroy critical safety guardrails or expert logic. LPO addresses these issues by focusing the optimization "gradient" on the specific parts of the prompt that contribute to errors.
Methods
LPO introduces a two-stage "Prompt Proposal" process within the standard APE loop. First, an Identification step uses a meta-prompt to analyze failure cases and mark problematic tokens with <edit> tags. Second, a Local Mutation step instructs the optimizer LLM to propose changes only for the tagged tokens, keeping the rest of the prompt static. This approach effectively reduces the search space to a few words rather than the entire prompt vocabulary.
Results
Evaluation across mathematical (GSM8k, MultiArith) and general reasoning (BIG-bench Hard) tasks demonstrates that LPO consistently outperforms global methods. Notably, LPO is "plug-and-play," enhancing existing frameworks like APE, APO, and PE2.
In a real-world application involving an 8,000-token production prompt for tool orchestration, LPO achieved a 6% improvement in accuracy, where global methods struggled due to the prompt's complexity. Furthermore, LPO exhibits faster convergence, reaching optimal performance in fewer iterations than global counterparts.
Discussion and Limitations
While LPO offers significant precision and efficiency gains, it currently focuses on English-language prompts. Future work should explore its cross-lingual applicability. Additionally, the high precision of LPO can lead to overfitting on small development sets, necessitating robust search strategies to ensure generalization. Finally, the effectiveness of the identification step currently relies on high-performing models like GPT-4o; the performance of smaller, open-source models in this role remains to be fully explored.
Conclusion
Local Prompt Optimization represents a shift from "black-box" prompt rewriting to a more interpretable and controlled engineering process. By focusing on local edits, LPO enables the optimization of massive production prompts while maintaining the integrity of expert-designed instructions.
Summary updated