NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Modular Arithmetic: Language Models Solve Math Digit by Digit

Tanja Baeumel, Daniil Gurgurov, Yusser Al Ghussin, Josef van Genabith, Simon OstermannarXiv 2025 · DOI

Introduction

Despite the remarkable capabilities of Large Language Models (LLMs) in mathematical reasoning, the internal mechanisms they employ to solve arithmetic problems have largely remained a "black box." A central question in mechanistic interpretability is whether these models follow a coherent algorithmic process, rely on simple heuristics, or merely memorize training data. Recent research has begun to peel back these layers, revealing that LLMs do not treat numbers as monolithic entities. Instead, they appear to process multi-digit arithmetic through highly specialized, modular neural pathways.

Methodology: Identifying Digit-Specific Circuits

To investigate the internal logic of LLMs, researchers employed a two-stage mechanistic interpretability framework. The goal was to identify and verify "digit-position-specific circuits"—distinct groups of neurons responsible for calculating individual digits (units, tens, hundreds) independently.

  1. Circuit Identification: Using the Fisher Score, a supervised feature selection method, the researchers identified Multi-Layer Perceptron (MLP) neurons most sensitive to specific digit-level subtasks. This allowed them to map which neurons fire specifically when the model calculates the units, tens, or hundreds place.
  2. Causal Verification: To prove these identified neurons were functionally responsible for the output, the team performed "interchange interventions" (activation patching). By taking neural activations from a "source" problem (e.g., $261 + 512 = 773$) and injecting them into the corresponding circuit of a "base" problem (e.g., $347 + 231 = 578$), they could observe if the model's output changed in a predictable, digit-specific manner.
LLMs utilize independent neural circuits for each digit position during arithmetic tasks.

Key Insights: Modularity and Independence

The study's findings suggest a surprisingly structured approach to arithmetic within transformer architectures:

  • Modular Architecture: LLMs utilize distinct, non-overlapping groups of neurons for different digit positions. For instance, the neurons calculating the "units" place are largely separate from those calculating the "hundreds" place.
  • Parallel Processing: These circuits operate largely in parallel. Intervening on a specific circuit (e.g., the units circuit) can change that specific digit in the final answer while leaving other digits unaffected.
  • Robustness to Tokenization: Interestingly, this modularity persists even in models like Llama 3, where a 3-digit number is represented as a single atomic token. The model internally "unpacks" these tokens to perform digit-wise computation.
  • Integration of Heuristics: Previously identified "heuristic" neurons (such as those detecting parity) were found to be integrated components within these larger, position-specific circuits.

Experimental Results

The researchers validated their findings across several state-of-the-art models, including LLaMA3-8B, LLaMA3-70B, OLMo 2 7B, and Gemma 2 9B.

  • High Specificity: In Llama 3 8B, interventions on the hundreds-digit circuit increased the target digit's probability by 45.56 percentage points, with negligible impact on other digit positions.
  • Minimal Overlap: At high sensitivity thresholds, the overlap between units, tens, and hundreds circuits was found to be less than 2%, confirming high modularity.
Causal intervention demonstrates that swapping activations in the units-digit circuit selectively changes only the units digit of the result.

Limitations and Future Directions

While this work provides a clear map of digit-wise addition and subtraction, several questions remain. The study focused primarily on MLP layers and operations without complex "carry" logic. While preliminary tests on carry bits suggest they are handled by separate mechanisms, a full mapping of carry-over circuitry is a vital next step. Furthermore, it remains to be seen if more interdependent operations, such as multiplication or division, exhibit similar modularity or require more integrated neural structures.

Summary updated

BibTeX
@misc{baeumel2025modular,
  author = {Tanja Baeumel and Daniil Gurgurov and Yusser Al Ghussin and Josef van Genabith and Simon Ostermann},
  title = {{Modular Arithmetic: Language Models Solve Math Digit by Digit}},
  year = {2025},
  eprint = {2508.02513},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.02513},
}
Figure