Prompt Optimization with EASE? Efficient Ordering-aware Automated Selection of Exemplars

Large language models (LLMs) have shown impressive capabilities in real-world applications. The capability of in-context learning (ICL) allows us to adapt an LLM to downstream tasks by including input-label exemplars in the prompt without model fine-tuning. However, the quality of these exemplars in the prompt greatly impacts performance, highlighting the need for an effective automated exemplar selection method. Recent studies have explored retrieval-based approaches to select exemplars tailored to individual test queries, which can be undesirable due to extra test-time computation and an increased risk of data exposure. Moreover, existing methods fail to adequately account for the impact of exemplar ordering on the performance. On the other hand, the impact of the instruction, another essential component in the prompt given to the LLM, is often overlooked in existing exemplar selection methods. To address these challenges, we propose a novel method named EASE, which leverages the hidden embedding from a pre-trained language model to represent ordered sets of exemplars and uses a neural bandit algorithm to optimize the sets of exemplars while accounting for exemplar ordering. Our EASE can efficiently find an ordered set of exemplars that performs well for all test queries from a given task, thereby eliminating test-time computation. Importantly, EASE can be readily extended to jointly optimize both the exemplars and the instruction. Through extensive empirical evaluations (including novel tasks), we demonstrate the superiority of EASE over existing methods, and reveal practical insights about the impact of exemplar selection on ICL, which may be of independent interest. Our code is available at https://github.com/ZhaoxuanWu/EASE-Prompt-Optimization.

Paper

References (55)

Scroll for more · 38 remaining

Similar papers

Peer review

Reviewer 1tAm6/10 · confidence 4/52024-07-05

Summary

The paper proposes EASE, an exemplar selection algorithm for in-context learning of large language models (LLMs). It takes into account the order of the exemplars and offers the possibility to jointly optimize the instruction and the exemplars. A neural network is iteratively trained on the embeddings of the current exemplar sequence to predict the score of the next exemplar. The search space is reduced using a technique based on optimal transport. The paper also empirically shows that the effect of exemplar selection is not the same for all tasks.

Strengths

- A wide range of baseline methods and tasks are covered in the experiments. - The paper provides insights on the impact of exemplar selection on some specific tasks.

Weaknesses

- The performance of EASE, which requires training a model for each task, on Instruction Induction (II) is very close to the random search baseline for most tasks. - Experiments are mainly conducted on gpt-3.5-turbo-1106, an API that might include unknown pre- and post-processing. Moreover, the availability and behaviour of these APIs is not guaranteed hindering reproducibility. Consequently, the algorithm should also be validated on open-weight models (not just when doing progressive finetuning) in addition to models only available through APIs. Minor issues: Concerning the presentation, although the main contribution is clearly stated, the paper is structured in a way that makes it a bit hard to read. For example, the main paper lacks a dedicated related work section that would better contextualize the proposed algorithm.

Questions

- “out-of-distribution” tasks is defined as as tasks on which the LLM is not already well trained. How are these tasks selected without access to the training data? - what is the effect of the length of exemplars k on performance (using a range instead of a fixed value as in D.5)?

Rating

6

Confidence

4

Soundness

2

Presentation

2

Contribution

2

Limitations

There is a section on limitations in the main paper and a section on broader social impact in the appendix.

Reviewer NbA95/10 · confidence 4/52024-07-09

Summary

The paper introduces EASE (Efficient ordering-aware Automated Selection of Exemplars), a new approach to boost in-context learning (ICL) in large language models (LLMs). EASE optimizes the selection and ordering of input-label exemplars without needing model fine-tuning or test-time retrieval. EASE trains a neural network to predict the prompt performance using hidden embeddings from a pre-trained language model. Using the network as the scorer, it then employs a bandit algorithm to search for the best order exemplars for improved performance efficiently. Additionally, EASE can jointly optimize exemplars and instructions. In Instruction Induction (II) benchmark tasks and four novel out-of-distribution tasks, EASE outperforms several basic baselines, especially when the LLM has limited knowledge of the task.

Strengths

- The problem addressed is significant, as finding a fixed set of examples and instructions that generalize well to testing time could be a valuable technique. - The proposed method is well-founded, incorporating a novel component that uses optimal transport to reduce the search space. - The performance improvement in the out-of-distribution (OOD) setting is clear.

Weaknesses

