mlsanityData to 7 Oct 2026

How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?

arXiv 2402.15607 ↗First posted 23 Feb 2024cs.LGcited by 35

Not on the map. Why?

Abstract (arXiv)

Transformer-based large language models have displayed impressive in-context learning capabilities, where a pre-trained model can handle new tasks without fine-tuning by simply augmenting the query with some input-output examples from that task. Despite the empirical success, the mechanics of how to train a Transformer to achieve ICL and the corresponding ICL capacity is mostly elusive due to the technical challenges of analyzing the nonconvex training problems resulting from the nonlinear self-attention and nonlinear activation in Transformers. To the best of our knowledge, this paper provides the first theoretical analysis of the training dynamics of Transformers with nonlinear self-attention and nonlinear MLP, together with the ICL generalization capability of the resulting model. Focusing on a group of binary classification tasks, we train Transformers using data from a subset of these tasks and quantify the impact of various factors on the ICL generalization performance on the remaining unseen tasks with and without data distribution shifts. We also analyze how different components in the learned Transformers contribute to the ICL performance. Furthermore, we provide the first theoretical analysis of how model pruning affects ICL performance and prove that proper magnitude-based pruning can have a minimal impact on ICL while reducing inference costs. These theoretical findings are justified through numerical experiments.

Key facts. Cited by 35 papers in the map (data through 7 Oct 2026). Builds on 57 of its 74 references that are in the map. First posted on arXiv 23 Feb 2024.

Builds on

57 of 74 references.

References · 57

  1. 2017Attention Is All You Needcited by 59,932
  2. 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,456
  3. 2020Language Models are Few-Shot Learnerscited by 32,199
  4. 2023GPT-4 Technical Reportcited by 18,132
  5. 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
  6. 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
  7. 2021Zero-Shot Text-to-Image Generationcited by 4,276
  8. 2018Neural Tangent Kernel: Convergence and Generalization in Neural Networkscited by 2,597
  9. 2015Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman Codingcited by 2,291
  10. 2021What Makes Good In-Context Examples for GPT-3?cited by 1,184
  11. 2023SparseGPT: Massive Language Models Can Be Accurately Pruned in One-Shotcited by 1,090
  12. 2018A Convergence Theory for Deep Learning via Over-Parameterizationcited by 784
38 more
  1. 2023A Simple and Effective Pruning Approach for Large Language Modelscited by 776
  2. 2022Transformers learn in-context by gradient descentcited by 714
  3. 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
  4. 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
  5. 2023LLM-Pruner: On the Structural Pruning of Large Language Modelscited by 643
  6. 2021Learning To Retrieve Prompts for In-Context Learningcited by 641
  7. 2016Learning Structured Sparsity in Deep Neural Networkscited by 538
  8. 2017ThiNet: A Filter Level Pruning Method for Deep Neural Network Compressioncited by 438
  9. 2018Learning and Generalization in Overparameterized Neural Networks, Going Beyond Two Layerscited by 340
  10. 2023Trained Transformers Learn Linear Models In-Contextcited by 331
  11. 2020Towards Understanding Ensemble, Knowledge Distillation and Self-Distillation in Deep Learningcited by 292
  12. 2023Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selectioncited by 291
  13. 2023Transformers learn to implement preconditioned gradient descent for in-context learningcited by 274
  14. 2019Generalization Bounds of Stochastic Gradient Descent for Wide and Deep Neural Networkscited by 221
  15. 2023Transformers as Algorithms: Generalization and Stability in In-context Learningcited by 220
  16. 2022WANLI: Worker and AI Collaboration for Natural Language Inference Dataset Creationcited by 200
  17. 2022Self-Adaptive In-Context Learning: An Information Compression Perspective for In-Context Example Selection and Orderingcited by 158
  18. 2019An Improved Analysis of Training Over-parameterized Deep Neural Networkscited by 120
  19. 2023In-Context Convergence of Transformerscited by 112
  20. 2023Scan and Snap: Understanding Training Dynamics and Token Composition in 1-layer Transformercited by 101
  21. 2017Recovery Guarantees for One-hidden-layer Neural Networkscited by 94
  22. 2023How Many Pretraining Tasks Are Needed for In-Context Learning of Linear Regression?cited by 93
  23. 2022Vision Transformers provably learn spatial structurecited by 92
  24. 2023How Do Transformers Learn Topic Structure: Towards a Mechanistic Understandingcited by 85
  25. 2020Learning Parities with Neural Networkscited by 77
  26. 2023A Theoretical Understanding of Shallow Vision Transformers: Learning, Generalization, and Sample Complexitycited by 77
  27. 2023How Do Transformers Learn In-Context Beyond Simple Functions? A Case Study on Learning with Representationscited by 72
  28. 2023Transformers as Support Vector Machinescited by 67
  29. 2023Transformers Implement Functional Gradient Descent to Learn Non-Linear Functions In Contextcited by 63
  30. 2023Max-Margin Token Selection in Attention Mechanismcited by 57
  31. 2023JoMA: Demystifying Multilayer Transformers via JOint Dynamics of MLP and Attentioncited by 52
  32. 2022A Theoretical Analysis on Feature Learning in Neural Networks: Emergence from Inputs and Advantage over Fixed Featurescited by 49
  33. 2023On the Role of Attention in Prompt-tuningcited by 49
  34. 2023On the Optimization and Generalization of Multi-head Attentioncited by 37
  35. 2023Patch-level Routing in Mixture-of-Experts is Provably Sample-efficient for Convolutional Neural Networkscited by 35
  36. 2022Generalization Guarantee of Training Graph Convolutional Networks with Graph Topology Samplingcited by 23
  37. 2018Guaranteed Recovery of One-Hidden-Layer Neural Networks via Cross Entropycited by 22
  38. 2024Provably learning a multi-head attention layercited by 21

