Abstract
While Transformer models like T5 are linguistic powerhouses, they notoriously struggle with basic arithmetic. This paper reveals that the secret to "teaching" them math isn't necessarily more parameters, but rather changing the surface representation of numbers—specifically by using "position tokens" (like scientific notation) to explicitly label digit significance. With the right format, a standard T5 model can learn to add 60-digit numbers with near-perfect accuracy, though it still fails to generalize to lengths it hasn't seen during training.
Introduction
Despite their success in natural language, Transformers often fail at simple multi-digit addition and subtraction. The authors argue this isn't just a lack of "reasoning" capability, but a failure of representation. Standard subword tokenizers (like those used in GPT or BERT) often group digits irregularly (e.g., "132" might be one token, while "232" is split into "23" and "2"), making it nearly impossible for the model to learn consistent place-value rules. This paper investigates whether "injecting" semantic information into the input text can overcome these architectural limitations.
Methods
The researchers used the T5 (Text-to-Text Transfer Transformer) model across various sizes (from 60M to 3B parameters). They framed addition and subtraction as sequence-to-sequence tasks (e.g., Input: "What is 52 plus 148?" $\rightarrow$ Output: "200").
The core of their experiment was testing seven different orthographies (ways of writing numbers) to determine how representation affects learning efficiency and accuracy.
Datasets and Sampling
The authors programmatically generated synthetic datasets using two sampling strategies:
- Balanced Sampling: Ensures an equal proportion of $d$-digit numbers (from 2 to $D$ digits) to prevent length bias.
- Random Sampling: Numbers sampled uniformly from $[0, 10^D - 1]$, which results in ~90% of the data being the maximum length ($D$ digits).
Key Results and Insights
The choice of orthography proved to be the single most important factor in model performance. As shown in Figure 1, standard representations like DECIMAL fail almost immediately as the number of digits increases.
- Subwords are the Enemy: The
DECIMALrepresentation failed (0% accuracy beyond 5 digits) because irregular grouping prevents the model from learning a stable mapping between tokens and numerical values. - Position Tokens are the "Cheat Code": The
10E-BASEDformat was the clear winner. By explicitly labeling each digit's significance (e.g., "10e59"), the model doesn't have to "count" positions; it can simply attend to the token to the right of a digit to know its value. Using this representation, T5-220M achieved ~100% accuracy on numbers up to 60 digits. - Pretraining Provides a 10x Boost: Pretrained models reached 100% accuracy using roughly ten times fewer examples than models trained from scratch, suggesting that pretraining helps the model learn useful internal representations of structure.
The Extrapolation Barrier
Despite the success within trained lengths, even the best models failed to extrapolate. If a model is trained on up to 50-digit numbers, it fails when asked to add 60-digit numbers, often "skipping" the middle of the sequence. While larger models (T5-3B) performed slightly better at extrapolation than smaller ones, even they could not reliably learn length-independent rules.
Conclusion
The models seem to memorize digit-position relationships for specific lengths rather than learning a universal algorithm (like the "carry" rule) that works for any number of digits. While simple input manipulations can "patch" some Transformer weaknesses, the underlying architecture—specifically how it handles positional encoding and sequence termination—may need fundamental changes to truly achieve human-like mathematical reasoning.
Summary updated