Pre-trained Large Language Models Use Fourier Features to Compute Addition
Tianyi Zhou, Deqing Fu, Vatsal Sharan, Robin Jia
Abstract
Pre-trained large language models (LLMs) exhibit impressive mathematical reasoning capabilities, yet how they compute basic arithmetic, such as addition, remains unclear. This paper shows that pre-trained LLMs add numbers using Fourier features -- dimensions in the hidden state that represent numbers via a set of features sparse in the frequency domain. Within the model, MLP and attention layers use Fourier features in complementary ways: MLP layers primarily approximate the magnitude of the answer using low-frequency features, while attention layers primarily perform modular addition (e.g., computing whether the answer is even or odd) using high-frequency features. Pre-training is crucial for this mechanism: models trained from scratch to add numbers only exploit low-frequency features, leading to lower accuracy. Introducing pre-trained token embeddings to a randomly initialized model rescues its performance. Overall, our analysis demonstrates that appropriate pre-trained representations (e.g., Fourier features) can unlock the ability of Transformers to learn precise mechanisms for algorithmic tasks.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
14 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection cites Language Models are Few-Shot Learners
- Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection cites Transformers Learn In-Context by Gradient Descent
- Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm Selection cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- FoNE: Precise Single-Token Number Embeddings via Fourier Features cites Language Models are Few-Shot Learners
- FoNE: Precise Single-Token Number Embeddings via Fourier Features cites Fourier Features Let Networks Learn High Frequency Functions in Low Dimensional Domains
- Sequential Group Composition: A Window into the Mechanics of Deep Learning cites Alternating Gradient Flows: A Theory of Feature Learning in Two-layer Neural Networks
- A Implies B: Circuit Analysis in LLMs for Propositional Logical Reasoning cites Language Models are Few-Shot Learners
- Transformers Learn In-Context by Gradient Descent cites Language Models are Few-Shot Learners
- Transformers Learn In-Context by Gradient Descent cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
- What Can Transformers Learn In-Context? A Case Study of Simple Function Classes cites Language Models are Few-Shot Learners
- Alternating Gradient Flows: A Theory of Feature Learning in Two-layer Neural Networks cites Language Models are Few-Shot Learners
- Alternating Gradient Flows: A Theory of Feature Learning in Two-layer Neural Networks cites Transformers Learn In-Context by Gradient Descent
- Alternating Gradient Flows: A Theory of Feature Learning in Two-layer Neural Networks cites What Can Transformers Learn In-Context? A Case Study of Simple Function Classes
Cited by top-tier papers14
- FoNE: Precise Single-Token Number Embeddings via Fourier FeaturesTianyi Zhou, Deqing Fu, Mahdi Soltanolkotabi, Robin Jia et al.ICLR 2026 · 24 citations
- A Implies B: Circuit Analysis in LLMs for Propositional Logical ReasoningGuanzhe Hong, Nishanth Dikkala, Enming Luo, Cyrus Rashtchian et al.NeurIPS 2025 · 17 citations
- Alternating Gradient Flows: A Theory of Feature Learning in Two-layer Neural NetworksDaniel Kunin, Giovanni Luca Marchetti, Feng Chen, Dhruva Karkada et al.NeurIPS 2025 · 15 citations
- Sequential Group Composition: A Window into the Mechanics of Deep LearningGiovanni Luca Marchetti, Daniel Kunin, Adele Myers, Francisco Acosta et al.ICML 2026 · 8 citations
- Path Channels and Plan Extension Kernels: a Mechanistic Description of Planning in a Sokoban RNNMohammad Taufeeque, Aaron David Tucker, Adam Gleave, Adrià Garriga-AlonsoICLR 2026 · 5 citations
Builds on17
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- Fourier Features Let Networks Learn High Frequency Functions in Low Dimensional DomainsMatthew Tancik, Pratul P. Srinivasan, Ben Mildenhall, Sara Fridovich-Keil et al.NeurIPS 2020 · 4,036 citations
- What Can Transformers Learn In-Context? A Case Study of Simple Function ClassesShivam Garg, Dimitris Tsipras, Percy Liang, Gregory ValiantNeurIPS 2022 · 883 citations
- Transformers Learn In-Context by Gradient DescentJohannes von Oswald, Eyvind Niklasson, Ettore Randazzo, João Sacramento et al.ICML 2023 · 729 citations
- Transformers as Statisticians: Provable In-Context Learning with In-Context Algorithm SelectionYu Bai, Fan Chen, Huan Wang, Caiming Xiong et al.NeurIPS 2023 · 356 citations
Related papers
- How do autoregressive transformers solve full addition?Wang Peixu, Chen Yu, Yu Ming, Cheng XiangEMNLP 2025
- A Mechanistic Interpretation of Arithmetic Reasoning in Language Models using Causal Mediation AnalysisAlessandro Stolfo, Yonatan Belinkov, Mrinmaya SachanEMNLP 2023 · 11 citations
- Scaling Behavior for Large Language Models regarding Numeral Systems: An Example using PythiaZhejian Zhou, Jiayu Wang, Dahua Lin, Kai ChenEMNLP Findings 2024
- Algorithmic Capabilities of Random TransformersZiqian Zhong, Jacob AndreasNeurIPS 2024 · 23 citations
- How Numerical Precision Affects Arithmetical Reasoning Capabilities of LLMsGuhao Feng, Kai Yang, Yuntian Gu, Xinyue Ai et al.ACL Findings 2025 · 5 citations
