BatchPrompt: Accomplish more with less

Jianzhe Lin,Maurice Diesendruck,Liang Du,Robin Abraham
2024-07-15
Abstract:As the ever-increasing token limits of large language models (LLMs) have enabled long context as input, prompting with single data samples might no longer an efficient way. A straightforward strategy improving efficiency is to batch data within the token limit (e.g., 8k for gpt-3.5-turbo; 32k for GPT-4), which we call BatchPrompt. We have two initial observations for prompting with batched data. First, we find that prompting with batched data in longer contexts will inevitably lead to worse performance, compared to single-data prompting. Second, the performance of the language model is significantly correlated with the positions and order of the batched data, due to the corresponding change in decoder context. To retain efficiency and overcome performance loss, we propose Batch Permutation and Ensembling (BPE), and a novel Self-reflection-guided EArly Stopping (SEAS) technique. Our comprehensive experimental evaluation demonstrates that BPE can boost the performance of BatchPrompt with a striking margin on a range of popular NLP tasks, including question answering (Boolq), textual entailment (RTE), and duplicate questions identification (QQP). These performances are even competitive with/higher than single-data prompting(SinglePrompt), while BatchPrompt requires much fewer LLM calls and input tokens (For SinglePrompt v.s. BatchPrompt with batch size 32, using just 9%-16% the number of LLM calls, Boolq accuracy 90.6% to 90.9% with 27.4% tokens, QQP accuracy 87.2% to 88.4% with 18.6% tokens, RTE accuracy 91.5% to 91.1% with 30.8% tokens). To the best of our knowledge, this is the first work to technically improve prompting efficiency of large language models. We hope our simple yet effective approach will shed light on the future research of large language models. The code will be released.
Computation and Language
What problem does this paper attempt to address?
The problem that this paper attempts to solve is to improve the efficiency and performance of large - language models (LLMs) when processing long - context inputs. Specifically, when dealing with a small amount of data, the traditional single - data - point prompting method (SinglePrompt) has a low token utilization rate because instructions and examples take up a large number of tokens, which affects the inference speed and computational cost. The paper proposes a new prompting strategy - BatchPrompt, which improves token utilization by batch - processing multiple data points in each prompt. However, simple batch - processing will lead to performance degradation. In particular, as the batch - size increases, data points in different positions may produce different answers. To solve this problem, the paper introduces Batch Permutation and Ensembling (BPE) and Self - reflection - guided EArly Stopping (SEAS) methods to improve performance while maintaining high token utilization. ### Main contributions 1. **BatchPrompt**: An efficient LLMs prompting technique that improves token utilization by batch - processing data points. 2. **BPE**: Improves the performance of BatchPrompt through data permutation and integration (majority voting). 3. **SEAS**: Further improves the accuracy and efficiency of BatchPrompt through self - reflection - guided early stopping, while reducing the number of LLMs invocations and token usage. 4. **Experimental verification**: The effectiveness of BatchPrompt combined with BPE and SEAS has been verified on multiple benchmark tasks, showing that it has performance comparable to or even higher than that of the single - data - point prompting method while reducing token usage. ### Specific problems solved - **Low token utilization**: When dealing with a small amount of data, the traditional SinglePrompt method has a low token utilization rate because instructions and examples take up a large number of tokens. - **Performance degradation**: Simple batch - processing of data will lead to performance degradation, especially when the batch - size increases. - **High computational cost**: Low token utilization and multiple LLM invocations increase the computational cost. ### Experimental results - **Significantly reduced token usage**: On multiple tasks, the number of tokens used by BatchPrompt + BPE + SEAS is far less than that of SinglePrompt. For example, on the Boolq task, when using a batch - size of 32 data points, the token usage is reduced by 72.6%. - **Performance improvement**: Although the token usage is reduced, the performance of BatchPrompt + BPE + SEAS is comparable to or even higher than that of SinglePrompt. For example, on the Boolq task, the accuracy is increased from 90.6% to 90.9%. ### Conclusion The BatchPrompt method combined with BPE and SEAS proposed in the paper effectively improves the performance and efficiency of LLMs when processing long - context inputs while improving token utilization, providing new ideas for future large - scale language model research.