Can transformers learn the greatest common divisor?

08/29/2023
by   François Charton, et al.
0

I investigate the capability of small transformers to compute the greatest common divisor (GCD) of two positive integers. When the training distribution and the representation base are carefully chosen, models achieve 98 and correctly predict 91 of the 100 first GCD. Model predictions are deterministic and fully interpretable. During training, the models learn to cluster input pairs with the same GCD, and classify them by their divisors. Basic models, trained from uniform operands encoded on small bases, only compute a handful of GCD (up to 38 out of 100): the products of divisors of the base. Longer training and larger bases allow some models to "grok" small prime GCD. Training from log-uniform operands boosts performance to 73 correct GCD, and balancing the training distribution of GCD, from inverse square to log-uniform, to 91 GCD. Training models from a uniform distribution of GCD breaks the deterministic model behavior.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
10/31/2022

What is my math transformer doing? – Three results on interpretability and generalization

This paper investigates the failure cases and out-of-distribution behavi...
research
06/01/2021

Solutions of the Multivariate Inverse Frobenius–Perron Problem

We address the inverse Frobenius–Perron problem: given a prescribed targ...
research
06/27/2023

Length Generalization in Arithmetic Transformers

We examine how transformers cope with two challenges: learning basic int...
research
12/03/2021

Linear algebra with transformers

Most applications of transformers to mathematics, from integration to th...
research
10/08/2021

Iterative Decoding for Compositional Generalization in Transformers

Deep learning models do well at generalizing to in-distribution data but...
research
07/11/2002

Compilation of Propositional Weighted Bases

In this paper, we investigate the extent to which knowledge compilation ...

Please sign up or login with your details

Forgot password? Click here to reset