English

Linear algebra with transformers

Machine Learning 2022-11-09 v2 Computation and Language

Abstract

Transformers can learn to perform numerical computations from examples only. I study nine problems of linear algebra, from basic matrix operations to eigenvalue decomposition and inversion, and introduce and discuss four encoding schemes to represent real numbers. On all problems, transformers trained on sets of random matrices achieve high accuracies (over 90%). The models are robust to noise, and can generalize out of their training distribution. In particular, models trained to predict Laplace-distributed eigenvalues generalize to different classes of matrices: Wigner matrices or matrices with positive eigenvalues. The reverse is not true.

Keywords

Cite

@article{arxiv.2112.01898,
  title  = {Linear algebra with transformers},
  author = {François Charton},
  journal= {arXiv preprint arXiv:2112.01898},
  year   = {2022}
}

Comments

Transactions in Machine Learning Research (TMLR), October 2022

R2 v1 2026-06-24T08:03:07.703Z