- The main framework is quite similar to prior work [1], with only minor differences in details. - The literature review is inadequate, failing to cover other prompt optimization approaches, including instructions and/or example ordering (see below). Including a comprehensive related work section is crucial to highlight the novelty of the approach and justify its preference over others. - Due to the lack of discussion on prominent related works, it is unclear why the authors did not include them in the baseline set. The current baseline set is weak, relying only on heuristic methods. It would be better to incorporate proper optimization-based methods using RL[2,3], GA [4], or even LLM [5,6] as optimizers. - The current presentation of the results is unconvincing. For instance, there is no comparison in terms of running time or efficiency, areas where the paper claims to excel. The second-best baseline, Best-of-N, shows competitive results in real benchmarks. If N increases, its performance might surpass EASE. Without efficiency comparison between methods, it is hard to determine if EASE is useful. - Another major concern is the method seems to only work well with synthetic OOD settings. More experiments with real datasets are preferred. [1] Xiaoqiang Lin, Zhaoxuan Wu, Zhongxiang Dai, Wenyang Hu, Yao Shu, See-Kiong Ng, Patrick Jaillet, and Bryan Kian Hsiang Low. Use your INSTINCT: Instruction optimization using neural bandits coupled with transformers. In NeurIPS Workshop on Instruction Tuning and Instruction Following, 2023. [2] Mingkai Deng, Jianyu Wang, Cheng-Ping Hsieh, Yihan Wang, Han Guo, Tianmin Shu, Meng Song, Eric Xing, and Zhiting Hu. 2022. Rlprompt: Optimizing discrete text prompts with reinforcement learning. In Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, pages 3369–3391. [3] Tianjun Zhang, Xuezhi Wang, Denny Zhou, Dale Schuurmans, and Joseph E Gonzalez. 2022. Tempera: Test-time prompt editing via reinforcement learning. In The Eleventh International Conference on Learning Representations [4] Archiki Prasad, Peter Hase, Xiang Zhou, and Mohit Bansal. 2023. Grips: Gradient-free, editbased instruction search for prompting large language models. In Proceedings of the 17th Conference of the European Chapter of the Association for Computational Linguistics, pages 3827–3846. [5] Yongchao Zhou, Andrei Ioan Muresanu, Ziwen Han, Keiran Paster, Silviu Pitis, Harris Chan, and Jimmy Ba. 2022. Large language models are human-level prompt engineers. In The Eleventh International Conference on Learning Representations. [6] Chengrun Yang, Xuezhi Wang, Yifeng Lu, Hanxiao Liu, Quoc V Le, Denny Zhou, and Xinyun Chen. 2023. Large language models as optimizers. arXiv preprint arXiv:2309.03409.

Questions

- What is the size of the dataset D? If D is small, a brute-force search could be feasible. Typically, LLMs are most beneficial when there is little to no data for downstream tasks, so a small D would be more realistic. - How was the NN’s uncertainty computed? - What method was used to tune the hyperparameters of NeuralUCB? - Please consider more real data such as those in the Tempera paper [3].

Rating

5

Confidence

4

Soundness

2

Presentation

2

Contribution

2

Limitations

The authors could also mention the cost of hyperparameter tuning

Reviewer FzJo6/10 · confidence 4/52024-07-12

Summary

The paper introduces EASE, a method for optimizing ICL in LLMs by selecting and ordering exemplars efficiently. Unlike retrieval-based methods that incur extra computation and privacy risks, EASE uses a neural bandit algorithm and optimal transport techniques to find high-quality ordered exemplars without test-time computation. It also extends to jointly optimize exemplars and instructions for improved performance. Empirical evaluations demonstrate EASE's superiority over existing methods across various tasks, especially where the LLM lacks task-specific knowledge. EASE proves robust in noisy data scenarios, offering a comprehensive solution for enhancing ICL in practical applications.

Strengths

- The introduction of the EASE algorithm, which combines neural bandit optimization and optimal transport, is a unique approach to exemplar selection. - The paper includes extensive empirical evaluations, comparing EASE with a comprehensive suite of baseline methods across various tasks. The consistent outperformance of EASE underscores its effectiveness. - The paper provides clear explanations of the methodology, including the use of neural bandit algorithms and optimal transport, making the complex concepts accessible.

Weaknesses

