Same Question, Different Words: A Latent Adversarial Framework for Prompt Robustness

Tingchen Fu, Fazl Barez

TL;DR

Large language models (LLMs) are surprisingly sensitive to small, semantically equivalent changes in prompts, leading to inconsistent performance. This paper introduces Latent Adversarial Paraphrasing (LAP), a novel framework that trains LLMs to be robust against these prompt variations by optimizing for worst-case paraphrases in a latent adversarial manner. LAP significantly improves worst-case performance without requiring additional paraphrasing data or increasing inference latency.

What Problem Does This Paper Address?

Large language models (LLMs) have shown remarkable capabilities across various tasks. However, a critical issue is their sensitivity to semantically equivalent paraphrases of user queries. Even minor rephrasing can lead to significant performance degradation, making their real-world deployment unreliable. Existing solutions either rely on tedious prompt engineering or computationally expensive inference-time algorithms, which are not practical for general users. This paper aims to address this "prompt robustness" problem, specifically focusing on query paraphrasing, by making LLMs inherently more resilient to such variations.

Methods

The core of the proposed solution is the Latent Adversarial Paraphrasing (LAP) framework. LAP builds upon the idea of Latent Adversarial Training (LAT), which involves a bi-level optimization process.

Here's how LAP works:

  • Dual-Loop Architecture: LAP employs an inner loop and an outer loop.
  • Inner Loop (Perturbation Optimization):
    • It introduces a trainable perturbation ($\delta$) into the hidden layers of the LLM. This perturbation acts as a "continuous paraphrase" in the latent space.
  • The perturbation is optimized to maximize the embedding distance between the original query's representation and the perturbed representation. The intuition here is that worst-case paraphrases tend to have larger embedding distances.
  • Crucially, LAP adds a constraint to ensure that this perturbation doesn't significantly increase the language modeling loss. This is based on the insight that semantic-preserving paraphrases shouldn't drastically worsen performance.
  • This inner loop uses a Lagrangian multiplier ($\lambda$) to convert the constrained optimization problem into an unconstrained one, allowing for dynamic adjustment of the constraint.
  • Outer Loop (LLM Optimization):
    • Once the perturbation is optimized, it's fixed.
  • The LLM's parameters ($\theta$) are then optimized to minimize the language modeling loss with the perturbed input. This makes the LLM more robust to the specific perturbation found in the inner loop.
  • Supervised Fine-Tuning (SFT): The framework also incorporates standard SFT on instruction-following data, ensuring that the model retains its general capabilities.

The key novelty lies in LAP's ability to synthesize a worst-case perturbation in the latent space and train the LLM against it, rather than relying on finding or generating explicit textual paraphrases.

Datasets

  • RobustAlpaca: Used for evaluation. This benchmark contains 100 cases, each with an original user query and 10 semantic-preserving paraphrases.
  • UltraFeedback (chosen completion): Used for fine-tuning the LLM backbones. This is a pair-wise preference dataset.
  • UltraFeedback (augmented paraphrases): Used by a baseline method (Data Augmentation) to synthesize paraphrases for training.

Key Insights and Ideas

  • Embedding Distance as an Indicator: The paper's key insight is that worst-case paraphrases exhibit a larger Euclidean distance in the model's hidden embedding space compared to the original prompt, even when semantically equivalent. This distance serves as a crucial indicator for identifying problematic paraphrases.
  • Latent Adversarial Paraphrasing: Instead of generating explicit textual paraphrases, LAP creates "continuous paraphrases" in the latent space. This allows for more fine-grained control and optimization against worst-case scenarios.
  • Balancing Robustness and Performance: The framework carefully balances adversarial training (to improve robustness) with standard supervised fine-tuning (to maintain general performance). The constraint on language modeling loss is vital for ensuring semantic preservation.
  • Agnosticism to Model Architecture: LAP is designed to be model-agnostic and can be applied to various pre-trained auto-regressive language models.

Key Results

  • Improved Worst-Case Win-Rate: LAP achieved a 0.5%–4% absolute improvement in worst-case win-rate on the RobustAlpaca benchmark across multiple backbones (Llama-3-8b, Mistral-7b-v0.3, Llama-2-13b).
  • Competitive Original and Average Win-Rates: LAP also obtained the best or second-best results for original and average win-rates, demonstrating that robustness enhancement does not come at the cost of overall performance.
  • Outperforming Baselines: LAP generally outperformed other training algorithms (SFT, Data Augmentation, Prompt Consistency, LAT) and inference-time algorithms (USC, Self-Refinement, Mixture-of-Agents) in terms of worst-case performance.
  • Scalability: The framework showed effectiveness on larger backbones like Llama-2-13b.
  • Perturbation Position Insensitivity: The effectiveness of LAP was relatively insensitive to the specific transformer layer chosen for perturbation insertion, though layers 12 and 20 showed slightly better results.

Limitations and Future Work

  • Modality: The current work focuses on text modality. Future work could explore prompt robustness for large vision-language models and other modalities.
  • PEFT Techniques: The study primarily used LoRA for parameter-efficient fine-tuning. Experiments with other PEFT techniques (e.g., adapter, IA3) or full-parameter fine-tuning were not conducted.
  • Multi-Layer Perturbation: The current LAP inserts perturbation into a single layer. Future work could investigate multi-layer perturbation.
  • Ethical Considerations: While LAP enhances reliability, it could also make models more consistently capable of harmful outputs if misused. The authors suggest further research into refining adversarial training techniques for enhanced model resilience.
  • Multi-Turn Dialogues: The applicability of LAP to multi-turn dialogues is an area for future exploration.

Summary updated

BibTeX
@inproceedings{fu2025same,
  author = {Tingchen Fu and Fazl Barez},
  title = {{Same Question, Different Words: A Latent Adversarial Framework for Prompt Robustness}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure