Introduction
Prompt engineering has emerged as a critical, albeit poorly understood, discipline in the era of Large Language Models (LLMs). While practitioners often debate the merits of specific formatting or polite phrasing, these choices are frequently arbitrary. This research investigates the "reliability" of LLM responses under semantic-preserving variations—non-functional changes that do not alter the core meaning of a task. The study reveals a startling "butterfly effect": even the smallest perturbations, such as adding a trailing space or a greeting, can cause models to flip their predictions on simple classification tasks.
Methodology
The researchers conducted a systematic stress test of four prominent models: ChatGPT (gpt-3.5-turbo-1106) and the Llama 2 family (7B, 13B, and 70B). They applied 24 distinct prompt variations across 11 diverse text classification benchmarks, including reasoning (BoolQ, MathQA), sentiment analysis (IMDBSentiment), and toxicity detection (Jigsaw Toxicity).
To isolate the effect of the prompts, the models were set to a deterministic mode (temperature 0). The variations were categorized into four groups:
- Output Formats: Requesting answers in JSON, CSV, XML, YAML, or Python lists.
- Minor Perturbations: Adding leading/trailing spaces or greetings (e.g., "Hello," "Howdy").
- Tipping: Offering financial incentives for "perfect" responses.
- Jailbreaks: Utilizing templates like "AIM" or "Dev Mode v2" designed to bypass safety filters.
The Fragility of Output Formatting
Forcing an LLM to adhere to a specific data structure is a common requirement for automated pipelines. However, this study found that requesting a specific format generally degrades accuracy compared to free-form text. More importantly, changing the requested format caused a minimum of 10% of predictions to change across all models tested.
As shown in Figure 1, formats like JSON and YAML induce significant instability. This suggests that the tokenization and probability distributions of these models are highly sensitive to the structural overhead of the requested output format.
The Hidden Cost of Jailbreaks and Social Cues
The most dramatic performance shifts occurred when using "jailbreak" prompts. While these are often used to ensure a model doesn't refuse a sensitive topic, they frequently "lobotomize" the model's reasoning capabilities. For ChatGPT, the "AIM" jailbreak caused accuracy to plummet from a baseline of ~79% to just 6.3%, often resulting in a refusal rate of nearly 90% even on benign classification tasks.
Figure 2 illustrates that even "invisible" changes, like adding a single space, caused over 500 prediction flips in ChatGPT. Interestingly, the study also identified a "Tipping Paradox": while promising a small tip ($1-$100) improved accuracy for the smallest model (Llama 2-7B), "over-tipping" ($1000) led to performance degradation. Larger models remained largely indifferent to these social incentives.
Key Insights and Robustness
The research highlights several critical takeaways for prompt engineers:
- Robustness Scales with Size: Larger models, such as Llama 2-70B, demonstrated greater resilience to minor perturbations than their smaller counterparts, suggesting that increased capacity helps models ignore spurious correlations.
- Politeness is Not Neutral: Using Multidimensional Scaling (MDS), the authors found that variations like "Thank you" or greetings clustered far from the baseline in the models' representation space, indicating they are perceived as distinct semantic shifts rather than neutral additions.
- Format Constraints Hurt: The "No Specified Format" baseline consistently yielded the highest accuracy, suggesting that practitioners should only enforce formatting when strictly necessary.
Conclusion
LLMs are powerful but incredibly fragile. The fact that a single space or a polite greeting can flip a model's decision raises significant concerns about using these models as stable labeling or reasoning tools. Future development must focus on "prompt-resilient" training, ensuring that models can maintain objective performance regardless of the social or structural wrapper used to deliver the prompt.
Summary updated