Investigating the Limitations of Transformers with Simple Arithmetic Tasks
By Rodrigo Nogueira, Jimmy J. Li. 2021
163 citations recorded by the source corpus.
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
Subfields: Artificial Intelligence, Large Language Models, Natural Language Processing
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Artificial Intelligence
- Graham Neubig
- Mohit Bansal
- Yoshua Bengio
- Pengfei Liu
- Luyu Gao
- Jianfeng Gao
- Luke S. Zettlemoyer
- Kyunghyun Cho
In Large Language Models
In Natural Language Processing
Citations in the corpus
- Teaching Autoregressive Language Models Complex Tasks By Demonstration (2021, background): “These errors often involved numbers that were copied from earlier in the demonstration string being swapped, duplicated, or omitted, suggesting that the use of alternative positional encodings could be a promising approach [20], [41].”
- PAL: Program-aided Language Models (2022, background): “…decompose natural language problems into steps and perform simple arithmetic operations, their performance falls dramatically when dealing with complex arithmetic (Hendrycks et al., 2021; Madaan & Yazdanbakhsh, 2022) or large numbers (Geva et al., 2020; Nogueira et al., 2021; Qian et al., 2022).”
- Teaching Algorithmic Reasoning via In-context Learning (2022, background): “However, despite significant progress, these models still struggle with out-of-distribution (OOD) generalization on reasoning tasks (Nogueira et al., 2021; Kim et al., 2021; Anil et al., 2022).”
- Exploring Generalization Ability of Pretrained Language Models on Arithmetic and Logical Reasoning (2021, background): “, 2019), and answer generalization on distribution differences between training set and test set (Nogueira et al., 2021).”
- Reasoning with Language Model Prompting: A Survey (2022, background): “, by generating reasoning processes); however, we cannot have both fish and bear’s paw (Hendrycks et al., 2021; Nogueira et al., 2021; Lewkowycz et al., 2022).”
- LIFT: Language-Interfaced Fine-Tuning for Non-Language Machine Learning Tasks (2022, background): “[133] Rodrigo Nogueira, Zhiying Jiang, and Jimmy Lin.”
- ToolQA: A Dataset for LLM Question Answering with External Tools (2023, background): “Additionally, they exhibit weaknesses in numerical reasoning, an essential skill in numerous real-life applications [14, 36, 41, 28, 51, 13].”
- Representing Numbers in NLP: a Survey and a Vision (2021, methodology): “Character level tokenization outperforms subword level (Nogueira et al., 2021; Wallace et al., 2019; Geva et al., 2020).”
- mGPT: Few-Shot Learners Go Multilingual (2022, methodology): “The design of the tokenization method may have a significant impact on learning efficient representations, model memorization, and downstream performance (Mielke et al., 2021; Nogueira et al., 2021; Pfeiffer et al., 2021; Rust et al., 2021).”
- Limitations of Language Models in Arithmetic and Symbolic Induction (2022, background): “Larger models might perform better on the testing data, but worse on numbers that are longer than the training data (out-of-distribution, OOD) (Nogueira et al., 2021).”