Length Generalization in Arithmetic Transformers

06/27/2023
by   Samy Jelassi, et al.
0

We examine how transformers cope with two challenges: learning basic integer arithmetic, and generalizing to longer sequences than seen during training. We find that relative position embeddings enable length generalization for simple tasks, such as addition: models trained on 5-digit numbers can perform 15-digit sums. However, this method fails for multiplication, and we propose train set priming: adding a few (10 to 50) long sequences to the training set. We show that priming allows models trained on 5-digit × 3-digit multiplications to generalize to 35× 3 examples. We also show that models can be primed for different generalization lengths, and that the priming sample size scales as the logarithm of the training set size. Finally, we discuss potential applications of priming beyond arithmetic.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
05/26/2023

Randomized Positional Encodings Boost Length Generalization of Transformers

Transformers have impressive generalization capabilities on tasks with a...
research
02/25/2021

Investigating the Limitations of Transformers with Simple Arithmetic Tasks

The ability to perform arithmetic tasks is a remarkable trait of human i...
research
06/15/2020

Neural Execution Engines: Learning to Execute Subroutines

A significant effort has been made to train neural networks that replica...
research
08/29/2023

Can transformers learn the greatest common divisor?

I investigate the capability of small transformers to compute the greate...
research
07/07/2023

Teaching Arithmetic to Small Transformers

Large language models like GPT-4 exhibit emergent capabilities across ge...
research
11/02/2016

Extensions and Limitations of the Neural GPU

The Neural GPU is a recent model that can learn algorithms such as multi...
research
10/14/2020

The EOS Decision and Length Extrapolation

Extrapolation to unseen sequence lengths is a challenge for neural gener...

Please sign up or login with your details

Forgot password? Click here to reset