Trainable Transformer in Transformer
Not on the map. Why?
Abstract (arXiv)
Recent works attribute the capability of in-context learning (ICL) in large pre-trained language models to implicitly simulating and fine-tuning an internal model (e.g., linear or 2-layer MLP) during inference. However, such constructions require large memory overhead, which makes simulation of more sophisticated internal models intractable. In this work, we propose an efficient construction, Transformer in Transformer (in short, TinT), that allows a transformer to simulate and fine-tune complex models internally during inference (e.g., pre-trained language models). In particular, we introduce innovative approximation techniques that allow a TinT model with less than 2 billion parameters to simulate and fine-tune a 125 million parameter transformer model within a single forward pass. TinT accommodates many common transformer variants and its design ideas also improve the efficiency of past instantiations of simple models inside transformers. We conduct end-to-end experiments to validate the internal fine-tuning procedure of TinT on various language modeling and downstream tasks. For example, even with a limited one-step budget, we observe TinT for a OPT-125M model improves performance by 4-16% absolute on average compared to OPT-125M. These findings suggest that large pre-trained language models are capable of performing intricate subroutines. To facilitate further work, a modular and extensible codebase for TinT is included.
Key facts. Cited by 17 papers in the map (data through 7 Oct 2026). Builds on 60 of its 87 references that are in the map. First posted on arXiv 3 Jul 2023.
Builds on
60 of 87 references.
References · 60
- 2017Attention Is All You Needcited by 59,932
- 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
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2022PaLM: Scaling Language Modeling with Pathwayscited by 5,304
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
- 2022OPT: Open Pre-trained Transformer Language Modelscited by 3,464
- 2016Gaussian Error Linear Units (GELUs)cited by 3,431
- 2016Pointer Sentinel Mixture Modelscited by 2,992
- 2022Emergent Abilities of Large Language Modelscited by 2,483
- 2015Character-level Convolutional Networks for Text Classificationcited by 2,293
- 2022BLOOM: A 176B-Parameter Open-Access Multilingual Language Modelcited by 1,968
38 more
- 2020GLU Variants Improve Transformercited by 1,724
- 2016Concrete Problems in AI Safetycited by 1,582
- 2018Group Normalizationcited by 1,514
- 2019Root Mean Square Layer Normalizationcited by 1,425
- 2021Improving language models by retrieving from trillions of tokenscited by 1,278
- 2020Leveraging Passage Retrieval with Generative Models for Open Domain Question Answeringcited by 1,203
- 2022Interpretability in the Wild: a Circuit for Indirect Object Identification in GPT-2 smallcited by 1,130
- 2021Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolationcited by 1,085
- 2021A General Language Assistant as a Laboratory for Alignmentcited by 1,023
- 2022Atlas: Few-shot Learning with Retrieval Augmented Language Modelscited by 940
- 2022In-context Learning and Induction Headscited by 930
- 2021An Explanation of In-context Learning as Implicit Bayesian Inferencecited by 915
- 2022Few-Shot Parameter-Efficient Fine-Tuning is Better and Cheaper than In-Context Learningcited by 886
- 2023Progress measures for grokking via mechanistic interpretabilitycited by 822
- 2022Transformers learn in-context by gradient descentcited by 714
- 2022What Can Transformers Learn In-Context? A Case Study of Simple Function Classescited by 700
- 2023Towards Automated Circuit Discovery for Mechanistic Interpretabilitycited by 700
- 2022What learning algorithm is in-context learning? Investigations with linear modelscited by 671
- 2018Scalable agent alignment via reward modeling: a research directioncited by 438
- 2023Fine-Tuning Language Models with Just Forward Passescited by 337
- 2018Generating Wikipedia by Summarizing Long Sequencescited by 333
- 2023Trained Transformers Learn Linear Models In-Contextcited by 331
- 2022Data Distributional Properties Drive Emergent In-Context Learning in Transformerscited by 303
- 2022UL2: Unifying Language Learning Paradigmscited by 292
- 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
- 2022Transformers Learn Shortcuts to Automatacited by 260
- 2021Surface Form Competition: Why the Highest Probability Answer Isn't Always Rightcited by 256
- 2016Equilibrium Propagation: Bridging the Gap Between Energy-Based Models and Backpropagationcited by 251
- 2022Exploring Length Generalization in Large Language Modelscited by 204
- 2021Thinking Like Transformerscited by 182
- 2016Using Fast Weights to Attend to the Recent Pastcited by 161
- 2021Inductive Biases and Variable Creation in Self-Attention Mechanismscited by 144
- 2023A Toy Model of Universality: Reverse Engineering How Networks Learn Group Operationscited by 141
- 2019On the Turing Completeness of Modern Neural Network Architecturescited by 129
- 2023The Learnability of In-Context Learningcited by 126
- 2023What and How does In-Context Learning Learn? Bayesian Model Averaging, Parameterization, and Generalizationcited by 112
- 2021Self-Attention Networks Can Process Bounded Hierarchical Languagescited by 105
50 most cited of 60 All 60 (JSON)
Built on by
Citing papers per year: 2023: 10; 2024: 6; 2025: 1.
17 papers.
Sort:
By area:
- 2023In-Context Unlearning: Language Models as Few Shot Unlearnerscited by 214
- 2024Can Looped Transformers Learn to Implement Multi-step Gradient Descent for In-context Learning?cited by 60
- 2024Why Larger Language Models Do In-context Learning Differently?cited by 44
- 2023A Fast Optimization View: Reformulating Single Layer Attention in LLM Based on Tensor and SVM Trick, and Solving It in Matrix Multiplication Timecited by 30
- 2024The Fine-Grained Complexity of Gradient Computation for Training Large Language Modelscited by 30
- 2023How to Protect Copyright Data in Optimization of Large Language Models?cited by 26
- 2024Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannotcited by 21
- 2023Why Softmax Attention Outperforms Linear Attentioncited by 15
- 2023Unmasking Transformers: A Theoretical Approach to Data Recovery via Attention Weightscited by 11
- 2024On the Role of Depth and Looping for In-Context Learning with Task Diversitycited by 11
- 2023Local Convergence of Approximate Newton Method for Two Layer Nonlinear Regressioncited by 9
- 2023The Expressibility of Polynomial based Attention Schemecited by 7
5 more
- 2023Convergence of Two-Layer Regression with Nonlinear Unitscited by 6
- 2023A Theoretical Insight into Attack and Defense of Gradient Leakage in Transformercited by 6
- 2023One Pass Streaming Algorithm for Super Long Token Attention Approximation in Sublinear Spacecited by 6
- 2025Subquadratic Algorithms and Hardness for Attention with Any Temperaturecited by 4
- 2024Representing Rule-based Chatbots with Transformerscited by 1
- 2025Subquadratic Algorithms and Hardness for Attention with Any Temperature20 May 2025
- 2024On the Role of Depth and Looping for In-Context Learning with Task Diversity29 Oct 2024
- 2024Can Looped Transformers Learn to Implement Multi-step Gradient Descent for In-context Learning?10 Oct 2024
- 2024Representing Rule-based Chatbots with Transformers15 Jul 2024
- 2024Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannot11 Jun 2024
- 2024Why Larger Language Models Do In-context Learning Differently?30 May 2024
- 2024The Fine-Grained Complexity of Gradient Computation for Training Large Language Models7 Feb 2024
- 2023Local Convergence of Approximate Newton Method for Two Layer Nonlinear Regression26 Nov 2023
- 2023One Pass Streaming Algorithm for Super Long Token Attention Approximation in Sublinear Space24 Nov 2023
- 2023A Theoretical Insight into Attack and Defense of Gradient Leakage in Transformer22 Nov 2023
- 2023The Expressibility of Polynomial based Attention Scheme30 Oct 2023
- 2023Unmasking Transformers: A Theoretical Approach to Data Recovery via Attention Weights19 Oct 2023
5 more
- 2023Why Softmax Attention Outperforms Linear Attention18 Oct 2023
- 2023In-Context Unlearning: Language Models as Few Shot Unlearners11 Oct 2023
- 2023A Fast Optimization View: Reformulating Single Layer Attention in LLM Based on Tensor and SVM Trick, and Solving It in Matrix Multiplication Time14 Sep 2023
- 2023How to Protect Copyright Data in Optimization of Large Language Models?23 Aug 2023
- 2023Convergence of Two-Layer Regression with Nonlinear Units16 Aug 2023
- 2023In-Context Unlearning: Language Models as Few Shot Unlearnerscited by 214
- 2024Can Looped Transformers Learn to Implement Multi-step Gradient Descent for In-context Learning?cited by 60
- 2024Why Larger Language Models Do In-context Learning Differently?cited by 44
- 2023A Fast Optimization View: Reformulating Single Layer Attention in LLM Based on Tensor and SVM Trick, and Solving It in Matrix Multiplication Timecited by 30
- 2024The Fine-Grained Complexity of Gradient Computation for Training Large Language Modelscited by 30
- 2023How to Protect Copyright Data in Optimization of Large Language Models?cited by 26
- 2024Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannotcited by 21
- 2023Why Softmax Attention Outperforms Linear Attentioncited by 15
- 2023Unmasking Transformers: A Theoretical Approach to Data Recovery via Attention Weightscited by 11
- 2024On the Role of Depth and Looping for In-Context Learning with Task Diversitycited by 11
- 2023Local Convergence of Approximate Newton Method for Two Layer Nonlinear Regressioncited by 9
- 2023The Expressibility of Polynomial based Attention Schemecited by 7
- 2023Convergence of Two-Layer Regression with Nonlinear Unitscited by 6
12 most cited of 16 All 16 (JSON)
- 2025Subquadratic Algorithms and Hardness for Attention with Any Temperature20 May 2025
- 2024On the Role of Depth and Looping for In-Context Learning with Task Diversity29 Oct 2024
- 2024Can Looped Transformers Learn to Implement Multi-step Gradient Descent for In-context Learning?10 Oct 2024
- 2024Representing Rule-based Chatbots with Transformers15 Jul 2024
- 2024Transformers Provably Learn Sparse Token Selection While Fully-Connected Nets Cannot11 Jun 2024
- 2024Why Larger Language Models Do In-context Learning Differently?30 May 2024
- 2024The Fine-Grained Complexity of Gradient Computation for Training Large Language Models7 Feb 2024
- 2023Local Convergence of Approximate Newton Method for Two Layer Nonlinear Regression26 Nov 2023
- 2023One Pass Streaming Algorithm for Super Long Token Attention Approximation in Sublinear Space24 Nov 2023
- 2023A Theoretical Insight into Attack and Defense of Gradient Leakage in Transformer22 Nov 2023
- 2023The Expressibility of Polynomial based Attention Scheme30 Oct 2023
- 2023Unmasking Transformers: A Theoretical Approach to Data Recovery via Attention Weights19 Oct 2023
12 newest of 16 All 16 (JSON)