HackerPapers

arXiv:2406.03445cs.LG

Pre-trained Large Language Models Use Fourier Features to Compute Addition

Tianyi Zhou, Deqing Fu, Vatsal Sharan, Robin Jia

Early discovery. Linked by one identifiable commenter. This paper is outside the main ranking; a mention is not an endorsement.

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.

arXiv comments
Journal reference
DOI
Subjects
cs.LGMachine Learning cs.CLComputation and Language

On Hacker News

Linked by 1 identifiable commenter in 1 comment across 1 thread, from Aug 2025 to Aug 2025. Found in 1 HN submission from Feb 2025 to Feb 2025. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments1 thread

    • "Isn't it just temporary, and AI will get better?" There are 2 instances of the word "understand" in the first paragraph, 3 if you count the beginning of the second. In my book, "understanding" is a synonym for "intelligence" - the roots of the word are "read between the lines"…

      astrobe_View on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.