Learning the greatest common divisor: explaining transformer predictions
Francois Charton
OpenReview ground truth
TL;DR — Transformers can learn to predict greatest common divisors, their predictions can be fully explained, training distribution matters
Abstract
The predictions of small transformers, trained to calculate the greatest common divisor (GCD) of two positive integers, can be fully characterized by looking at model inputs and outputs. As training proceeds, the model learns a list $\mathcal D$ of integers, products of divisors of the base used to represent integers and small primes, and predicts the largest element of $\mathcal D$ that divides both inputs. Training distributions impact performance. Models trained from uniform operands only learn a handful of GCD (up to $38$ GCD $\leq100$). Log-uniform operands boost performance to $73$ GCD $\leq 100$, and a log-uniform distribution of outcomes (i.e. GCD) to $91$. However, training from uniform (balanced) GCD breaks explainability.
Author context
Most prolific author: 1 submissions (credibility 1.00).
No mass-submission penalty for this paper (authors within normal submission volume).
Aggregate statistics only — no individual author rankings.
Ranking trajectory
Percentile by tournament round — convergence indicates rating stability.
Battle history — 36 comparisons
Ranked above opponent in 54% of matchups.
- ▲ beat Randomized Benchmarking of Local Zeroth-Or… ×6
- ▼ lost to Multimodal Molecular Pretraining via Modal… ×4
- ▼ lost to PDC-Net: Probability Density Cloud Represe… ×4
- ▼ lost to Empowering Active Learning for 3D Molecula… ×4
- ▼ lost to MediTab: Scaling Medical Tabular Data Pred… ×4
Judge assessments
Mean overall score 0.0 ± 0.0 (n = 36)