Arbitrary Length Generalization for Addition
Abstract
This paper introduces a novel training methodology that enables a small Transformer model to generalize the addition of two-digit numbers to numbers with unseen lengths of digits. The proposed approach employs an autoregressive generation technique, processing from right to left, which mimics a common manual method for adding large numbers. To the best of my knowledge, this methodology has not been previously explored in the literature. All results are reproducible, and the corresponding R code is available at: https://github.com/AGPatriota/ALGA-R/.
Community
In order to test for random numbers with 100 digits run the following inside your R session opened in the main folder:source('Testing-Digits.R')
Change the seed by commenting set.seed(10)
in the file Testing-Digits.R
If you want to test the algorithm for variable digit numbers, replacex = paste0(sample(0:9,n0, replace=TRUE), collapse="")
and y = paste0(sample(0:9,n0, replace=TRUE), collapse="")
withx = paste0(sample(0:9,sample(1:n0,1), replace=TRUE), collapse="")
and y = paste0(sample(0:9,sample(1:n0,1), replace=TRUE), collapse="")
:
Best regards,
Alexandre G. Patriota,
Department of Statistics,
Institute of Mathematics and Statistics,
University of São Paulo, Brazil.
Models citing this paper 0
No model linking this paper
Datasets citing this paper 0
No dataset linking this paper
Spaces citing this paper 0
No Space linking this paper
Collections including this paper 0
No Collection including this paper