Lune

ICLR2024Top-tier venue

Learning the greatest common divisor: explaining transformer predictions

François Charton

Abstract

The predictions of small transformers, trained to calculate the greatest common divisor (GCD) of two positive integers, can be fully characterized by looking at model inputs and outputs. As training proceeds, the model learns a list D\mathcal D of integers, products of divisors of the base used to represent integers and small primes, and predicts the largest element of D\mathcal D that divides both inputs. Training distributions impact performance. Models trained from uniform operands only learn a handful of GCD (up to 3838 GCD ≤100\leq100). Log-uniform operands boost performance to 7373 GCD ≤100\leq 100, and a log-uniform distribution of outcomes (i.e. GCD) to 9191. However, training from uniform (balanced) GCD breaks explainability.

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.

11 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • Dichotomy of Early and Late Phase Implicit Biases Can Provably Induce Grokking cites Towards Understanding Grokking: An Effective Theory of Representation Learning
  • Teaching Arithmetic to Small Transformers cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
  • The Clock and the Pizza: Two Stories in Mechanistic Explanation of Neural Networks cites Towards Understanding Grokking: An Effective Theory of Representation Learning
  • Uncovering a Universal Abstract Algorithm for Modular Addition in Neural Networks cites Towards Understanding Grokking: An Effective Theory of Representation Learning
  • Uncovering a Universal Abstract Algorithm for Modular Addition in Neural Networks cites Dichotomy of Early and Late Phase Implicit Biases Can Provably Induce Grokking
  • Uncovering a Universal Abstract Algorithm for Modular Addition in Neural Networks cites The Clock and the Pizza: Two Stories in Mechanistic Explanation of Neural Networks
  • Learning to compute Gröbner bases cites Deep Learning For Symbolic Mathematics
  • Efficient numeracy in language models through single-token number embeddings cites Teaching Arithmetic to Small Transformers
  • Efficient numeracy in language models through single-token number embeddings cites Chain-of-Thought Prompting Elicits Reasoning in Large Language Models
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers11

  1. Dichotomy of Early and Late Phase Implicit Biases Can Provably Induce GrokkingKaifeng Lyu, Jikai Jin, Zhiyuan Li, Simon Shaolei Du et al.ICLR 2024 · 71 citations
  2. Uncovering a Universal Abstract Algorithm for Modular Addition in Neural NetworksGavin McCracken, Gabriela Moisescu-Pareja, Vincent Létourneau, Doina Precup et al.NeurIPS 2025 · 14 citations
  3. Learning to compute Gröbner basesHiroshi Kera, Yuki Ishihara, Yuta Kambe, Tristan Vaccon et al.NeurIPS 2024 · 9 citations
  4. Beyond Model Collapse: Scaling Up with Synthesized Data Requires VerificationYunzhen Feng, Elvis Dohmatob, Pu Yang, François Charton et al.ICLR 2025 · 6 citations
  5. Efficient numeracy in language models through single-token number embeddingsLinus Kreitner, Paul Hager, Jonathan Mengedoht, Georgios Kaissis et al.ICML 2026 · 5 citations

Builds on8

  1. Chain-of-Thought Prompting Elicits Reasoning in Large Language ModelsJason Wei, Xuezhi Wang, Dale Schuurmans, Maarten Bosma et al.NeurIPS 2022 · 22,562 citations
  2. Deep Learning For Symbolic MathematicsGuillaume Lample, François ChartonICLR 2020 · 477 citations
  3. Towards Understanding Grokking: An Effective Theory of Representation LearningZiming Liu, Ouail Kitouni, Niklas Nolte, Eric J. Michaud et al.NeurIPS 2022 · 299 citations
  4. The Clock and the Pizza: Two Stories in Mechanistic Explanation of Neural NetworksZiqian Zhong, Ziming Liu, Max Tegmark, Jacob AndreasNeurIPS 2023 · 181 citations
  5. Teaching Arithmetic to Small TransformersNayoung Lee, Kartik Sreenivasan, Jason D. Lee, Kangwook Lee et al.ICLR 2024 · 128 citations

Related papers

  1. Algorithmic Capabilities of Random TransformersZiqian Zhong, Jacob AndreasNeurIPS 2024 · 23 citations
  2. (How) Can Transformers Predict Pseudo-Random Numbers?Tao Tao, Darshil Doshi, Dayal Singh Kalra, Tianyu He et al.ICML 2025
  3. Learning Pseudorandom Numbers with Transformers: Permuted Congruential Generators, Curricula, and InterpretabilityTao Tao, Maissam BarkeshliICLR 2026
  4. How does GPT-2 compute greater-than?: Interpreting mathematical abilities in a pre-trained language modelMichael Hanna, Ollie Liu, Alexandre VariengienNeurIPS 2023 · 251 citations
  5. Learning to grok: Emergence of in-context learning and skill composition in modular arithmetic tasksTianyu He, Darshil Doshi, Aritra Das, Andrey GromovNeurIPS 2024 · 52 citations
Dusk over the sea between two cliffs drawn in fine vertical lines