TL;DR
Automated prompt optimization methods often produce bloated prompts that overfit to training data by accumulating narrow, case-specific rules. TextReg introduces a text-space regularization framework that penalizes prompt length and rule narrowness, significantly boosting out-of-distribution (OOD) generalization across complex reasoning tasks.
What Problem Does This Paper Address?
When large language models (LLMs) optimize prompts iteratively based on feedback, they tend to act like overzealous software developers writing ad-hoc patches. Instead of discovering compact, general principles, the optimizer appends specific rules to fix individual training errors (e.g., "if the input mentions tomatoes, count them as vegetables").
The authors define this failure mode as prompt distributional overfitting. It manifests along two coupled dimensions:
- Capacity Cost: Prompts grow excessively long, consuming the model's context budget and making it harder to locate relevant instructions.
- Scope Narrowness: The rules become highly specific to the training sample distribution, failing catastrophically when evaluated on out-of-distribution (OOD) data.
To solve this, the paper introduces the concept of Representational Inefficiency—a metric that multiplies capacity cost by scope narrowness—and proposes a method to constrain it during discrete text-space optimization.
Methods
The authors propose TextReg, a regularization framework that mimics soft-penalty objectives used in classical machine learning (like weight decay or LASSO) but operates entirely within discrete text space. It breaks down prompt updates into three distinct stages:
- Dual-Evidence Gradient Purification: Before a raw feedback gradient is applied, it is filtered using two sources of evidence. Local case evidence checks if the rule is too specific to the current mini-batch. Global recurrence evidence checks a "RuleBank" (a cross-step memory of accepted rules) to see if this principle has repeatedly appeared. If a rule is purely stylistic or too narrow, it is discarded.
- Semantic Edit Regularization (SER): This stage acts as a textual regularization gradient generator ($g_{reg}$). It uses an LLM as a "semantic diff analyzer" to compare the current prompt with the previous version. If the edit caused an unnecessary increase in length or a narrowing of rule scope, it synthesizes a natural-language directive to compress or generalize the prompt.
- Regularization-Guided Prompt Update: The optimizer generates a set of task-faithful candidate prompts. TextReg then selects the candidate that is most compatible with the regularization gradient ($g_{reg}$), biasing the prompt evolution toward compact and broadly applicable instructions.
Datasets
The framework was evaluated on nine reasoning datasets spanning symbolic and arithmetic domains:
- Big-Bench Hard (BBH): Logical Deduction and Tracking Shuffled Objects. Prompts were optimized on simpler 3-object variants and evaluated OOD on harder 5-object and 7-object variants.
- Arithmetic Benchmarks: Optimized on GSM8K (grade-school math) and evaluated for cross-dataset generalization on SVAMP and MultiArith.
Key Insights and Ideas
- Overfitting is Structural: Prompt overfitting isn't just an optimization quirk; it's a structural failure where prompt length and rule narrowness amplify each other.
- Textual Differentiation: You don't need continuous, differentiable parameters to regularize. By treating prompt changes as finite differences and using an LLM to analyze the "semantic delta," you can effectively calculate a regularization gradient in pure text.
- Lightweight Models Can Regularize: A resilience study revealed that even when the regularization and optimization roles were downgraded from GPT-4o to a much weaker model (Qwen2.5-7B-Instruct), TextReg retained strong performance. This indicates that the regularization signal is structural and robust, rather than entirely dependent on high-tier LLM capabilities.
Key Results
TextReg consistently outperformed standard prompt optimization methods like TextGrad and REVOLVE across multiple downstream test engines (Qwen2, Llama-3, Llama-3.1, and Phi-3.5):
- Substantial OOD Gains: TextReg achieved accuracy gains of up to +11.8% over TextGrad and +16.5% over REVOLVE on the hardest tracking and logic tasks.
- Preventing Performance Degradation: On certain models like Phi-3.5, unregularized baselines actually degraded performance below a simple zero-shot Chain-of-Thought (CoT) baseline due to severe overfitting. TextReg successfully preserved and extended the generalization benefits of CoT.
Limitations and Future Work
Currently, TextReg is optimized for single-turn reasoning tasks that rely on well-defined behavioral rules. The authors note that extending this framework to open-ended generation, multi-turn conversational prompts, and autonomous agent instructions remains an open challenge, as rule structures blur and capacity costs are shared dynamically across multiple turns.
Summary updated