[Paper Review] In-Context Learning with Long-Context Models: An In-Depth Exploration
The paper studies in-context learning (ICL) at extreme context lengths across multiple datasets and models, comparing naive prompting, retrieval-based demonstrations, and finetuning, and analyzes long-context ICL properties.
As model context lengths continue to increase, the number of demonstrations that can be provided in-context approaches the size of entire training datasets. We study the behavior of in-context learning (ICL) at this extreme scale on multiple datasets and models. We show that, for many datasets with large label spaces, performance continues to increase with hundreds or thousands of demonstrations. We contrast this with example retrieval and finetuning: example retrieval shows excellent performance at low context lengths but has diminished gains with more demonstrations; finetuning is more data hungry than ICL but can sometimes exceed long-context ICL performance with additional data. We use this ICL setting as a testbed to study several properties of both in-context learning and long-context models. We show that long-context ICL is less sensitive to random input shuffling than short-context ICL, that grouping of same-label examples can negatively impact performance, and that the performance boosts we see do not arise from cumulative gain from encoding many examples together. We conclude that although long-context ICL can be surprisingly effective, most of this gain comes from attending back to similar examples rather than task learning.
Motivation & Objective
- Investigate how ICL scales when demonstrations reach hundreds to thousands, approaching full training-set sizes.
- Compare naive in-context prompting, retrieved demonstrations, and model finetuning under long-context conditions.
- Evaluate the impact of long context on model sensitivity to demonstration order and label grouping.
- Contrast long-context ICL with LoRA-based finetuning and retrieve-and-prompt approaches across diverse datasets.
Proposed method
- Evaluate several long-context variants of Llama-2-7b (nosep), including 32k- and 80k-context finetuned models, and Mistral-7b-Instruct-v0.2.
- Use constrained decoding to output only valid labels, following Ratner et al. (2022).
- Conduct in-context learning with three settings: random sampling of demonstrations, retrieval-based demonstrations via BM25, and finetuning with a classification head.
- Compare ICL variants to parameter-efficient finetuning (LoRA) on the same datasets.
- Subsample 250 test examples per dataset and report accuracy and macro-F1 (primarily accuracy).
- Assess long-context ICL behavior across five classification datasets with varying label spaces.
Experimental results
Research questions
- RQ1Does increasing the number of in-context demonstrations continue to improve performance when context length is extremely large?
- RQ2How does retrieval-based selection compare to random selection in long-context ICL?
- RQ3How does long-context ICL compare to LoRA finetuning across datasets with different label spaces?
- RQ4What properties of long-context ICL emerge (e.g., sensitivity to example order, grouping by label) as demonstrations scale?
- RQ5To what extent is gains from long-context ICL due to retrieval from relevant examples versus encoding many examples simultaneously?
Key findings
- Performance improves with hundreds to thousands of demonstrations, sometimes matching or exceeding finetuned models on some datasets.
- Retrieval-based demonstrations outperform random sampling at short contexts, but the advantage diminishes as the number of demonstrations grows in long-context ICL.
- Finetuning with LoRA can surpass long-context ICL on certain datasets, particularly with large label spaces, but long-context ICL often remains competitive.
- Long-context ICL shows reduced sensitivity to demonstration order as context length increases, and grouping same-label examples can significantly harm performance.
- The primary advantage of long-context ICL appears to stem from retrieving more relevant examples rather than iterative refinement of a decision boundary through encoding, suggesting a retrieval-based mechanism dominates in long contexts.
- Blocking attention experiments indicate that much of the improvement is due to access to relevant demonstrations rather than learning task boundaries within short blocks.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.