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 -digit numbers can perform -digit sums. However, this method fails for multiplication, and we propose train set priming: adding a few ( to ) long sequences to the training set. We show that priming allows models trained on -digit -digit multiplications to generalize to 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.

生成讲解博客的中文版本

生成AI智能校验的中文版本