[Paper Review] Investigating the Limitations of Transformers with Simple Arithmetic Tasks
The paper shows that the surface representation of numbers critically affects arithmetic learning in transformers; with proper position-aware representations, models can learn addition/subtraction on very long numbers, while standard tokenization struggles, and extrapolation remains challenging.
The ability to perform arithmetic tasks is a remarkable trait of human intelligence and might form a critical component of more complex reasoning tasks. In this work, we investigate if the surface form of a number has any influence on how sequence-to-sequence language models learn simple arithmetic tasks such as addition and subtraction across a wide range of values. We find that how a number is represented in its surface form has a strong influence on the model's accuracy. In particular, the model fails to learn addition of five-digit numbers when using subwords (e.g., "32"), and it struggles to learn with character-level representations (e.g., "3 2"). By introducing position tokens (e.g., "3 10e1 2"), the model learns to accurately add and subtract numbers up to 60 digits. We conclude that modern pretrained language models can easily learn arithmetic from very few examples, as long as we use the proper surface representation. This result bolsters evidence that subword tokenizers and positional encodings are components in current transformer designs that might need improvement. Moreover, we show that regardless of the number of parameters and training examples, models cannot learn addition rules that are independent of the length of the numbers seen during training. Code to reproduce our experiments is available at https://github.com/castorini/transformers-arithmetic
Motivation & Objective
- Assess how different surface representations of numbers influence transformer learning for simple arithmetic (addition/subtraction).
- Investigate whether explicit positional semantics can be injected into input to improve arithmetic abilities without re-pretraining.
Proposed method
- Cast addition and subtraction as sequence-to-sequence tasks using input templates like 'What is [number1] [operation] [number2]?'.
- Systematically compare six number representations (decimal, character, fixed-character, underscore, words, 10-based position tokens, 10e-based) on model accuracy.
- Use T5 models of various sizes (and vanilla transformers) trained with balanced/random sampling; measure accuracy with greedy decoding.
- Analyze impact of pretraining by comparing representations and conducting appendix experiments on extrapolation/interpolation and position embeddings.
Experimental results
Research questions
- RQ1How does the surface form of numbers affect learning of simple arithmetic in transformer models?
- RQ2Can explicit position-based representations (10-based and 10e-based) enable accurate addition/subtraction for very long numbers?
- RQ3Do larger models or more data overcome representation-induced learning limitations in arithmetic tasks?
- RQ4Is extrapolation to unseen digit lengths feasible under different representations and model sizes?
Key findings
- Decimal and subword-like tokenizations hinder learning arithmetic for longer numbers; accuracy drops to zero for 5-digit additions or more.
- Character and underscore representations improve learning but still degrade as digit length increases; memorization strategies fail beyond around 12–15 digits.
- 10-based and 10e-based representations with position tokens enable near-perfect accuracy up to 60-digit numbers in the main results (the text states up to 60 digits in discussion).
- The fixed-character representation outperforms character/underscore for longer numbers but eventually breaks around 15 digits.
- Pretraining and representation interact; words representation benefits from intrinsic position tokens but fails for very long numbers due to token length limits; 10-based/10e-based representations yield high accuracy with proper positioning.
- Extrapolation remains challenging for many models; even 3B-parameter models struggle to learn arithmetic rules independent of training-length distributions.
Better researchstarts right now
From reading papers to final review, dramatically reduce your research time.
No credit card · Free plan available
This review was created by AI and reviewed by human editors.