- The requirement for on-the-fly computation of embeddings for ordered exemplar sequences is identified as a potential computational bottleneck. - EASE relies on the availability of a suitable validation set, which may not always be readily available in certain scenarios. This requirement could limit the method's applicability in some contexts. - The joint optimization of exemplars and instructions, while beneficial, adds complexity to the method. The paper could provide more detailed guidance on effectively implementing this joint optimization in practice.

Questions

- Can you provide more insights or potential solutions to mitigate the computational bottleneck caused by the on-the-fly computation of embeddings for ordered exemplar sequences? - While combining EASE with retrieval-based methods for large exemplar sets has shown better performance, could you elaborate on any potential limitations or challenges of this approach?

Rating

6

Confidence

4

Soundness

3

Presentation

3

Contribution

2

Limitations

- The need for a suitable validation set is recognized as a limitation, as such sets may not always be readily available. This could restrict the method's applicability in certain contexts where validation data is scarce or difficult to obtain. - The selection of exemplars could inadvertently reinforce biases present in the training data. The authors could address how EASE mitigates bias and ensures fairness in exemplar selection, especially in sensitive applications.

Authorsrebuttal2024-08-13

Dear Reviewer FzJo, Thank you for taking the time to review our paper! As the discussion period is concluding in less than a day, we hope to hear from you whether our rebuttal has sufficiently addressed your questions and concerns. We have provided additional insights and proposed potential solutions to the computational bottleneck. We also justified the use of our validation dataset, while offering an alternative approach to remove the validation dataset in future works. We also hope that our detailed guidance on joint optimization, along with our discussion of the limitations helped to improve the quality of the paper. We are more than happy to answer any further questions during the remaining discussion period. Best regards, Authors of Paper 16009

Reviewer u1fC7/10 · confidence 4/52024-07-15

Summary

The authors propose EASE, a method for optimizing the selection of few-shot examples for prompting black-box LLMs. EASE is an iterative algorithm that combines NeuralUCB and Optimal Transport. In iteration t, EASE trains a neural network to map embeddings of strings (of few-shot examples) to their average score on a validation set. Then, they sample a subset of possible combinations of few-shot examples, filter them with optimal transport, and use NeuralUCB to select a set that maximizes their acquisition function. The selected set is evaluated and added to the pool of embedding -> score list. The authors evaluate on a set of existing tasks and a few synthetic tasks they created. Overall, the proposed method outperforms the baselines nearly across the board.

Strengths

1) The paper overall is easy to follow. 2) The results are very strong and the range of baselines is satisfactory. 3) The hypothesis and synthetic task evaluation is quite valuable and insightful. 4) The method underlying EASE is likely to spur future approaches in this space.

Weaknesses

1) The method does not really justify why we should expect off-the-shelf embeddings (into a single unlearned vector no less) of few-shot example strings to encode enough information for NeuralUCB to work effectively. In general, off-the-shelf encoders may or may not highlight the important aspects of the prompt; they're not trained to do that. The authors discuss that embeddings will be sensitive to the ordering. This is true, but in what way do we know that such sensitivity could be leveraged effectively from a frozen task-misaligned sematic encoder? 2) A lot of the discussions regarding "retrieval-based methods" are just forced and the paper doesn't even need them. The work shows that it's empirically more effective. That's sufficient. You don't need to argue that retrieval-based methods will "significant additional computational overheads especially when the number of test queries is large". That's plainly false: retrieval in the way discussed in this paper (e.g., cosine similarity) can standardly be done from billion-scale collections in 2-3 milliseconds in practice, far faster than the LLM invocation. 3) Many experimental details don't seem to have been controlled for: what's the effect of the LM choice? what's the effect of the precise budget? of the training set size? of the validation set size? How large are these currently in the first place? 4) The tasks selected are arguably overly simplistic and generally this means that the few-shot examples considered are all rather trivial. To my understanding, there are no reasoning chains or open-ended generation in any of the labels. There's no argument on why we should expect a method that works for simple direct classification-type labels to generalize to far more open-ended tasks. Such tasks exist plentifully; it's unclear why the authors do not consider any of them. 5) The authors say: "Our proposed Evo and Best-of-N are the most competitive baselines with best performance in 9 and 11 tasks, respectively." This seems to suggest that the authors believe they are the first to consider such approaches. While I think the current baselines are satisfactory, both Evo and Best-of-N approaches are components in numerous existing methods (which may involve other components), e.g. see PhaseEvo "Unified In-Context Prompt Optimization" for the former and DSPy's BootstrapFewShot with RandomSearch for the latter.

Questions

