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

Arithmetic Without Algorithms: Language Models Solve Math with a Bag of Heuristics

Yaniv Nikankin, Anja Reusch, Aaron Mueller, Yonatan Belinkov

When Large Language Models (LLMs) solve math problems, are they acting as "stochastic parrots" that simply regurgitate memorized training data, or are they "reasoning engines" executing robust, generalizable algorithms?

According to the ICLR 2025 paper "Arithmetic Without Algorithms: Language Models Solve Math with a Bag of Heuristics," the reality lies in a fascinating, messy middle ground. Through rigorous mechanistic interpretability, researchers have discovered that LLMs rely on an unorganized collection of shortcuts—a "bag of heuristics"—to perform basic arithmetic.

The Core Problem: Generalization vs. Memorization

If a child learns to add, they learn a step-by-step algorithm (like vertical addition) that applies to any two numbers. If a simple computer program memorizes a lookup table, it fails the moment it encounters a novel number pair.

Previous research has successfully identified "circuits"—specific subsets of a neural network responsible for particular tasks—but often stopped short of explaining how those circuits actually function. This paper investigates whether the arithmetic circuits in models like Llama3 and Pythia implement reusable algorithms or just manage memorized patterns. Understanding this mechanism is crucial for predicting when LLMs will fail and for designing models capable of true reasoning.

Key Insights: The "Bag of Heuristics"

The researchers discovered that there is no single, elegant "addition algorithm" hidden within the model's weights. Instead, the model aggregates hundreds of simple, overlapping rules of thumb implemented by specific, individual neurons.

Overview of the 'Bag of Heuristics' mechanism, showing how individual neurons activate for specific mathematical patterns to vote on the final answer.
  • The Voting System: One neuron might activate if an operand is even; another might fire if the expected result is roughly between 150 and 180. The final mathematical answer is simply the aggregated result of these many tiny, specialized "votes."
  • Extreme Sparsity: Arithmetic operations are handled by a remarkably tiny fraction of the model. In Llama3-8B, only about 200 neurons per layer (roughly 1.5% of the Multi-Layer Perceptron) are needed to maintain high mathematical accuracy.
  • Direct vs. Indirect Heuristics: The model utilizes two main types of heuristic neurons. Direct neurons identify a pattern and immediately boost the probability of the correct final answer. Indirect neurons identify properties of the input (e.g., "operand 1 is in the range 0-50") and pass that context forward to help later layers make the final call.
  • Early Emergence: By analyzing training checkpoints, the authors found that this heuristic approach isn't a late-stage optimization or a fallback mechanism. It is the primary way the model learns to solve math right from the beginning of its training.

How Did They Prove This?

The authors used a suite of mechanistic interpretability techniques to reverse-engineer the models on two-operand arithmetic tasks (addition, subtraction, multiplication, and division):

  1. Circuit Discovery: Using "activation patching," they isolated the specific MLP layers and attention heads responsible for arithmetic.
  2. Causal Analysis & Ablation: They zoomed in on individual neurons and "knocked them out" (ablated them) to prove their causal necessity. Turning off neurons associated with a specific heuristic caused a significant drop in accuracy for prompts where that rule should have applied.
  3. Automated Classification: The team developed an algorithm to categorize these neurons into human-understandable heuristic types, successfully classifying 91% of the top-performing neurons into categories like Range, Modulo, or Pattern detectors.

Ultimately, the identified arithmetic circuit explains an impressive 96% of the model's behavior. When the model fails at math, it is usually because the "bag" of heuristics isn't large enough to provide a strong total signal for that specific number combination, rather than the model executing a "wrong" algorithm.

Limitations and the Path Forward

While this research provides a massive leap in our understanding of LLM mechanics, it has boundaries. The study focused heavily on single-token numbers (typically 0–1000). Solving math with multi-token numbers (e.g., 12,345 + 67,890) likely requires more complex information routing between tokens.

Furthermore, the researchers defined the heuristic categories themselves. It remains entirely possible that the model utilizes "alien" heuristics—patterns that successfully predict math but make zero intuitive sense to human evaluators. Finally, while the "bag of heuristics" explains arithmetic, it remains an open question whether other complex reasoning tasks, like logic or coding, rely on similar shortcuts or if they eventually develop true, generalizable algorithms.

Summary updated

BibTeX
@inproceedings{nikankin2025arithmetic,
  author = {Yaniv Nikankin and Anja Reusch and Aaron Mueller and Yonatan Belinkov},
  title = {{Arithmetic Without Algorithms: Language Models Solve Math with a Bag of Heuristics}},
  booktitle = {International Conference on Learning Representations},
  year = {2025},
  url = {https://openreview.net/forum?id=O9YTt26r2P},
}
Figure