Investigating the Limitations of Transformers with Simple Arithmetic Tasks
arXiv:2102.13019
Abstract
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
References in corpus (17)
- Decoupled Weight Decay Regularization
- DeBERTa: Decoding-enhanced BERT with Disentangled Attention
- Universal Transformers
- Grid Long Short-Term Memory
- Neural GPUs Learn Algorithms
- Inferring Algorithmic Patterns with Stack-Augmented Recurrent Nets
- Scaling Laws for Autoregressive Generative Modeling
- Neural Arithmetic Logic Units
- Rethinking Positional Encoding in Language Pre-training
- Encoding word order in complex embeddings
- Generative Language Modeling for Automated Theorem Proving
- Enhancing the Transformer with Explicit Relational Encoding for Math Problem Solving
- Scaling Laws for Transfer
- Birds have four legs?! NumerSense: Probing Numerical Commonsense Knowledge of Pre-trained Language Models
- Towards Question Format Independent Numerical Reasoning: A Set of Prerequisite Tasks
- Extensions and Limitations of the Neural GPU
- Learning Numeral Embeddings
Cited by in corpus (11)
- Transforming the Bootstrap: Using Transformers to Compute Scattering Amplitudes in Planar N = 4 Super Yang-Mills Theory
- MultiTabQA: Generating Tabular Answers for Multi-Table Question Answering
- Learning the Simplicity of Scattering Amplitudes
- Arithmetic with Language Models: from Memorization to Computation
- Beyond Distributional Hypothesis: Let Language Models Learn Meaning-Text Correspondence
- Exploring Generalization Ability of Pretrained Language Models on Arithmetic and Logical Reasoning
- Compositional Attention: Disentangling Search and Retrieval
- Teaching Autoregressive Language Models Complex Tasks By Demonstration
- Large Language Models -- the Future of Fundamental Physics?
- It Ain't That Bad: Understanding the Mysterious Performance Drop in OOD Generalization for Generative Transformer Models
- Investigating Numeracy Learning Ability of a Text-to-Text Transfer Model