TL;DR
This paper introduces Curriculum Demonstration Selection (CDS), a novel method for selecting in-context learning (ICL) examples for Large Language Models (LLMs). By organizing demonstrations from easy to difficult, CDS significantly boosts LLM performance across various reasoning and code generation tasks, especially for more challenging problems.
What Problem Does This Paper Address?
Large Language Models (LLMs) have shown impressive in-context learning (ICL) capabilities, meaning they can learn new tasks from a few examples provided in the prompt without needing to update their internal parameters. However, the effectiveness of ICL heavily relies on the quality and relevance of these example demonstrations. Current methods for selecting these demonstrations often rely on simple similarity metrics or random selection, which can lead to suboptimal performance, particularly when dealing with tasks of varying complexity. The core challenge is how to select a set of demonstrations that best unlocks an LLM's full potential, especially when faced with a spectrum of problem difficulties.
Methods
The paper proposes Curriculum Demonstration Selection (CDS), a method inspired by curriculum learning in education. The core idea is to present LLMs with demonstrations that gradually increase in difficulty, mimicking how humans learn.
Here's how it works:
- Curriculum Construction: The training data is first partitioned into several difficulty levels. This is achieved by leveraging existing metadata, such as grade levels for math problems or difficulty ratings (easy, medium, hard) for code generation tasks.
- Demonstration Retrieval: For each test instance, CDS selects one demonstration from each difficulty partition. This ensures that the LLM receives a balanced exposure to examples across the entire difficulty spectrum. The retrieval itself can be either random within each partition or similarity-based (using embeddings from models like RoBERTa) to find the most representative example for that difficulty level.
- Shuffling: To prevent the model from overfitting to the order of demonstrations, the selected set is then shuffled before being presented in the prompt.
Datasets
The authors evaluated their method on three distinct datasets:
- MATH dataset: A challenging benchmark for mathematical reasoning, comprising 7,500 training and 5,000 testing examples across various mathematical topics. It's categorized into five distinct complexity levels.
- ARC-Challenge dataset: A dataset for commonsense reasoning, featuring 2,590 multiple-choice science questions designed for students from grade 3 to grade 9. Difficulty is primarily determined by grade level.
- Mercury dataset: A specialized benchmark for code generation tasks, containing 256 evaluation tasks sourced from LeetCode problems, categorized into Easy, Medium, and Hard difficulty levels. Acceptance rates are used as an additional metric for finer difficulty distinctions.
Key Insights and Ideas
- Difficulty Matters: The most significant insight is that simply selecting similar examples isn't enough. A balanced set of demonstrations spanning different difficulty levels is crucial for maximizing LLM performance in ICL.
- Curriculum Learning for LLMs: The paper successfully demonstrates that applying curriculum learning principles, traditionally used for human education, can significantly enhance LLM learning in an ICL setting.
- Challenging Problems Benefit Most: CDS shows a disproportionately larger improvement on harder problems compared to easier ones, suggesting its effectiveness in pushing LLMs beyond their basic capabilities.
- Order Doesn't (Necessarily) Matter: Interestingly, the study found that shuffling the demonstrations after selection (as opposed to a strict easy-to-hard order) did not negatively impact performance, indicating the robustness of the selection strategy itself.
Key Results
CDS consistently outperformed baseline methods (uniform random selection and similarity-based selection like KATE) across all tested LLMs and benchmarks.
- Reasoning Tasks (MATH & ARC-c): CDS achieved notable improvements, with larger models like Llama 2 13B showing particularly significant gains. For instance, on the MATH dataset, CDS improved performance across various topics, with algebra and number theory seeing the most substantial benefits.
- Code Generation (Mercury): CDS significantly boosted performance on both "Pass" (functional correctness) and "Beyond" (efficiency) metrics for all LLMs tested, including CodeLlama, StarCoder, and DeepSeek-Coder.
- Retrieval Function: Both random and similarity-based retrieval within CDS outperformed the random baseline. Similarity-based retrieval generally yielded slightly better results, suggesting that selecting representative examples within each difficulty level is beneficial.
- Difficulty Levels: The average improvement from CDS was more pronounced on "Hard" difficulty problems (around 6% on MATH) compared to "Easy" ones (around 2% on MATH).
Limitations and Future Work
The authors acknowledge several limitations and suggest future research directions:
- Fixed Shot Setting: The experiments were conducted with a fixed five-shot setting. Future work could explore how CDS performs with varying numbers of demonstrations, especially for more complex tasks.
- Reliance on Metadata: CDS currently relies on pre-defined metadata for difficulty estimation. For datasets lacking such metadata, alternative methods for estimating task complexity (e.g., model-based estimates, heuristics) would be needed.
- Generalizability: The evaluation was limited to mathematical reasoning, commonsense reasoning, and code generation. Further research is needed to assess CDS's generalizability across a broader range of tasks and domains.
Summary updated