TL;DR
This paper explores "many-shot in-context learning" (ICL), where Large Language Models (LLMs) learn from hundreds or thousands of examples instead of just a few. They show that this "many-shot" approach significantly boosts performance across various tasks, even enabling LLMs to overcome pre-training biases and learn complex functions, rivaling fine-tuning. The authors also introduce "Reinforced ICL" and "Unsupervised ICL" to reduce reliance on human-generated examples.
What Problem Does This Paper Address?
Traditionally, LLMs learn from a handful of examples in their context window (few-shot ICL). However, with LLMs now boasting much larger context windows (up to 1 million tokens), researchers can explore "many-shot ICL" – using hundreds or thousands of examples. The challenge is that obtaining a large number of high-quality, human-generated examples (especially for complex reasoning tasks) is a significant bottleneck. This paper investigates how scaling up the number of examples in ICL impacts performance and explores methods to overcome the reliance on human data.
Methods
The core of the paper is the systematic evaluation of many-shot ICL across a diverse set of tasks. Key methodological contributions include:
- Many-Shot ICL: Investigating performance with hundreds to thousands of examples, pushing beyond the typical few-shot regime.
- Reinforced ICL: Replacing human-written rationales with model-generated chain-of-thought rationales. These rationales are filtered for correctness before being used in the prompt.
- Unsupervised ICL: Removing rationales entirely and prompting the model only with domain-specific inputs (problems).
- Analysis of Learning Dynamics: Studying how many-shot ICL differs from few-shot ICL in terms of overcoming biases, learning high-dimensional functions, and its relationship with fine-tuning.
- Evaluation of Scaling Laws: Examining the limitations of using next-token prediction loss as a sole indicator of ICL performance.
Datasets
The paper evaluates many-shot ICL on a wide range of existing benchmarks:
- Problem Solving: MATH, GSM8K, GPQA (Google-Proof QA), Big-Bench Hard (BBH)
- Summarization: XSum, XLSum
- Machine Translation: FLORES-200 (low-resource languages like Bemba and Kurdish)
- Reward Modeling: Code Verifier (using GSM8K code solutions)
- Planning: Logistics Domain
- Sentiment Analysis: Financial PhraseBank (FP)
- Classification: High-dimensional linear classification datasets.
- Sequential Parity: A non-natural language task.
The authors also mention using datasets derived from these benchmarks for specific experiments, such as the MATH500 test set for problem-solving.
Key Insights and Ideas
- Many-Shot is a Game Changer: The most striking insight is that scaling up the number of examples in ICL from few-shot to many-shot leads to substantial performance gains across almost all tested tasks. This suggests that LLMs have a much greater capacity to learn from context than previously thought.
- Overcoming Pre-training Biases: Unlike few-shot ICL, many-shot ICL can effectively override pre-training biases. This is demonstrated in sentiment analysis tasks where flipped or abstract labels are used, showing that with enough examples, the model can unlearn ingrained biases.
- Learning Complex Functions: Many-shot ICL can learn high-dimensional functions with numerical inputs, such as linear classification and sequential parity, tasks where few-shot ICL struggles. This highlights the versatility of many-shot ICL.
- Reinforced & Unsupervised ICL are Viable: The proposed Reinforced and Unsupervised ICL methods show promise, particularly for complex reasoning tasks. They reduce the dependency on human-annotated rationales, making many-shot ICL more scalable. Reinforced ICL, in particular, often outperforms Unsupervised ICL and even ground-truth ICL in some cases.
- Next-Token Prediction Loss is Misleading: The paper reveals that negative log-likelihood (NLL) trends, often used to evaluate long-context models, do not reliably predict downstream task performance in many-shot ICL. Performance can improve even when NLL plateaus or slightly degrades.
Key Results
- Significant Performance Gains: Many-shot ICL consistently outperforms few-shot ICL across a wide range of tasks, with improvements often reaching tens of percentage points. For example, on MATH and GPQA, many-shot ICL with hundreds of shots significantly surpasses few-shot performance.
- Comparable to Fine-Tuning: For tasks like low-resource machine translation, many-shot ICL performs comparably to supervised fine-tuning (SFT) with a similar number of examples.
- Reinforced ICL Effectiveness: On problem-solving tasks like MATH and GPQA, Reinforced ICL often outperforms ICL with ground-truth solutions, especially with many shots. For Big-Bench Hard, Reinforced ICL achieved an average success rate of 83%, compared to 77.1% for Unsupervised ICL and 72.1% for human-written CoT prompts.
- Overcoming Bias: In sentiment analysis with flipped labels, accuracy improved from around 60% with few shots to over 80% with many shots, approaching the performance of default labels.
- Learning High-Dimensional Functions: In linear classification, many-shot ICL with thousands of shots per class closely tracks the performance of a k-nearest neighbors baseline trained from scratch. For sequential parity, many-shot ICL surpasses a GPT-2 Medium transformer trained from scratch.
- Inference Cost: While many-shot ICL increases inference runtime, it scales linearly with the number of shots (when KV caching is enabled), making it manageable.
Limitations and Future Work
- Model Dependency: The primary evaluation was conducted on Gemini 1.5 Pro. While preliminary results with GPT-4-Turbo, Gemini 1.5 Flash, and Claude-3-Opus suggest similar benefits, more extensive evaluation across a wider range of long-context models is needed.
- Understanding Performance Degradation: The paper notes that performance can sometimes degrade with an increasing number of examples (e.g., for MATH). The current analysis of NLL doesn't fully explain this, suggesting a need for further research into the underlying mechanisms.
- Example Ordering Sensitivity: While many-shot ICL shows less sensitivity than few-shot ICL, performance can still vary significantly with different example orderings, posing a challenge for ensuring reliable results. Future work could explore prompt optimization frameworks like DSPy.
- Generalizability of Reinforced/Unsupervised ICL: While promising, these methods require further investigation into their broad applicability and robustness across diverse tasks and model architectures.
Overall, the paper advocates for many-shot ICL as a powerful paradigm for leveraging the capabilities of long-context LLMs, opening new frontiers in their adaptability and performance.
Summary updated