Towards LLM s Robustness to Changes in Prompt Format Styles (2025)

Abstract: Large language models (LLMs) have gained popularity in recent years for their utility in various applications. However, they are sensitive to non-semantic changes in prompt formats, where small changes in the prompt format can lead to significant performance fluctuations. In the literature, this problem is commonly referred to as prompt brittleness. Previous research on prompt engineering has focused mainly on developing techniques for identifying the optimal prompt for specific tasks. Some studies have also explored the issue of prompt brittleness and proposed methods to quantify performance variations; however, no simple solution has been found to address this challenge. We propose Mixture of Formats (MOF), a simple and efficient technique for addressing prompt brittleness in LLMs by diversifying the styles used in the prompt few-shot examples. MOF was inspired by computer vision techniques that utilize diverse style datasets to prevent models from associating specific styles with the target variable. Empirical results show that our proposed technique reduces style-induced prompt brittleness in various LLMs while also enhancing overall performance across prompt variations and different datasets.

## introduction large language models (llms) are useful for many applications and tasks i.e., content generation, translation, text analysis, etc. one of the popular techniques for adapting pre-trained llms to specific tasks that has emerged in recent years is prompt engineering @xcite @xcite . prompt engineering involves carefully crafting task-specific instructions and a few input-output demonstrations (prompts) to guide llms without changing their parameters @xcite . the popularity of prompt engineering can be attributed to the fact that it does not require labeled data and only needs a few demonstrations in prompts containing few-shot examples @xcite . prompting is also generally computationally cheaper than supervised fine-tuning techniques since the model parameters are not modified @xcite . existing prompting techniques include zero-shot prompting @xcite , few-shot prompting @xcite , chain-of-thought (cot) prompting @xcite , and automatic chainof-thought (auto-cot) prompting @xcite . most research on prompting techniques has focused on identifying or designing good prompts for specific tasks @xcite . however, a key problem often overlooked by these techniques is the sensitivity of llms to meaning-preserving changes in prompts. examples of such changes include adding extra spaces, replacing two colons with one, changing the order of few-shot examples, or varying the choice of fewshot examples @xcite @xcite . this problem is sometimes referred to as prompt brittleness @xcite . prompt brittleness contributes to llms being unreliable and prevents their adoption in high-risk domains such as healthcare. in this work, we focus on style-induced prompt brittleness as illustrated in figure 1 , and propose mixture of formats (mof) to address it. mof is a simple and computationally efficient prompting technique where each few-shot example in the prompt is presented in a distinct style. furthermore, the model is instructed to rewrite each example using a different style, as shown in figure 2 . mof was inspired by ideas from computer vision that involve learning from datasets with diverse styles to prevent models from associating styles with the target variable @xcite @xcite @xcite . we evaluate the effectiveness of mof prompting using datasets from var-ious tasks within supernaturalinstructions @xcite , comparing its performance against traditional prompts. our experiments focus on fewshot prompting, where a traditional prompt refers to a regular few-shot prompt, and a mof prompt is a few-shot prompt that has been converted into the mof style, as demonstrated in figure 2 . ## related work traditional prompt engineering techniques. several prompt engineering techniques have been proposed in recent years. zero-shot prompting is a technique in which a prompt contains a description of the task and no training data is required @xcite . unlike zero-shot prompting, few-shot prompting adds a few input-output demonstrations to the prompt to further help the model understand the task @xcite . both zero-shot and few-shot prompting techniques enable the application of llms on new tasks without extensive training @xcite . for reasoning and logic tasks, prompting techniques that have been proposed include chain-of-thought (cot) @xcite and automatic chain-of-thought (auto-cot) @xcite . cot is a prompting technique that encourages llms to do step-by-step reasoning @xcite . these traditional prompting techniques can be adapted to the mof format by applying differ-ent formatting styles to each prompt example, as demonstrated in figure 2 . in this paper, we focus on the application of mof to few-shot prompting. optimizing for the best prompt. this line of work focuses on optimizing and identifying the most effective prompt for a given task. @xcite propose the automatic prompt engineer (ape), an approach that enables the generation and selection of prompt instructions automatically. ape involves analyzing input queries, generating candidate prompt instructions, and then using reinforcement learning to select the best prompt @xcite . similarly, @xcite propose a method where an llm generates zero-shot outputs for given inputs, followed by selecting high-quality few-shot examples to construct an improved prompt, focusing on consistency, diversity, and repetition. since automatic prompt optimization (apo) methods focus on optimizing instruction or optimizing few-shot examples, @xcite propose a technique to optimize for both, and compare its performance with the performance of techniques that only optimize instructions or examples. @xcite present optimization by prompting (opro), a method that leverages llms as optimizers by describing the optimization task in natural language @xcite . @xcite propose prompt optimization with textual gradients (protegi), which employs text gradients guided by beam search and bandit selection techniques for automatic prompt optimization @xcite . additionally, @xcite introduce dspy, a framework that replaces hard-coded prompt templates with a systematic approach for building language model pipelines. other methods for identifying optimal prompts include @xcite @xcite . unlike existing methods in this area that repeatedly search for optimal prompts per task and model, our goal is to reduce style-induced prompt brittleness using an efficient and straightforward recipe illustrated in figure 2 . quantifying prompt brittleness in llms. several works have shown that llms are sensitive to changes in prompt formats @xcite @xcite and to the order of few-shot examples in the prompt @xcite . @xcite propose formatspread, a method to efficiently measure performance variations in llms caused by prompt format changes, answer : {} for dataset task1186, and tweet:{} , label:{} , answer:{} for dataset task905. these formats are generated using formatspread @xcite , as described in section 3.1. the datasets used are described in by computing the performance difference (spread) between the best-performing format and the worstperforming format. due to the sensitivity of llms to prompt format variations, polo et al. (2024) propose prompteval, an efficient method for evaluating llms on multiple prompts instead of a single prompt. similarly, @xcite propose metrics for multi-prompt evaluation of llms. while these approaches are valuable tools for quantifying prompt brittleness, our proposed method focuses on mitigating it, particularly the brittleness arising from style variations in prompt formats. prompt ensembles. @xcite introduce ask me anything (ama), a prompting approach that transforms inputs into a question-answering format to encourage open-ended responses. ama generates multiple imperfect prompts and combines the responses using a weak supervision strategy to produce the final output @xcite . similarly, @xcite propose template ensembles, an approach that aggregates model predictions across multiple prompt templates. however, both methods are computationally expensive, as they require aggregating predictions from multiple prompts. furthermore, unlike our proposed method, they do not specifically address prompt brittleness caused by style variations in prompt formats. ## mixture of formats style-induced prompt brittleness in llms is similar to problems observed in computer vision, where small changes to an image's style (eg. color or background) can affect the model's ability to make accurate predictions @xcite . in computer vision, various approaches have been developed to address this issue, often involving learning from diverse datasets @xcite @xcite @xcite . the underlying idea is that exposure to diverse data points helps the model disassociate styles from the target variable. drawing inspiration from these techniques, we propose mixture of formats (mof), a novel prompting strategy that deviates from traditional ways of crafting prompts by employing a distinct style format for each few-shot example in the prompt. to further reinforce model understanding, we have the model rewrite the question and answer of each example using a different format style, as illustrated in figure 2 . the effectiveness of this approach is evaluated in the subsequent subsections. ## conclusion and future work addressing prompt brittleness remains a challenge, particularly when caused by changes in prompt format styles. in this work, we introduce a simple and efficient prompting technique, mof, and evaluate its effectiveness in addressing style-induced prompt brittleness. the preliminary results are promising, with significant improvements over traditional prompting in many datasets, as shown in figure 3 . future directions include integrating mof with techniques like chain-of-thought (cot) and automatic prompt engineer (ape), comparing its performance with methods that aggregate results from multiple prompts such as ama @xcite and template ensembles @xcite , and conducting experiments with larger llms like gpt-4, claude 3.5 sonnet, falcon 40b, and llama 3.1 405b. additionally, analyzing mof's failures on certain datasets is a crucial area for further exploration. we hope this work will inspire further research into addressing prompt brittleness in llms, and the code for this project is publicly available on github. 1