Carrying over algorithm in transformers
Not on the map. Why?
Abstract (arXiv)
Addition is perhaps one of the simplest arithmetic tasks one can think of and is usually performed using the carrying over algorithm. This algorithm consists of two tasks: adding digits in the same position and carrying over a one whenever necessary. We study how transformer models implement this algorithm and how the two aforementioned tasks are allocated to different parts of the network. We first focus on two-layer encoder-only models and show that the carrying over algorithm is implemented in a modular fashion. The first layer is mostly responsible for adding digits in the same position. The second layer first decides, in the attention, which positions need a carried one or not, and then performs the carrying of the one in the final MLP. We provide a simple way of precisely identifying which neurons are responsible for that task. This implementation of the carrying over algorithm occurs across a range of hyperparameters for two as well as three-layer models. For small decoder-only models, we observe the same implementation and provide suggestive evidence for its existence in three 7B large language models.
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 26 of its 37 references that are in the map. First posted on arXiv 15 Jan 2024.
Builds on
26 of 37 references.
References · 26
- 2017Attention Is All You Needcited by 59,932
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2014Adam: A Method for Stochastic Optimizationcited by 36,960
- 2023GPT-4 Technical Reportcited by 18,132
- 2023LLaMA: Open and Efficient Foundation Language Modelscited by 13,958
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
- 2023Mistral 7Bcited by 3,065
- 2022Solving Quantitative Reasoning Problems with Language Modelscited by 1,359
- 2023PaLM 2 Technical Reportcited by 1,154
- 2022In-context Learning and Induction Headscited by 930
- 2022Toy Models of Superpositioncited by 928
14 more
- 2023Progress measures for grokking via mechanistic interpretabilitycited by 822
- 2023Zephyr: Direct Distillation of LM Alignmentcited by 498
- 2023Llemma: An Open Language Model For Mathematicscited by 385
- 2023The Impact of Positional Encoding on Length Generalization in Transformerscited by 319
- 2023MathPrompter: Mathematical Reasoning using Large Language Modelscited by 236
- 2023What Algorithms can Transformers Learn? A Study in Length Generalizationcited by 198
- 2022Hidden Progress in Deep Learning: SGD Learns Parities Near the Computational Limitcited by 184
- 2021Thinking Like Transformerscited by 182
- 2021Investigating the Limitations of Transformers with Simple Arithmetic Taskscited by 136
- 2023Teaching Arithmetic to Small Transformerscited by 121
- 2023Length Generalization in Arithmetic Transformerscited by 64
- 2021The Neural Data Router: Adaptive Control Flow in Transformers Improves Systematic Generalizationcited by 62
- 2018FIRST: A Framework for Optimizing Information Quality in Mobile Crowdsensing Systemscited by 50
- 2021How to decay your learning ratecited by 11
Built on by
Not cited yet.