Lune

ICLR2024Top-tier venue

Understanding In-Context Learning in Transformers and LLMs by Learning to Learn Discrete Functions

Satwik Bhattamishra, Arkil Patel, Phil Blunsom, Varun Kanade

Abstract

In order to understand the in-context learning phenomenon, recent works have adopted a stylized experimental framework and demonstrated that Transformers can learn gradient-based learning algorithms for various classes of real-valued functions. However, the limitations of Transformers in implementing learning algorithms, and their ability to learn other forms of algorithms are not well understood. Additionally, the degree to which these capabilities are confined to attention-based models is unclear. Furthermore, it remains to be seen whether the insights derived from these stylized settings can be extrapolated to pretrained Large Language Models (LLMs). In this work, we take a step towards answering these questions by demonstrating the following: (a) On a test-bed with a variety of Boolean function classes, we find that Transformers can nearly match the optimal learning algorithm for 'simpler' tasks, while their performance deteriorates on more 'complex' tasks. Additionally, we find that certain attention-free models perform (almost) identically to Transformers on a range of tasks. (b) When provided a teaching sequence, i.e. a set of examples that uniquely identifies a function in a class, we show that Transformers learn more sample-efficiently. Interestingly, our results show that Transformers can learn to implement two distinct algorithms to solve a single task, and can adaptively select the more sample-efficient algorithm depending on the sequence of in-context examples. (c) Lastly, we show that extant LLMs, e.g. LLaMA-2, GPT-4, can compete with nearest-neighbor baselines on prediction tasks that are guaranteed to not be in their training set.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

34 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • In-Context Language Learning: Architectures and Algorithms cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • In-Context Language Learning: Architectures and Algorithms cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • A Theoretical Understanding of Self-Correction through In-context Alignment cites Training language models to follow instructions with human feedback
  • A Theoretical Understanding of Self-Correction through In-context Alignment cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity cites Language Models are Few-Shot Learners
  • An Explanation of In-context Learning as Implicit Bayesian Inference cites Language Models are Few-Shot Learners
  • Can large language models explore in-context? cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • Can large language models explore in-context? cites Language Models are Few-Shot Learners
  • Can large language models explore in-context? cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • Training language models to follow instructions with human feedback cites Language Models are Few-Shot Learners
  • Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks cites Language Models are Few-Shot Learners
  • Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning Tasks cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
  • What Can Transformers Learn In-Context? A Case Study of Simple Function Classes cites Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
  • What Can Transformers Learn In-Context? A Case Study of Simple Function Classes cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • What Can Transformers Learn In-Context? A Case Study of Simple Function Classes cites Language Models are Few-Shot Learners
  • Many-Shot In-Context Learning cites Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
  • Many-Shot In-Context Learning cites An Explanation of In-context Learning as Implicit Bayesian Inference
  • Many-Shot In-Context Learning cites Language Models are Few-Shot Learners
  • Many-Shot In-Context Learning cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers34

  1. Many-Shot In-Context LearningRishabh Agarwal, Avi Singh, Lei Zhang, Bernd Bohnet et al.NeurIPS 2024 · 271 citations
  2. Can Mamba Learn How To Learn? A Comparative Study on In-Context Learning TasksJongho Park, Jaeseung Park, Zheyang Xiong, Nayoung Lee et al.ICML 2024 · 124 citations
  3. Can large language models explore in-context?Akshay Krishnamurthy, Keegan Harris, Dylan J. Foster, Cyril Zhang et al.NeurIPS 2024 · 95 citations
  4. In-Context Language Learning: Architectures and AlgorithmsEkin Akyürek, Bailin Wang, Yoon Kim, Jacob AndreasICML 2024 · 91 citations
  5. A Theoretical Understanding of Self-Correction through In-context AlignmentYifei Wang, Yuyang Wu, Zeming Wei, Stefanie Jegelka et al.NeurIPS 2024 · 69 citations

Builds on20

  1. Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
  2. Training language models to follow instructions with human feedbackLong Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida et al.NeurIPS 2022 · 24,707 citations
  3. Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order SensitivityYao Lu, Max Bartolo, Alastair Moore, Sebastian Riedel et al.ACL 2022 · 1,494 citations
  4. An Explanation of In-context Learning as Implicit Bayesian InferenceSang Michael Xie, Aditi Raghunathan, Percy Liang, Tengyu MaICLR 2022 · 1,030 citations
  5. What Can Transformers Learn In-Context? A Case Study of Simple Function ClassesShivam Garg, Dimitris Tsipras, Percy Liang, Gregory ValiantNeurIPS 2022 · 883 citations

Related papers

  1. Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm SelectionYu Bai, Fan Chen, Huan Wang, Caiming Xiong et al.NeurIPS 2023 · 356 citations
  2. Transformers Implement Functional Gradient Descent to Learn Non-Linear Functions In ContextXiang Cheng, Yuxin Chen, Suvrit SraICML 2024 · 64 citations
  3. In-context Learning on Function Classes Unveiled for TransformersZhijie Wang, Bo Jiang, Shuai LiICML 2024 · 8 citations
  4. Limits of Transformer Language Models on Learning to Compose AlgorithmsJonathan Thomm, Giacomo Camposampiero, Aleksandar Terzic, Michael Hersche et al.NeurIPS 2024 · 16 citations
  5. Language Models can Exploit Cross-Task In-context Learning for Data-Scarce Novel TasksAnwoy Chatterjee, Eshaan Tanwar, Subhabrata Dutta, Tanmoy ChakrabortyACL 2024 · 5 citations
Dusk over the sea between two cliffs drawn in fine vertical lines