Theoretical Understanding of In-Context Learning in Shallow Transformers with Unstructured Data
Not on the map. Why?
Abstract (arXiv)
Large language models (LLMs) are powerful models that can learn concepts at the inference stage via in-context learning (ICL). While theoretical studies, e.g., citezhang2023trained, attempt to explain the mechanism of ICL, they assume the input xi and the output yi of each demonstration example are in the same token (i.e., structured data). However, in real practice, the examples are usually text input, and all words, regardless of their logic relationship, are stored in different tokens (i.e., unstructured data citewibisono2023role). To understand how LLMs learn from the unstructured data in ICL, this paper studies the role of each component in the transformer architecture and provides a theoretical understanding to explain the success of the architecture. In particular, we consider a simple transformer with one/two attention layers and linear regression tasks for the ICL prediction. We observe that (1) a transformer with two layers of (self-)attentions with a look-ahead attention mask can learn from the prompt in the unstructured data, and (2) positional encoding can match the xi and yi tokens to achieve a better ICL performance.
Key facts. Cited by 5 papers in the map (data through 7 Oct 2026). Builds on 23 of its 35 references that are in the map. First posted on arXiv 1 Feb 2024.
Builds on
23 of 35 references.
References · 23
- 2017Attention Is All You Needcited by 59,932
- 2021Masked-attention Mask Transformer for Universal Image Segmentationcited by 2,338
- 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,979
- 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
- 2018Efficient Attention: Attention with Linear Complexitiescited by 366
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
- 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
- 2022cosFormer: Rethinking Softmax in Attentioncited by 212
- 2023In-Context Convergence of Transformerscited by 112
11 more
- 2023Linear attention is (maybe) all you need (to understand transformer optimization)cited by 97
- 2019How Does BERT Answer Questions? A Layer-Wise Analysis of Transformer Representationscited by 63
- 2019Mask-Guided Attention Network for Occluded Pedestrian Detectioncited by 36
- 2022Rewiring with Positional Encodings for Graph Neural Networkscited by 35
- 2017Segmentation-Aware Convolutional Networks Using Local Attention Maskscited by 31
- 2022Linear Complexity Randomized Self-attention Mechanismcited by 31
- 2021Mask Attention Networks: Rethinking and Strengthen Transformercited by 28
- 2020Linear Attention Mechanism: An Efficient Attention for Semantic Segmentationcited by 21
- 2023Dissecting Chain-of-Thought: Compositionality through In-Context Filtering and Learningcited by 19
- 2024Superiority of Multi-Head Attention in In-Context Linear Regressioncited by 17
- 2022Generalized Classification of Satellite Image Time Series with Thermal Positional Encodingcited by 14
Built on by
Citing papers per year: 2024: 3; 2025: 2.
5 papers.
- 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 55
- 2024A Theoretical Understanding of Chain-of-Thought: Coherent Reasoning and Error-Aware Demonstrationcited by 13
- 2025Understanding Task Vectors in In-Context Learning: Emergence, Functionality, and Limitationscited by 8
- 2025Impact of Positional Encoding: Clean and Adversarial Rademacher Complexity for Transformers under In-Context Regressioncited by 2
- 2024Predictive Analysis of Tuberculosis Treatment Outcomes Using Machine Learning: A Karnataka TB Data Study at a Scalecited by 0
- 2025Impact of Positional Encoding: Clean and Adversarial Rademacher Complexity for Transformers under In-Context Regression10 Dec 2025
- 2025Understanding Task Vectors in In-Context Learning: Emergence, Functionality, and Limitations10 Jun 2025
- 2024A Theoretical Understanding of Chain-of-Thought: Coherent Reasoning and Error-Aware Demonstration21 Oct 2024
- 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examples11 Apr 2024
- 2024Predictive Analysis of Tuberculosis Treatment Outcomes Using Machine Learning: A Karnataka TB Data Study at a Scale13 Mar 2024