50 most cited of 57 All 57 (JSON)

Built on by

Cited by year (2026 to 7 Oct)

Citing papers per year: 2024: 13; 2025: 16; 2026: 6.

35 papers.

Sort:

By area:

  1. 2024From Words to Numbers: Your Large Language Model Is Secretly A Capable Regressor When Given In-Context Examplescited by 55
  2. 2025When is Task Vector Provably Effective for Model Editing? A Generalization Analysis of Nonlinear Transformerscited by 38
  3. 2024Mechanics of Next Token Prediction with Self-Attentioncited by 34
  4. 2024Pretrained transformer efficiently learns low-dimensional target functions in-contextcited by 29
  5. 2024Evaluating the Prompt Steerability of Large Language Modelscited by 26
  6. 2024Can In-context Learning Really Generalize to Out-of-distribution Tasks?cited by 23
  7. 2024A Provably Effective Method for Pruning Experts in Fine-tuned Sparse Mixture-of-Expertscited by 21
  8. 2024What Improves the Generalization of Graph Transformers? A Theoretical Dive into the Self-attention and Positional Encodingcited by 14
  9. 2024Training Nonlinear Transformers for Chain-of-Thought Inference: A Theoretical Generalization Analysiscited by 14
  10. 2024Dissecting the Interplay of Attention Paths in a Statistical Mechanics Theory of Transformerscited by 9
  11. 2024Learning on Transformers is Provable Low-Rank and Sparse: A One-layer Analysiscited by 8
  12. 2024Training Dynamics of Transformers to Recognize Word Co-occurrence via Gradient Flow Analysiscited by 8
23 more
  1. 2025Out-of-Distribution Generalization of In-Context Learning: A Low-Dimensional Subspace Perspectivecited by 5
  2. 2025Provable In-Context Learning of Nonlinear Regression with Transformerscited by 4
  3. 2024AERO: Entropy-Guided Framework for Private LLM Inferencecited by 3
  4. 2025Merging Smarter, Generalizing Better: Enhancing Model Merging on OOD Datacited by 3
  5. 2025Asymptotic Study of In-context Learning with Random Transformers through Equivalent Modelscited by 3
  6. 2024Differentially Private Kernel Density Estimationcited by 2
  7. 2025Understanding Generalization in Transformers: Error Bounds and Training Dynamics Under Benign and Harmful Overfittingcited by 2
  8. 2025How Can Mamba Learn In Context with Outliers and Generalize Provably?cited by 2
  9. 2025Softmax ≥ Linear: Transformers may learn to classify in-context by kernel gradient descentcited by 2
  10. 2025Transformers Provably Learn Directed Acyclic Graphs via Kernel-Guided Mutual Informationcited by 2
  11. 2025Multi-Layer Attention is the Amplifier of Demonstration Effectivenesscited by 1
  12. 2025Mamba Can Learn Low-Dimensional Targets In-Context via Test-Time Feature Learningcited by 1
  13. 2025How Data Mixing Shapes In-Context Learning: Asymptotic Equivalence for Transformers with MLPscited by 1
  14. 2026HIFICL: High-Fidelity In-Context Learning for Multimodal Taskscited by 1
  15. 2025In-Context Learning with Hypothesis-Class Guidancecited by 0
  16. 2025To Theoretically Understand Transformer-Based In-Context Learning for Optimizing CSMAcited by 0
  17. 2025Optimality and NP-Hardness of Transformers in Learning Markovian Dynamical Functionscited by 0
  18. 2025Mixture-of-Transformers Learn Faster: A Theoretical Study on Classification Problemscited by 0
  19. 2026When Does Context Help? Error Dynamics of Contextual Information in Large Language Modelscited by 0
  20. 2026Robust Heterogeneous Analog-Digital Computing for Mixture-of-Experts Models with Theoretical Generalization Guaranteescited by 0
  21. 2026Transformers Learn the Optimal DDPM Denoiser for Multi-Token GMMscited by 0
  22. 2026Understanding Generalization and Forgetting in In-Context Continual Learningcited by 0
  23. 2026The Effect of Training Task Diversity on In-Context Learning through the Lens of Low-Dimensional Subspacescited by 0