1) The authors simultaneously find best-of-N to be highly effective as a baseline and yet argue for the importance of Optimal Transport in their method. Can we gain more insight on what OT ultimately selects under the hood? Intuition is lacking. 2) What's the difference between Tables 7 and 8? What about ablations on real tasks? 3) The authors say: > filter the large pool of data exemplars to eliminate those that are less relevant to the task. To this end, we propose to first use retrieval-based methods to select the exemplars that are more relevant to the task, and then run our EASE using this refined smaller set of exemplars. Specifically, we use a cosine similarity retriever and perform exemplar selection on D with a size n as large as 100000. What does this mean? What are examples that are "more relevant" to a task? What's the precise retrieval formulation here, i.e. what's the query and what is the corpus of documents.

Rating

7

Confidence

4

Soundness

3

Presentation

3

Contribution

3

Limitations

N/A

Authorsrebuttal2024-08-07

About NN uncertainty computation

Responding to *Reviewer NbA9*: Following [14] and [42], the uncertainty of the NN is the Gaussian process posterior standard deviation when the empirical neural tangent kernel (NTK) is used as the kernel $k(z_1,z_2) = \nabla_{\theta} m(z_1;\theta_{t})^\top \nabla_{\theta} m(z_2;\theta_{t}) $ where $z$ is the embedding and $\theta$ is the parameter of the NN $m$. Specifically, define $V_{t} = \sum_{\tau=1}^{t} \nabla_{\theta} m(z_{\tau};\theta_{\tau}) \nabla_{\theta} m(z_{\tau};\theta_{\tau})^{\top}$ where $z_\tau$ is the history of embedding at step $\tau$. Then, the uncertainty is calculated according to $\sigma_{t-1}(z;\theta_t) = \sqrt{\nabla_{\theta} m(z;\theta_{t})^{\top}V_{t-1}^{-1} \nabla_{\theta} m(z;\theta_{t})}$.

Reviewer u1fC2024-08-07

Thanks for the response. The retrieval formulation is a bit strange. Aren't the training and validation sets, both, from the same distribution? What's the intuition that justifies using each validation example to retrieve a training example, besides possibly overfitting to the validation set?

Authorsrebuttal2024-08-08

We thank the reviewer for the prompt reply! The retrieval method is mainly implemented as an **independent step to pre-filter candidates** serving as a promising extension of our EASE to handle a large set of exemplars. The intuition is to prefer exemplars that are similar to the validation set in order to achieve high performance. At the same time, it **encourages diversity** by selecting a subset that contains data from possible different subgroups represented by different validation data exemplars. Specifically, for each validation data exemplar, we retrieve the most relevant training data, so the combined dataset contains data from different data subgroups. We usually assume that the validation set and the test set follow the same distribution in the learning setting. By minimizing the validation error, we also minimize the test error. This in fact follows the common practice in classical machine learning, where we typically use the validation set to select the best-performing models or hyper-parameters. We hope that our clarification helps!

Reviewer u1fC2024-08-12

I'm unable to grasp the intuition in this specific part, but otherwise my assessment of the work is positive. I will raise my score from 6 to 7 but I expect the authors to iterate on the intuition, theory, or qualitative empirical observations from this retrieval element.

Authorsrebuttal2024-08-12

We are happy that our response generally improved your opinion about our work! For the specific part on retrieval, we will definitely iterate further to improve the clarity and the presentation of the intuition and results (e.g., we may include a diagram to visually illustrate the retrieval idea).

Reviewer 1tAm2024-08-10

Thank you for your answer to the questions. The method was validated using the open weight model Llama-3.1-8B-Instruct which improves the reproducibility of the paper. I disagree with the stated advantages of closed APIs. There are also cloud providers that offer inexpensive pay-as-you-go access to open weight models. The authors also run experiments on the effect of k. The new results helped in answering some of the questions and improved the quality of the paper. However, I have some remarks regarding the performance on the “Out-of-distribution” tasks which is one of the main contributions of the paper (since the method is as good as the baselines on regular tasks even though it introduces overhead). The proposed approach works better on some specific tasks labeled as “Out-of-distribution”. The task selection mainly relies on practical intuitions. Is it possible that the baselines perform worse on these tasks because of some other factors unrelated to model knowledge? This could be tested if we had access to the training data (with models like Olmo, Pythia) or by using methods that more rigorously asses the model's knowledge.

Authorsrebuttal2024-08-12

