Abstract: Despite the remarkable success of transformer-based large language models (LLMs) across various domains, understanding and enhancing their mathematical capabilities remains a significant challenge. In this paper, we conduct a rigorous theoretical analysis of LLMs’ mathematical abilities, with a specific focus on their arithmetic performances. We identify numerical precision as a key factor that influences their effectiveness in arithmetical tasks. Our results show that Transformers operating with low numerical precision fail to address arithmetic tasks, such as iterated addition and integer multiplication, unless the model size grows super-polynomially with respect to the input length. In contrast, Transformers with standard numerical precision can efficiently handle these tasks with significantly smaller model sizes. We further support our theoretical findings through empirical experiments that explore the impact of varying numerical precision on arithmetic tasks, providing valuable insights for improving the mathematical reasoning capabilities of LLMs.
Introduction
Large Language Models (LLMs) are surprisingly good at writing poetry and code, but they often stumble over basic arithmetic. While many researchers point to "hallucinations" or poor logic, new research suggests a more fundamental culprit: numerical precision. This paper provides a rigorous theoretical and empirical analysis showing that the numerical precision of a Transformer’s internal states is a "make-or-break" factor for mathematical reasoning.
Theoretical Framework: Precision and Complexity
The researchers tackle the problem using the lens of circuit complexity theory, modeling the Transformer as a computational circuit and analyzing its expressiveness under two settings:
- Constant-precision: Internal neurons use a fixed number of bits (e.g., $c$ bits), independent of the input length. This mirrors real-world quantized models like int4 or float8.
- Logarithmic-precision: Internal neurons use $O(\log n)$ bits, where $n$ is the input length. This represents "standard" precision (like float32), where the resolution of the numbers can scale with problem complexity.
The authors prove that constant-precision Transformers fall into the complexity class $AC^0$, while logarithmic-precision Transformers reach $TC^0$. In complexity theory, $TC^0$ can solve problems that $AC^0$ simply cannot unless the model size grows at a "super-polynomial" rate—essentially becoming too large to ever build or train.
Empirical Confirmation
To validate the theory, the authors trained Transformers from scratch on synthetic arithmetic tasks. The results showed that float32 models maintained near-perfect accuracy as digit length increased. In contrast, bfloat16—which has lower precision than float32—showed a significant performance drop as problems became more complex.
As seen in Figure 1, while float32 models maintain 100% accuracy, bfloat16 models experience a sharp decline in performance once the maximum length of the addends exceeds 7 digits in Base-2 iterated addition.
Key Results and Insights
- The "Overflow" Bottleneck: In low-precision models, individual neurons cannot store the intermediate results (like carries in a long addition or partial products in multiplication) required for complex math. To compensate, the model must "spread" the computation across a massive number of neurons, leading to an exponential requirement for model size.
- Addition vs. Multiplication: Simple two-number addition is solvable by low-precision models with reasonable size ($O(n^2)$). However, as soon as tasks involve adding a list of numbers or multiplying them, the precision requirement spikes.
- Quantization Impact: On LLaMA-3.1-8B experiments, an int4 quantized model saw a 20% drop in accuracy for iterated addition compared to the bfloat16 version. Even fine-tuning the int4 model (QLoRA) could not close the gap to the original model's performance.
Figure 4 highlights that this precision gap persists across different operations and model depths in Base-10. While float32 models handle 4-digit addition and 4-digit multiplication with high accuracy, bfloat16 models fail almost entirely on these tasks as the input length increases.
Conclusion
The paper demonstrates that numerical precision is a critical determinant of an LLM's mathematical capability. While quantization is essential for saving memory, it imposes a theoretical ceiling on arithmetical reasoning. For engineers, the takeaway is clear: if an application requires heavy lifting in math, aggressive quantization may be a significant bottleneck that cannot be solved by scaling alone.
Summary updated