Towards Understanding How Transformers Learn In-context Through a Representation Learning Lens
Not on the map. Why?
Abstract (arXiv)
Pre-trained large language models based on Transformers have demonstrated remarkable in-context learning (ICL) abilities. With just a few demonstration examples, the models can implement new tasks without any parameter updates. However, it is still an open question to understand the mechanism of ICL. In this paper, we attempt to explore the ICL process in Transformers through a lens of representation learning. Initially, leveraging kernel methods, we figure out a dual model for one softmax attention layer. The ICL inference process of the attention layer aligns with the training procedure of its dual model, generating token representation predictions that are equivalent to the dual model's test outputs. We delve into the training process of this dual model from a representation learning standpoint and further derive a generalization error bound related to the quantity of demonstration tokens. Subsequently, we extend our theoretical conclusions to more complicated scenarios, including one Transformer layer and multiple attention layers. Furthermore, drawing inspiration from existing representation learning methods especially contrastive learning, we propose potential modifications for the attention layer. Finally, experiments are designed to support our findings.
Key facts. Cited by 15 papers in the map (data through 7 Oct 2026). Builds on 46 of its 59 references that are in the map. First posted on arXiv 20 Oct 2023.
Builds on
46 of 59 references.
References · 46
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2019Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformercited by 14,491
- 2020A Simple Framework for Contrastive Learning of Visual Representationscited by 11,979
- 2018Representation Learning with Contrastive Predictive Codingcited by 7,662
- 2019Momentum Contrast for Unsupervised Visual Representation Learningcited by 7,482
- 2018GLUE: A Multi-Task Benchmark and Analysis Platform for Natural Language Understandingcited by 4,854
- 2020Bootstrap your own latent: A new approach to self-supervised Learningcited by 4,712
- 2016Gaussian Error Linear Units (GELUs)cited by 3,431
- 2020Exploring Simple Siamese Representation Learningcited by 2,853
- 2020Unsupervised Learning of Visual Features by Contrasting Cluster Assignmentscited by 2,845
34 more
- 2022Emergent Abilities of Large Language Modelscited by 2,483
- 2020Improved Baselines with Momentum Contrastive Learningcited by 2,282
- 2021Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processingcited by 2,222
- 2019HuggingFace's Transformers: State-of-the-art Natural Language Processingcited by 2,201
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,979
- 2018Unsupervised Feature Learning via Non-Parametric Instance-level Discriminationcited by 1,838
- 2020Rethinking Attention with Performerscited by 1,584
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
- 2021Towards a Unified View of Parameter-Efficient Transfer Learningcited by 863
- 2022Transformers learn in-context by gradient descentcited by 714
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
- 2019A Theoretical Analysis of Contrastive Unsupervised Representation Learningcited by 530
- 2021Linear Transformers Are Secretly Fast Weight Programmerscited by 471
- 2015Deep Metric Learning via Lifted Structured Feature Embeddingcited by 449
- 2021Random Feature Attentioncited by 350
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
- 2021CMT: Convolutional Neural Networks Meet Vision Transformerscited by 310
- 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
- 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 274
- 2021Understanding self-supervised Learning Dynamics without Contrastive Pairscited by 254
- 2023Label Words are Anchors: An Information Flow Perspective for Understanding In-Context Learningcited by 235
- 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 220
- 2023One Step of Gradient Descent is Provably the Optimal In-Context Learner with One Layer of Linear Self-Attentioncited by 168
- 2023Large Language Models Are Latent Variable Models: Explaining and Finding Good Demonstrations for In-Context Learningcited by 149
- 2016A vector-contraction inequality for Rademacher complexitiescited by 141
- 2021SOFT: Softmax-free Transformer with Linear Complexitycited by 128
- 2023What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalizationcited by 112
- 2023Uncovering mesa-optimization algorithms in Transformerscited by 94
- 2016Orthogonal Random Featurescited by 89
- 2022The Dual Form of Neural Networks Revisited: Connecting Test Time Predictions to Training Patterns via Spotlights of Attentioncited by 45
- 2023CausalLM is not optimal for in-context learningcited by 26
- 2023Non-Parametric Representation Learning with Kernelscited by 11
- 2023Simplex Random Featurescited by 9
Built on by
Citing papers per year: 2024: 3; 2025: 5; 2026: 7.
15 papers.
Sort:
By area:
- 2024Batch-ICL: Effective, Efficient, and Order-Agnostic In-Context Learningcited by 20
- 2024VisLingInstruct: Elevating Zero-Shot Learning in Multi-Modal Language Models with Autonomous Instruction Optimizationcited by 16
- 2025Provable In-Context Learning of Nonlinear Regression with Transformerscited by 4
- 2024Multimodal Contrastive In-Context Learningcited by 3
- 2025Review of Hallucination Understanding in Large Language and Vision Modelscited by 2
- 2026Modality-free Graph In-context Alignmentcited by 2
- 2025Brewing Knowledge in Context: Distillation Perspectives on In-Context Learningcited by 1
- 2025Supervised learning pays attentioncited by 1
- 2026Enhancing Large Language Models for Time-Series Forecasting via Vector-Injected In-Context Learningcited by 1
- 2026HIFICL: High-Fidelity In-Context Learning for Multimodal Taskscited by 1
- 2026Transformers Learn Robust In-Context Regression under Distributional Uncertaintycited by 1
- 2025The Prompt is Mightier than the Examplecited by 0
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learning29 Sep 2026
- 2026In-Context Optimization for Retrieval-Augmented Generation: A Gradient-Descent Perspective25 May 2026
- 2026IWP: Token Pruning as Implicit Weight Pruning in Large Vision Language Models1 Apr 2026
- 2026Transformers Learn Robust In-Context Regression under Distributional Uncertainty19 Mar 2026
- 2026Modality-free Graph In-context Alignment13 Mar 2026
- 2026HIFICL: High-Fidelity In-Context Learning for Multimodal Tasks13 Mar 2026
- 2026Enhancing Large Language Models for Time-Series Forecasting via Vector-Injected In-Context Learning12 Jan 2026
- 2025Supervised learning pays attention10 Dec 2025
- 2025Review of Hallucination Understanding in Large Language and Vision Models26 Sep 2025
- 2025Provable In-Context Learning of Nonlinear Regression with Transformers28 Jul 2025
- 2025Brewing Knowledge in Context: Distillation Perspectives on In-Context Learning13 Jun 2025
- 2025The Prompt is Mightier than the Example24 May 2025
- 2026IWP: Token Pruning as Implicit Weight Pruning in Large Vision Language Models1 Apr 2026
- 2026HIFICL: High-Fidelity In-Context Learning for Multimodal Tasks13 Mar 2026
- 2024VisLingInstruct: Elevating Zero-Shot Learning in Multi-Modal Language Models with Autonomous Instruction Optimization12 Feb 2024
- 2025The Prompt is Mightier than the Examplecited by 0
- 2025The Prompt is Mightier than the Example24 May 2025
- 2024Batch-ICL: Effective, Efficient, and Order-Agnostic In-Context Learningcited by 20
- 2025Provable In-Context Learning of Nonlinear Regression with Transformerscited by 4
- 2024Multimodal Contrastive In-Context Learningcited by 3
- 2025Review of Hallucination Understanding in Large Language and Vision Modelscited by 2
- 2026Modality-free Graph In-context Alignmentcited by 2
- 2025Brewing Knowledge in Context: Distillation Perspectives on In-Context Learningcited by 1
- 2025Supervised learning pays attentioncited by 1
- 2026Enhancing Large Language Models for Time-Series Forecasting via Vector-Injected In-Context Learningcited by 1
- 2026Transformers Learn Robust In-Context Regression under Distributional Uncertaintycited by 1
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learningcited by 0
- 2026Theory on Attention Dynamics for Out-of-Distribution In-Context Learning29 Sep 2026
- 2026Transformers Learn Robust In-Context Regression under Distributional Uncertainty19 Mar 2026
- 2026Modality-free Graph In-context Alignment13 Mar 2026
- 2026Enhancing Large Language Models for Time-Series Forecasting via Vector-Injected In-Context Learning12 Jan 2026
- 2025Supervised learning pays attention10 Dec 2025
- 2025Review of Hallucination Understanding in Large Language and Vision Models26 Sep 2025
- 2025Provable In-Context Learning of Nonlinear Regression with Transformers28 Jul 2025
- 2025Brewing Knowledge in Context: Distillation Perspectives on In-Context Learning13 Jun 2025
- 2024Multimodal Contrastive In-Context Learning23 Aug 2024
- 2024Batch-ICL: Effective, Efficient, and Order-Agnostic In-Context Learning12 Jan 2024