Stabilizing Black-Box Prompt Optimization with Textual Regularization and Signal Aggregation
About
An increasing number of NLP applications interact with large language models (LLMs) through black-box APIs, making prompt engineering critical for controlling model behavior. Recent Automatic Prompt Optimization (APO) methods iteratively refine prompts using model-generated critiques (often called textual gradients), but they predominantly optimize from failures and underutilize information contained in correct predictions, leading to instability and semantic drift. We propose TRAS (Textual Regularization with Aggregated Signals), a feedback-centric framework that is plug-and-play with existing APO search backbones. It retains the standard textual gradient signal from prior work for error correction and introduces a complementary textual regularizer derived from successful predictions to preserve beneficial prompt components. Because both signals are stochastic and can be noisy, we further introduce Monte Carlo Signal Aggregation (MCSA), which samples multiple gradients or regularizers and aggregates them into a single actionable directive, emphasizing consistent, actionable advice while filtering out outliers. Motivated by rapid model churn, we also formalize Automatic Prompt Migration (APM), the practical problem of adapting an expert prompt across model versions or API providers without losing critical instructions. Across standard APO and APM scenarios, our approach consistently outperforms strong baselines, yielding higher accuracy, faster convergence, and lower query cost, while substantially reducing the degradation observed under naive prompt migration.
Related benchmarks
| Task | Dataset | Result | Rank | |
|---|---|---|---|---|
| Causal Reasoning | Causal Judgment | Final Accuracy76.4 | 4 | |
| Geometric Reasoning | Geometric Shapes | Final Accuracy84.5 | 4 | |
| Logical reasoning | Penguins | Final Accuracy98 | 4 | |
| Natural Language Inference | CB | Final Accuracy87.5 | 4 | |
| Prompt Optimization | Causal Judgment | Accuracy64.4 | 4 | |
| Prompt Optimization | Geometric Shapes | Accuracy63.3 | 4 | |
| Prompt Optimization | Penguins | Accuracy68.6 | 4 | |
| Prompt Optimization | BIOSSES | Accuracy70.4 | 4 | |
| Prompt Optimization | CB | Accuracy85.7 | 4 |