mlsanityData to 7 Oct 2026

Theoretical Understanding of In-Context Learning in Shallow Transformers with Unstructured Data

arXiv 2402.00743 ↗First posted 1 Feb 2024cs.LG cs.CL stat.MLcited by 5

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

  1. 2017Attention Is All You Needcited by 59,932
  2. 2021Masked-attention Mask Transformer for Universal Image Segmentationcited by 2,338
  3. 2020Transformers are RNNs: Fast Autoregressive Transformers with Linear Attentioncited by 1,979
  4. 2022Transformers learn in-context by gradient descentcited by 714
  5. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
  6. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
  7. 2018Efficient Attention: Attention with Linear Complexitiescited by 366
  8. 2023Trained Transformers Learn Linear Models In-Contextcited by 331
  9. 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
  10. 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 274
  11. 2022cosFormer: Rethinking Softmax in Attentioncited by 212
  12. 2023In-Context Convergence of Transformerscited by 112
11 more
  1. 2023Linear attention is (maybe) all you need (to understand transformer optimization)cited by 97
  2. 2019How Does BERT Answer Questions? A Layer-Wise Analysis of Transformer Representationscited by 63
  3. 2019Mask-Guided Attention Network for Occluded Pedestrian Detectioncited by 36
  4. 2022Rewiring with Positional Encodings for Graph Neural Networkscited by 35
  5. 2017Segmentation-Aware Convolutional Networks Using Local Attention Maskscited by 31
  6. 2022Linear Complexity Randomized Self-attention Mechanismcited by 31
  7. 2021Mask Attention Networks: Rethinking and Strengthen Transformercited by 28
  8. 2020Linear Attention Mechanism: An Efficient Attention for Semantic Segmentationcited by 21
  9. 2023Dissecting Chain-of-Thought: Compositionality through In-Context Filtering and Learningcited by 19
  10. 2024Superiority of Multi-Head Attention in In-Context Linear Regressioncited by 17
  11. 2022Generalized Classification of Satellite Image Time Series with Thermal Positional Encodingcited by 14

Built on by

Cited by year

Citing papers per year: 2024: 3; 2025: 2.

5 papers.