Beyond Magic Words: Sharpness-Aware Prompt Evolving for Robust Large Language Models with TARE

Guancheng Wan, Lucheng Fu, Mengting Li · DOI

Abstract

Prompt engineering for Large Language Models (LLMs) often suffers from extreme brittleness, where minor linguistic variations lead to significant performance drops. This paper introduces TARE (Textual Sharpness-Aware Evolving) and its adaptive variant ATARE, frameworks designed to optimize prompts by minimizing "textual sharpness." By seeking "flat minima" in the semantic prompt landscape, these methods discover robust prompts that maintain high accuracy across diverse paraphrases. Evaluations on benchmarks like GSM8K and Big-Bench Hard demonstrate that TARE-optimized prompts significantly outperform traditional accuracy-only optimization methods in both performance and stability.

Introduction: The Problem of Prompt Brittleness

Current prompt optimization techniques primarily focus on point-wise accuracy—finding a specific string that maximizes performance on a given dataset. However, these "magic words" are often fragile. A single synonym change or a slight shift in phrasing can cause an LLM's accuracy to plummet. This phenomenon is characterized as textual sharpness.

Conceptual comparison between sharp and robust prompt landscapes, illustrating how slight semantic changes can lead to dramatic loss increases in non-robust prompts.

As shown in the figure above, a "sharp" prompt (Prompt A) might achieve zero loss, but a slight semantic change (Prompt A') leads to a dramatic loss increase. In contrast, a "robust" prompt (Prompt B) sits in a flatter region of the landscape where neighbors (Prompt B') maintain similar performance.

Methodology: TARE and ATARE

To address this, we propose a derivative-free, black-box optimization framework that prioritizes landscape flatness alongside accuracy.

Textual Sharpness-Aware Evolving (TARE)

TARE operates through a two-stage iterative loop:

  1. Inner Adversarial Search: The system generates "hard" paraphrases of the current prompt to identify the worst-case scenario within a semantic neighborhood.
  2. Outer Robust Selection: The prompt is updated not just to improve its own accuracy, but to ensure that its "worst-case neighbor" also performs well. This encourages the optimizer to move toward flatter regions of the semantic space.

Adaptive TARE (ATARE) and Anisotropy

Recognizing that different components of a prompt (e.g., style vs. core constraints) have varying sensitivities, we introduce ATARE. This version utilizes Anisotropic Search, which learns to weight prompt components differently. By identifying high-sensitivity areas, the generator can perturb sensitive parts cautiously while exploring more robust components broadly.

The TARE and ATARE frameworks, detailing the inner adversarial search, feedback generation, and outer robustness updates using a Landscape-Aware Textual Optimizer (LATO).

The optimization is driven by the Landscape-Aware Textual Optimizer (LATO), which uses the gap between a prompt and its worst neighbor to steer the search toward more robust semantic basins.

Key Results and Insights

  • Superior Performance: TARE and ATARE consistently outperformed state-of-the-art optimizers like TextGrad and Revolve. For instance, on the "Tracking Shuffled Objects" task with Llama 3 8B, ATARE achieved 67.7% accuracy compared to TextGrad's 55.5%.
  • Paraphrase Invariance: Prompts discovered via TARE maintained stable performance even when subjected to heavy paraphrasing, whereas accuracy-only methods saw significant degradation.
  • Anisotropy Matters: Treating prompt components as distinct layers (Constraint, Method, Style) allows for more efficient and effective optimization.
  • Scalability: The framework remains effective even when using smaller models (e.g., Llama 3.1 8B) as the optimizer for larger target models.

Conclusion and Future Work

TARE moves prompt engineering from a search for "magic words" to a search for robust semantic regions. While computationally more intensive due to neighborhood evaluations, the resulting prompts are significantly more reliable for production environments. Future research will explore the application of these techniques to multi-turn conversations and tool-augmented settings like Retrieval-Augmented Generation (RAG).

Summary updated

BibTeX
@inproceedings{wan2026beyond,
  author = {Guancheng Wan and Lucheng Fu and Mengting Li},
  title = {{Beyond Magic Words: Sharpness-Aware Prompt Evolving for Robust Large Language Models with TARE}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=YEBDvqsniH},
}
Figure