MAPO : Boosting Large Language Model Performance with Model-Adaptive Prompt Optimization (2023)

Abstract: Prompt engineering, as an efficient and effective way to leverage Large Language Models (LLM), has drawn a lot of attention from the research community. The existing research primarily emphasizes the importance of adapting prompts to specific tasks, rather than specific LLMs. However, a good prompt is not solely defined by its wording, but also binds to the nature of the LLM in question. In this work, we first quantitatively demonstrate that different prompts should be adapted to different LLMs to enhance their capabilities across various downstream tasks in NLP. Then we novelly propose a model-adaptive prompt optimizer (MAPO) method that optimizes the original prompts for each specific LLM in downstream tasks. Extensive experiments indicate that the proposed method can effectively refine prompts for an LLM, leading to significant improvements over various downstream tasks.

## introduction advancements in large language models (llms) have ushered in a transformative era in natural language processing, showcasing their remarkable capabilities across a wide range of tasks @xcite . while these models possess human-like comprehension and response abilities, their performance is heavily influenced by the quality of prompts. as can be observed in fig. 1 , answers from different llms vary widely when they are provided with the same task-specific prompts. therefore, it is necessary to generate prompts that are most suitable for each llm, thereby enhancing its performance on downstream tasks. a common practice towards prompt optimization is to count on human expertise @xcite @xcite ## empirical study in this section, we conduct empirical study on three llms (bloom-7b @xcite , gpt-j-6b @xcite , and llama-7b @xcite ) to evaluate their separate performance on question-answering (qa), classification, and generation tasks with same task-specific prompts. we use nine dataset from p3 @xcite covering three downstream tasks with details in appendix e. p3 is a widely-used prompt benchmark which contains original prompts and the corresponding ground-truth answers. we adopt f1 score, accuracy and rouge-l for qa, classification, and generation tasks, respectively. the visualization results are shown in the fig. 2 . from the violin plot, we observe significant variations in distribution among different llms in each task. for example, in the generation task, the results of all three models are distributed within the range of 0 to 0.5, but there are still differences in the specific distribution patterns. moreover, the medians, means, and other statistical measures also differ greatly among three llms in each downstream task. therefore, we consider that finding the optimal prompt for each specific llm on each task is meaningful, as it can help enhance the llms' performance on various downstream tasks. ## methods based on the above empirical study, we present mapo, a model-adaptive prompt optimization approach for llms. it takes the original prompt as input and generate an optimized prompt which makes an llm give better outputs. the framework of mapo is shown in fig. 3 . ## related work llms' prompt optimization process involves prompt retrieval, prompt generation from scratch and prompt editing. for prompt retrieval, for example, @xcite adopt greedy search to identify near-optimal prompts. zhou et al. (2022) introduce ape for automatic instruction selection, etc. for prompt generation from scratch, pang et al. (2023) introduce sharpt, which learns a shared latent space and generates soft prompts. white et al. (2023) describe a catalog of prompt engineering techniques. zamfirescu-pereira et al. (2023) investigate end-user prompt engineering using a prototype llm-based chatbot design tool. wang et al. (2022a) present self-instruct for improving instruction-following capabilities of plms. for prompt editing, gao et al. (2020) automatically select label words and generate templates. pryzant et al. (2023) introduce apo based on "gradients" to provide critical feedback on the current prompt. deng et al. (2022) propose rlprompt based on rl. zhang et al. (2023) propose tempera, which provides interpretable prompts for different queries. prasad et al. (2022) introduce grips, a gradientfree approach for improving task instructions for llms. moreover, some research focuses on incor-porating additional knowledge to enhance prompt editing. for example, li et al. (2023) propose dsp to generate "directional stimulus" of each input. qin and eisner (2021a) optimize a mixture of prompts using gradient descent to generate relational knowledge. shin et al. (2020) develop autoprompt, a gradient-guided approach to find the best tokens in the prompt. jiang et al. (2020) propose mining-based and paraphrasing-based methods to automatically generate diverse prompts. furthermore, some research focus on continuous prompt optimization instead of discrete prompt optimization mentioned before, such as research by zheng et al. (2023), hambardzumyan et al. (2021), zhong et al. (2021), etc. however, all above-mentioned prompts optimization approaches aim to obtain task-specific prompts instead of model-specific ones. different from theirs, we dedicate at optimizing prompts for llms within the nlp domain and achieve impressive performance. ## conclusions the remarkable capabilities of llms have revolutionized nlp in various tasks. however, their performance heavily relies on the quality of prompts. in this work, we address the prompt optimization challenge by proposing a model-adaptive prompt optimization (mapo) approach. through extensive experiments, we demonstrated that mapo can adapt different llms with generating modelfriendly prompts to enhance their capabilities across various downstream tasks. in future work, we aim to construct more fine-grained modeladaptive prompts that can adapt to the continuously evolving data encountered in real-world production environments. additionally, we intend to enhance its applicability across a broad spectrum of linguistic contexts.