TL;DR
This paper introduces OverPrompt, a novel prompting strategy for Large Language Models (LLMs) that significantly reduces the cost (both time and tokens) of using LLMs for zero-shot classification tasks by processing multiple inputs in a single API call. It achieves this while maintaining, and sometimes even improving, task performance by better leveraging the in-context learning capabilities of LLMs.
What Problem Does This Paper Address?
Large Language Models (LLMs) like ChatGPT have shown impressive capabilities in various Natural Language Processing (NLP) tasks. However, their massive size and the associated computational costs make them expensive to deploy, especially when using them via APIs. Traditional zero-shot prompting, where each input is sent as a separate query, incurs substantial token and time costs due to repeated task descriptions and individual API calls. This hinders their practical adoption in real-world applications. The paper aims to address this by developing a more cost-efficient prompting strategy that still leverages the power of LLMs for zero-shot tasks.
Methods
The core of OverPrompt is its batch-processing of multiple task inputs within a single API query. Instead of sending one sentence or data point at a time, OverPrompt groups several instances together. This approach is grounded in the idea of in-context learning (ICL), where LLMs can learn from examples provided within the prompt. By presenting multiple inputs, OverPrompt aims to:
- Reduce Token Costs: The task description and other contextual information are only sent once per batch, rather than once per individual input.
- Reduce Time Costs: Fewer API calls are needed, which significantly cuts down on latency, especially when dealing with many data points.
- Improve Performance: The paper hypothesizes that providing more contextual information within a single prompt can lead to better conditional distribution mapping, potentially improving the LLM's ability to make accurate predictions.
The strategy also incorporates output formatting improvements, using JSON to clearly delineate predictions for each input within the batch, thus avoiding mismatches and improving clarity.
Datasets
The paper evaluates OverPrompt on a variety of datasets across different NLP tasks:
- Fact Checking: Fever, VitaminC, HoVer
- Sentiment Analysis: SST-2
- Natural Language Inference: GLUE benchmark datasets (including RTE, MultiNLI, QNLI, WNLI)
- Opinion Analysis: MPQA Opinion dataset
Key Insights and Ideas
- Batching is Key to Efficiency: The most significant insight is that processing multiple inputs in a single API call dramatically reduces both time and token costs. This is because the overhead of the task description is amortized across many inputs.
- ICL Benefits from Grouping: Presenting multiple related inputs together seems to help LLMs better understand the underlying task and make more accurate predictions, especially in tasks like fact-checking where comparing evidence is crucial.
- Robustness to Input Order: Interestingly, the study found that the order of inputs within a batch does not significantly impact performance, suggesting OverPrompt is robust to input permutation. This is a notable finding, as previous work on few-shot learning has shown sensitivity to example ordering.
- Not Universally Beneficial: While OverPrompt shows promise, it's not a silver bullet. For tasks like sentence entailment, where contextual information might not be as crucial or could even be detrimental if the prompt becomes too long, performance might not improve or could even degrade.
Key Results
- Significant Cost Reduction: OverPrompt consistently reduced average time cost per instance and average token cost per query across all tested datasets. For example, with n=20 instances per query, the time cost for Fever dropped from 1.3751s to 0.3579s, and token cost from 100.51 to 60.79.
- Performance Improvement: In many cases, OverPrompt not only reduced costs but also improved task performance. For instance, on the Fever dataset, accuracy increased from 0.6830 (n=1) to 0.7843 (n=20), and Macro-F1 from 0.4321 to 0.5226.
- Varied Optimal Batch Size: The optimal number of instances per batch (n) varied across datasets, suggesting that the nature of the task and the data influences how much context is beneficial.
- LLM Specificity: The effectiveness of OverPrompt was found to be more pronounced with certain LLMs, particularly the GPT-x series and Baidu's Ernie Bot, suggesting that their training data might be better suited for this type of structured input.
Limitations and Future Work
- Task Specificity: OverPrompt's benefits are not universal. For tasks like natural language inference, performance can decrease due to longer prompts potentially complicating comprehension.
- Context Length Limits: For tasks requiring very long intermediate reasoning or summarization of lengthy documents, the combined input length might exceed LLM context window limits, hindering the grouping capability.
- Instruction Complexity: Intricate instructions or very long prompts can negatively impact performance.
Future work suggested includes:
- Determining optimal strategies for segmenting inputs to retain essential context while managing prompt length.
- Deconstructing complex instructions into subtasks or step-by-step guidelines to enhance LLM efficiency.
- Further exploring the synergy between LLMs and structured data for improved performance.
Summary updated