Abstract
System Prompt Optimization (MetaSPO) is a novel meta-learning framework designed to automate the creation of robust, transferable system prompts for Large Language Models (LLMs). By framing prompt design as a bilevel optimization problem, MetaSPO develops foundational instructions that synergize with task-specific user prompts. Experimental results across 34 tasks in five domains—including medical, reasoning, and safety—demonstrate that MetaSPO significantly enhances model performance on unseen tasks. Notably, the framework enables rapid adaptation to new domains with 75% less data and 80% fewer optimization iterations compared to standard baselines.
1. Introduction
The performance of Large Language Models (LLMs) is highly sensitive to the instructions provided in the prompt. These instructions are generally divided into two categories: the system prompt, which establishes high-level behavioral constraints and personas, and the user prompt, which defines the specific task at hand.
While significant research has focused on automating user prompt engineering (e.g., Automatic Prompt Engineer or OPRO), the system prompt has remained largely manual or generic. This represents a significant oversight, as the system prompt serves as the "operating system" for the model's reasoning process. MetaSPO addresses this gap by treating the system prompt as a meta-instruction set that can be optimized to improve performance across a wide distribution of tasks.
2. Methodology: MetaSPO Framework
MetaSPO utilizes a bilevel optimization strategy to decouple task-specific refinements from general behavioral improvements.
2.1 The Inner Loop: Task-Specific Optimization
The inner loop focuses on optimizing user prompts for specific tasks. When a model fails a task, an "optimizer LLM" performs a failure analysis to diagnose the root cause of the error. Based on this analysis, the system generates refined candidate user prompts designed to maximize performance on that specific task instance.
2.2 The Outer Loop: Meta-Learning Optimization
The outer loop is responsible for optimizing the system prompt. Rather than looking at individual tasks, it aggregates failure data from the entire task distribution explored in the inner loop. The optimizer LLM then rewrites the system prompt to provide better foundational guidance. This process allows the system prompt to capture "meta-knowledge"—high-level strategies such as "always check for logical contradictions" or "cite relevant principles"—that apply across multiple domains.
3. Experimental Evaluation
The researchers evaluated MetaSPO using 34 tasks across five distinct domains:
- Medical: MedMCQA.
- Review Analysis: Amazon sentiment prediction.
- Reasoning: BigBench analytical tasks.
- Safety: Anthropic Harmless and Ethos.
- Grounding: SQuAD and HotpotQA.
The framework was optimized using four source tasks per domain and subsequently tested on 14 entirely unseen target tasks to measure generalization.
4. Key Results and Discussion
4.1 Generalization and Efficiency
MetaSPO consistently outperformed baselines, including manual Chain-of-Thought (CoT) and automated methods like SPRIG. In test-time adaptation scenarios, MetaSPO reached baseline performance levels using 75% less data and 80% fewer iterations, highlighting its efficiency in low-resource settings.
4.2 Synergy and Robustness
A key finding is the "synergy effect": MetaSPO-optimized system prompts are specifically tuned to work with optimized user prompts. Furthermore, these system prompts increase the model's resilience to "bad" or unoptimized user prompts. Analysis of internal model states showed that LLMs allocate more attention to system prompt tokens when using MetaSPO, indicating that the instructions are more actionable.
4.3 Cross-Model Transferability
The meta-knowledge captured in the system prompts proved to be model-agnostic. Prompts optimized on Llama 3.2 showed significant performance gains when applied to other models, such as Qwen 2.5 and GPT-4o mini, suggesting that the learned strategies reflect fundamental improvements in instruction following.
5. Conclusion
MetaSPO represents a significant step forward in automated prompt engineering by focusing on the foundational role of the system prompt. By leveraging bilevel optimization, the framework creates instructions that are robust, efficient, and transferable across models and domains. Future work will focus on reducing the computational overhead of the meta-training phase and exploring distillation techniques for smaller models.
Summary updated