Transformers Can Do Arithmetic with the Right Embeddings. McLeish, S., Bansal, A., Stein, A., Jain, N., Kirchenbauer, J., Bartoldson, B. R., Kailkhura, B., Bhatele, A., Geiping, J., Schwarzschild, A., & Goldstein, T. In Advances in Neural Information Processing Systems, volume 37, pages 108012–108041, December, 2024. arXiv. arXiv:2405.17399 [cs]
Paper doi abstract bibtex The poor performance of transformers on arithmetic tasks seems to stem in large part from their inability to keep track of the exact position of each digit inside of a large span of digits. We mend this problem by adding an embedding to each digit that encodes its position relative to the start of the number. In addition to the boost these embeddings provide on their own, we show that this fix enables architectural modifications such as input injection and recurrent layers to improve performance even further. With positions resolved, we can study the logical extrapolation ability of transformers. Can they solve arithmetic problems that are larger and more complex than those in their training data? We find that training on only 20 digit numbers with a single GPU for one day, we can reach state-of-the-art performance, achieving up to 99% accuracy on 100 digit addition problems. Finally, we show that these gains in numeracy also unlock improvements on other multi-step reasoning tasks including sorting and multiplication.
@inproceedings{mcleish_transformers_2024,
title = {Transformers {Can} {Do} {Arithmetic} with the {Right} {Embeddings}},
volume = {37},
url = {http://arxiv.org/abs/2405.17399},
doi = {10.48550/arXiv.2405.17399},
abstract = {The poor performance of transformers on arithmetic tasks seems to stem in large part from their inability to keep track of the exact position of each digit inside of a large span of digits. We mend this problem by adding an embedding to each digit that encodes its position relative to the start of the number. In addition to the boost these embeddings provide on their own, we show that this fix enables architectural modifications such as input injection and recurrent layers to improve performance even further. With positions resolved, we can study the logical extrapolation ability of transformers. Can they solve arithmetic problems that are larger and more complex than those in their training data? We find that training on only 20 digit numbers with a single GPU for one day, we can reach state-of-the-art performance, achieving up to 99\% accuracy on 100 digit addition problems. Finally, we show that these gains in numeracy also unlock improvements on other multi-step reasoning tasks including sorting and multiplication.},
urldate = {2025-04-23},
booktitle = {Advances in {Neural} {Information} {Processing} {Systems}},
publisher = {arXiv},
author = {McLeish, Sean and Bansal, Arpit and Stein, Alex and Jain, Neel and Kirchenbauer, John and Bartoldson, Brian R. and Kailkhura, Bhavya and Bhatele, Abhinav and Geiping, Jonas and Schwarzschild, Avi and Goldstein, Tom},
month = dec,
year = {2024},
note = {arXiv:2405.17399 [cs]},
keywords = {Computer Science - Artificial Intelligence, Computer Science - Machine Learning, year-2-pubs, year-2-pubs-direct},
pages = {108012--108041},
}
Downloads: 0
{"_id":"pESYzA3RhTPaWyrRT","bibbaseid":"mcleish-bansal-stein-jain-kirchenbauer-bartoldson-kailkhura-bhatele-etal-transformerscandoarithmeticwiththerightembeddings-2024","author_short":["McLeish, S.","Bansal, A.","Stein, A.","Jain, N.","Kirchenbauer, J.","Bartoldson, B. R.","Kailkhura, B.","Bhatele, A.","Geiping, J.","Schwarzschild, A.","Goldstein, T."],"bibdata":{"bibtype":"inproceedings","type":"inproceedings","title":"Transformers Can Do Arithmetic with the Right Embeddings","volume":"37","url":"http://arxiv.org/abs/2405.17399","doi":"10.48550/arXiv.2405.17399","abstract":"The poor performance of transformers on arithmetic tasks seems to stem in large part from their inability to keep track of the exact position of each digit inside of a large span of digits. We mend this problem by adding an embedding to each digit that encodes its position relative to the start of the number. In addition to the boost these embeddings provide on their own, we show that this fix enables architectural modifications such as input injection and recurrent layers to improve performance even further. With positions resolved, we can study the logical extrapolation ability of transformers. Can they solve arithmetic problems that are larger and more complex than those in their training data? We find that training on only 20 digit numbers with a single GPU for one day, we can reach state-of-the-art performance, achieving up to 99% accuracy on 100 digit addition problems. Finally, we show that these gains in numeracy also unlock improvements on other multi-step reasoning tasks including sorting and multiplication.","urldate":"2025-04-23","booktitle":"Advances in Neural Information Processing Systems","publisher":"arXiv","author":[{"propositions":[],"lastnames":["McLeish"],"firstnames":["Sean"],"suffixes":[]},{"propositions":[],"lastnames":["Bansal"],"firstnames":["Arpit"],"suffixes":[]},{"propositions":[],"lastnames":["Stein"],"firstnames":["Alex"],"suffixes":[]},{"propositions":[],"lastnames":["Jain"],"firstnames":["Neel"],"suffixes":[]},{"propositions":[],"lastnames":["Kirchenbauer"],"firstnames":["John"],"suffixes":[]},{"propositions":[],"lastnames":["Bartoldson"],"firstnames":["Brian","R."],"suffixes":[]},{"propositions":[],"lastnames":["Kailkhura"],"firstnames":["Bhavya"],"suffixes":[]},{"propositions":[],"lastnames":["Bhatele"],"firstnames":["Abhinav"],"suffixes":[]},{"propositions":[],"lastnames":["Geiping"],"firstnames":["Jonas"],"suffixes":[]},{"propositions":[],"lastnames":["Schwarzschild"],"firstnames":["Avi"],"suffixes":[]},{"propositions":[],"lastnames":["Goldstein"],"firstnames":["Tom"],"suffixes":[]}],"month":"December","year":"2024","note":"arXiv:2405.17399 [cs]","keywords":"Computer Science - Artificial Intelligence, Computer Science - Machine Learning, year-2-pubs, year-2-pubs-direct","pages":"108012–108041","bibtex":"@inproceedings{mcleish_transformers_2024,\n\ttitle = {Transformers {Can} {Do} {Arithmetic} with the {Right} {Embeddings}},\n\tvolume = {37},\n\turl = {http://arxiv.org/abs/2405.17399},\n\tdoi = {10.48550/arXiv.2405.17399},\n\tabstract = {The poor performance of transformers on arithmetic tasks seems to stem in large part from their inability to keep track of the exact position of each digit inside of a large span of digits. We mend this problem by adding an embedding to each digit that encodes its position relative to the start of the number. In addition to the boost these embeddings provide on their own, we show that this fix enables architectural modifications such as input injection and recurrent layers to improve performance even further. With positions resolved, we can study the logical extrapolation ability of transformers. Can they solve arithmetic problems that are larger and more complex than those in their training data? We find that training on only 20 digit numbers with a single GPU for one day, we can reach state-of-the-art performance, achieving up to 99\\% accuracy on 100 digit addition problems. Finally, we show that these gains in numeracy also unlock improvements on other multi-step reasoning tasks including sorting and multiplication.},\n\turldate = {2025-04-23},\n\tbooktitle = {Advances in {Neural} {Information} {Processing} {Systems}},\n\tpublisher = {arXiv},\n\tauthor = {McLeish, Sean and Bansal, Arpit and Stein, Alex and Jain, Neel and Kirchenbauer, John and Bartoldson, Brian R. and Kailkhura, Bhavya and Bhatele, Abhinav and Geiping, Jonas and Schwarzschild, Avi and Goldstein, Tom},\n\tmonth = dec,\n\tyear = {2024},\n\tnote = {arXiv:2405.17399 [cs]},\n\tkeywords = {Computer Science - Artificial Intelligence, Computer Science - Machine Learning, year-2-pubs, year-2-pubs-direct},\n\tpages = {108012--108041},\n}\n\n","author_short":["McLeish, S.","Bansal, A.","Stein, A.","Jain, N.","Kirchenbauer, J.","Bartoldson, B. R.","Kailkhura, B.","Bhatele, A.","Geiping, J.","Schwarzschild, A.","Goldstein, T."],"key":"mcleish_transformers_2024","id":"mcleish_transformers_2024","bibbaseid":"mcleish-bansal-stein-jain-kirchenbauer-bartoldson-kailkhura-bhatele-etal-transformerscandoarithmeticwiththerightembeddings-2024","role":"author","urls":{"Paper":"http://arxiv.org/abs/2405.17399"},"keyword":["Computer Science - Artificial Intelligence","Computer Science - Machine Learning","year-2-pubs","year-2-pubs-direct"],"metadata":{"authorlinks":{}}},"bibtype":"inproceedings","biburl":"https://api.zotero.org/users/730428/collections/9B8PKJP4/items?key=Erv9LX3tbR2gor2WT78NPJMp&format=bibtex&limit=100","dataSources":["tFvQtGDPkqnJa6Fbq","e4qi3jRmPhPzc7C9a","QPenDByDoYqTm9vaT","ccCtzG4uXnpLBW37N"],"keywords":["computer science - artificial intelligence","computer science - machine learning","year-2-pubs","year-2-pubs-direct"],"search_terms":["transformers","arithmetic","right","embeddings","mcleish","bansal","stein","jain","kirchenbauer","bartoldson","kailkhura","bhatele","geiping","schwarzschild","goldstein"],"title":"Transformers Can Do Arithmetic with the Right Embeddings","year":2024}