We are happy that our additional experiments helped to address the questions! We also thank the reviewer for suggesting the use of OLMo and Pythia to verify our intuitions about model knowledge. Upon checking the published data sources, named Dolma, of OLMo, it is likely that Instruction Induction (II) data has been included in the training source (via Common Crawl, or The Stack). Therefore, we perform additional experiments across different checkpoints (at 41k, 130k and 410k training steps) of the recent OLMo-7B-0424-hf model, which released checkpoints over more than 400k steps of training. The results are presented below. | | OLMo_41k | OLMo_41k | OLMo_130k | OLMo_130k | OLMo_410k | OLMo_410k | |:----------------------|:--------------------:|:----------------:|:--------------------:|:----------------:|:--------------------:|:----------------:| | | **Best-of-N** | **EASE** | **Best-of-N** | **EASE** | **Best-of-N** | **EASE** | | object_counting | 20.0 ± 2.9 | 28.3 ± 1.7 | 25.0 ± 2.9 | 38.3 ± 1.7 | 45.0 ± 2.9 | 46.7 ± 1.7 | | sentence_similarity | 25.0 ± 0.0 | 26.7 ± 1.7 | 30.0 ± 2.9 | 31.7 ± 1.7 | 41.7 ± 1.7 | 41.7 ± 1.7 | | orthography_starts_with | 21.7 ± 1.7 | 23.3 ± 1.7 | 21.7 ± 1.7 | 28.3 ± 1.7 | 26.7 ± 1.7 | 31.7 ± 1.7 | | translation_en-fr | 21.7 ± 1.7 | 23.3 ± 1.7 | 38.3 ± 1.7 | 45.0 ± 2.9 | 35.0 ± 0.0 | 40.0 ± 0.0 | The conclusions are consistent with Figure 1 of the main paper. - When the training just started (i.e., at 41k steps), the model might not be capable enough to carry out effective in-context learning. - As the training progresses (i.e., at 130k steps), we observe the best exemplar selection effectiveness. At this point, the model is capable of learning underlying relationships among the in-context exemplars, and yet to be well-trained on the specific task. - As the model converges (i.e., at 410k steps), the gain from exemplar selection using our EASE diminishes as the model becomes well-trained on the dataset of the respective tasks. We also tried the rule-based tasks and remapped label tasks on OLMo-7B-0424-hf. However, the in-context learning performances are always at 0\% for these more difficult tasks, so comparisons are not meaningful. We also look forward to similar efforts (as OLMo and Pythia) in the community to open-source larger and more capable models with checkpoints in the future. We thank the reviewer again for the insightful comments that helped improve our paper.

Reviewer 1tAm2024-08-13

The controlled experiment on the open-source model shows that EASE outperforms the baseline during the earlier phase of training. The gap gets smaller as the number of steps increases. As you mention, this highlights the in-context learning abilities of the model. An undertrained model benefits more from the exemplars selection method. However, the task is present in the training set. It seems to be more about the evolution of the in-context learning abilities of the model as evaluated on a dataset seen during training than about the performance on out-of-distribution tasks. It is an informative experiment nonetheless.

Authorsrebuttal2024-08-13

We appreciate the reviewer's active discussion and constructive feedback. Unfortunately, we do not have access to an open-source model with checkpoints that is sufficiently capable of performing the challenging out-of-distribution tasks in context --- Even the most recent model, OLMo-7B-0424-hf, demonstrates essentially 0\% accuracy on OOD tasks. Nevertheless, we are happy to hear that the experiments above are informative from other perspectives.

Authorsrebuttal2024-08-13

Dear Reviewer NbA9, Thank you for taking the time to review our paper! As the discussion period is concluding in less than a day, we hope to hear from you whether our rebuttal has sufficiently addressed your questions and concerns. Especially, we hope that the clarifications on our distinctions from [1] and related works are satisfactory. Additionally, we hope that the additional experiments we conducted on real datasets (MR, Yelp P., CR, MNLI & MRPC) and datasets with CoT reasoning chains (MATH, GSM8K & AQuA-RAT) have made our papers more convincing. We are more than happy to answer any further questions during the remaining discussion period. Best regards, Authors of Paper 16009

Reviewer FzJo2024-08-13

I appreciate the comprehensive rebuttal provided by the authors, which addresses the concerns and questions raised in my initial review. I will raise my rating from 5 to 6, reflecting a higher confidence in the paper's contribution and impact.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC