SPRIG: Improving Large Language Model Performance by System Prompt Optimization

Lechen Zhang, Tolga Ergen, Lajanugen Logeswaran, Moontae Lee, David Jurgens

TL;DR

Most prompt optimization techniques focus on task-specific instructions, requiring users to generate a new prompt for every single use case. This paper introduces SPRIG, a genetic algorithm that optimizes the system prompt—the overarching, general instructions given to a Large Language Model (LLM). The authors demonstrate that a single, highly optimized system prompt can boost performance across dozens of diverse tasks just as effectively as task-specific prompts. Furthermore, combining both approaches yields state-of-the-art results.

The Problem: Scaling Prompt Optimization

When interacting with an LLM, a prompt typically consists of two parts:

  1. Task Instructions: Specific details about the current job (e.g., "Translate this sentence to French").
  2. System Instructions: General, overarching rules or personas that guide the model's behavior across all turns (e.g., "You are a helpful assistant. Think step-by-step.").

Historically, researchers have focused heavily on automating the optimization of task prompts. However, this approach is exhausting to scale; every new task requires an expensive optimization process to find the best prompt. Meanwhile, system prompts are usually just manually crafted guesses based on human intuition. The authors tackle this gap by asking: Can we systematically discover a single, highly effective, task-agnostic system prompt that generalizes across a massive variety of domains?

Methods: The SPRIG Algorithm

To navigate the massive search space of possible system instructions, the authors propose SPRIG (System Prompt Refinement for Increased Generalization), an edit-based genetic algorithm.

The SPRIG iterative workflow, utilizing a prompt reward model and genetic mutations to optimize system instructions.

The SPRIG process operates through several key steps:

  • The Gene Pool: The researchers built a corpus of 9,000 "prompt components" (single sentences like "Let's think step by step" or "You are a mathematician"). These are categorized into types such as Chain-of-Thought (CoT), Role, Emotion, and Safety.
  • Reward Model: Evaluating thousands of prompts across dozens of benchmarks is computationally prohibitive. To solve this, they fine-tuned a smaller model (Modern-BERT) to act as a "Prompt Reward Model." This model quickly estimates prompt quality, allowing the algorithm to cull the bottom 50% of the population.
  • Mutation & Crossover: The surviving prompts undergo genetic edits. The algorithm might Add a new component, Delete one, Swap their order, Rephrase them, or perform Crossover (combining the best parts of two different prompts).
  • Iteration: A sample of the new generation is evaluated on actual benchmarks. The reward model is then updated with this ground-truth data, and the cycle repeats for 25 iterations.

Evaluation Datasets

To ensure the resulting system prompt was truly generalizable, the authors evaluated it on a massive combination of 42 different benchmarks spanning 7 categories: reasoning, math, social understanding, commonsense, faithfulness, knowledge, and language understanding.

  • Familiar Benchmarks: MMLU, BBH, TruthfulQA, HellaSwag.
  • Social Benchmarks: SocKET (for humor, irony, and empathy detection).
  • Multilingual Generalization: To test if English-optimized prompts worked in other languages, they used datasets like MGSM, Belebele, XCOPA, M3Exam, and M-MMLU.

Key Insights and Ideas

Evolution of prompt components showing a preference for Chain-of-Thought over Roles, and error overlap demonstrating the complementary nature of system and task optimizations.
  • System and Task Optimizations Fix Different Things: One of the most significant findings comes from analyzing which questions the models got right. System prompts and task prompts only overlapped on errors 18% of the time. This proves they are highly complementary rather than redundant.
  • A Shift in the "Global Mindset": By probing the LLM's hidden states using Principal Component Analysis (PCA), the authors found that optimizing a task prompt fine-tunes the model's activations locally. Optimizing the system prompt, however, shifts the model's activations into an entirely new, high-performance global region.
  • "Roles" Are Overrated: Despite the popular advice to tell an LLM "You are an expert mathematician," the genetic algorithm rarely selected Role components. Instead, it heavily favored stacking multiple Chain-of-Thought (CoT) and Behavioral instructions (e.g., "decompose the question," "rephrase before answering").
  • Language Transfer: An English system prompt optimized by SPRIG generalized surprisingly well to multilingual tasks, actually outperforming task-specific optimizers on new languages.

Key Results

  • ~10% Performance Boost: SPRIG improved average performance by about 10% over unoptimized baselines across three mid-sized LLMs (Llama-3.1-8B, Mistral-Nemo, Qwen2.5-7B).
  • Beats Standard CoT: SPRIG significantly outperformed the standard "Let's think step by step" baseline across almost all task types, with the exception of pure knowledge retrieval.
  • State-of-the-Art Combo: Combining a SPRIG-optimized system prompt with a task-optimized prompt (via ProTeGi) achieved the highest overall scores, proving the two methods stack beautifully.

Limitations and Future Work

While SPRIG offers a powerful "once-and-for-all" optimization, it comes with limitations. The upfront compute cost is high, taking about 20 hours on 4 GPUs for a single LLM. Additionally, system prompts exhibit model idiosyncrasies; a prompt optimized for Llama doesn't transfer perfectly to Mistral, and prompts optimized on an 8B model didn't yield significant gains when blindly applied to a 70B model of the same family. Finally, because the algorithm pulls from a corpus of personas and behavioral instructions, there is a risk that the optimized prompt could inadvertently reinforce cultural or social biases present in those components.

Summary updated

BibTeX
@inproceedings{zhang2026sprig,
  author = {Lechen Zhang and Tolga Ergen and Lajanugen Logeswaran and Moontae Lee and David Jurgens},
  title = {{SPRIG: Improving Large Language Model Performance by System Prompt Optimization}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=VdVV24KSWK},
}
Figure