Length Generalization in Arithmetic Transformers

Samy Jelassi, Stéphane d'Ascoli, Carles Domingo-Enrich, Yuhuai Wu, Yuanzhi Li +1 more
6/27/2023
cs.LG

No confident code implementation found for this paper. 1 possible match can be shown below.

Abstract

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 $\times$ $3$-digit multiplications to generalize to $35\times 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.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 1 weaker match is hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{jelassi2023length,
  title  = {Length Generalization in Arithmetic Transformers},
  author = {Samy Jelassi and Stéphane d'Ascoli and Carles Domingo-Enrich and Yuhuai Wu and Yuanzhi Li and François Charton},
  year   = {2023},
  eprint = {2306.15400},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2306.15400v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2306.15400.svg)](https://codeofpaper.com/paper/2306.15400)

Discussion