Instances Need More Care: Rewriting Prompts for Instances with LLM s in the Loop Yields Better Zero-Shot Performance (2024)

Abstract: Large language models (LLMs) have revolutionized zero-shot task performance, mitigating the need for task-specific annotations while enhancing task generalizability. Despite its advancements, current methods using trigger phrases such as “Let’s think step by step” remain limited. This study introduces PRomPTed, an approach that optimizes the zero-shot prompts for individual task instances following an innovative manner of “LLMs in the loop”.Our comprehensive evaluation across 13 datasets and 10 task types based on GPT-4 reveals that PRomPTed significantly outperforms both the naive zero-shot approaches and a strong baseline (i.e., “Output Refinement”) which refines the task output instead of the input prompt. Our experimental results also confirmed the generalization of this advantage to the relatively weaker GPT-3.5. Even more intriguingly, we found that leveraging GPT-3.5 to rewrite prompts for the stronger GPT-4 not only matches but occasionally exceeds the efficacy of using GPT-4 as the prompt rewriter. Our research thus presents a huge value in not only enhancing zero-shot LLM performance but also potentially enabling supervising LLMs with their weaker counterparts, a capability attracting much interest recently. Finally, our additional experiments confirm the generalization of the advantages to open-source LLMs such as Mistral 7B and Mixtral 8x7B.

## introduction the advent of large language models (llms) has revolutionized the landscape of natural language processing. these models perform downstream tasks primarily via prompting, which can be categorized into two types, i.e., zero-shot prompting and few-shot in-context learning. in zero-shot zero shot zero-shot cot output refinement prompted prompt output q: prompt output + let's think step by step output prompt prompt output avg. accuracy 40 50 60 70 80 gpt-3.5 gpt-4 zero-shot zero-shot cot output refinement prompted acknowledging the diverse requirements of each test instance, we advocate for instance-level prompt optimization, i.e., rewriting the prompt for each test input in a way that the rewritten prompt can better elicit an llm's capability in solving the specific test instance. to illustrate its promise, we present prompted ( prompted also bears a unique distinction from the widely adopted paradigm of "output refinement", which iteratively refines the task llm's output (as opposed to its input prompt) based on the feedback provided by a meta llm (figure 1 ). an instantiation of this paradigm is "self refinement" @xcite , where the same llm is prompted to give feedback to itself and then iteratively refine its output. this strategy, while useful in fixing local issues (e.g., mathematical inaccuracies or code patches) in the execution output, does not introduce new reasoning paths and thus cannot resolve more substantial issues (e.g., fundamental logical mistakes). to validate the effectiveness of prompted, we evaluate it in 13 benchmark datasets, primarily using @xcite as both the meta and the task llms. our results showed that prompted can significantly improve gpt-4's zero-shot performance compared to the baselines, including the strong baseline of "output refinement", demonstrating the advantage of rewriting the input prompt over refining the llm output. our further analysis revealed that prompted aids the task llm in recalling relevant facts for knowledgeintensive tasks, including domain-specific ones (e.g., medical question answering). it also results in more ethical responses by including proper instructions in the rewritten prompt. particularly notable is prompted's ability to maintain high accuracy levels when applied to the relatively weaker gpt-3.5. an exciting observation is that, when using gpt-3.5 as the meta llm to rewrite prompts for gpt-4 as the task llm, prompted brings on-par or even better performance than using gpt-4 as the meta llm. this result indicates the promise of supervising a stronger llm using a weaker one, and we thus expect our work to pave the way for future research towards enhancing ai for tasks that are beyond human capabilities @xcite . finally, our experiments with mistral @xcite and mixtral @xcite confirmed that the advantages of prompted generalize well to open-source llms and can even perform in a "cross-family" llm setting (e.g., an open-source llm rewrites prompts for a close-source one). ## prompted: improving zero-shot performance of llms with instance-level prompt rewriting 2.1 overview prompted enhances zero-shot llm performance by rewriting the prompt of each test instance in an "llm in the loop" manner (figure 1 ). we term the llm performing the zero-shot task as "task llm" and formally denote it as m task . in the zero-shot setting (step 1), m task produces an output y task to a test input x by sampling from p m task (y task | e||x), where e is a natural language sentence describing the task demand (called "task instruction"), and e||x denotes the concatenation of the task instruction and the test input. in literature, this concatenation is also called a "prompt" to the zero-shot llm, and we denote it as ρ. the task of prompt rewriting targets learning a rewriting function f : ρ → ρ * , such that the rewritten prompt ρ * can yield better zero-shot per-reason: the output is incorrect. the claim (...) depends on how "productivity" is defined in this context. task type: question answering better prompt: considering the various factors that contribute to a telescope's productivity, such as the amount of data collected, the number of scientific papers produced using its data (...) ## related works llms in zero-shot to reduce the manual effort in devising task-specific demonstrations, recent works have been motivated to investigate zero-shot llm prompting and shown its efficacy in reasoning @xcite @xcite ), text classification @xcite , generating goal-driven action plans @xcite , natural language generation (axelsson and skantze, 2023), information extraction @xcite demonstrated that llms such as @xcite , despite being shown to perform few-shot learning quite well, are not very successful in zero-shot in-context learning. to improve the zero-shot reasoning capabilities of llms, @xcite proposed @xcite . however, the usage of such a trigger phrase may encourage harmful responses @xcite . our work contributes to this field by studying approaches for optimizing task prompts in a zero-shot setting. it differs from prior work in optimizing prompts for individual instances with the task llm in the loop. our approach prompted is shown to outperform vanilla zero-shot or zero-shot cot. prompt rewriting and optimization prior works have aimed to optimize prompts to llms via manual rewrite @xcite or gradient-based tuning @xcite . @xcite proposed 26 guiding principles designed to streamline the process of querying and prompting large language models. however, employing these principles in real life may still require trial and error and is unfriendly to users without sufficient expertise. similar to our work, @xcite ; jiang et al. ( 2020) 2023b ) suggested an alternative approach, which optimizes the task output rather than the input prompt. we show that this approach underperforms prompt rewriting, as the latter can more easily direct the reasoning paths of an llm. ## conclusions in this paper, we have proposed a new task of prompt rewriting with (task) llm-in-the-loop at the instance level to improve the zero-shot abilities of llms. we show that optimizing at the instance level aids in generating task-specific hints, induces domain knowledge, and encourages harmless and honest responses. excitingly, we also show that the weaker gpt-3.5 can rewrite prompts for the stronger gpt-4, which shows a huge potential for prompted to be used for oversight. finally, our experiments using open-source llms, including mistral and mixtral, confirmed the generalizability of prompted's advantages.