Towards Training Transformers as a Universal Computer

Ruize Xu, Chenxiao Yang, Yanhong Li, David McAllester


Abstract
We demonstrate that a small transformer can learn to execute programs in MicroPy, a simplified yet computationally universal programming language. Given procedure definitions together with an expression to evaluate, the transformer predicts small-step execution using PENCIL scaffolding for space-efficient execution within a bounded context window. After training on randomly generated, semantically arbitrary MicroPy programs, the learned transformer generalizes to held-out human-written programs including bit copying and flipping, binary addition and multiplication, and SAT verification and solving. The trained model exhibits out-of-distribution generalization: it correctly evaluates programs drawn from a substantially different distribution than the one used to generate its training data. Since MicroPy can express any computation, our results provide empirical evidence that a standard transformer can be trained to act as a universal computer when paired with PENCIL scaffolding.
Anthology ID:
2026.findings-emnlp.2284
Volume:
Findings of the Association for Computational Linguistics: EMNLP 2026
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Hung-Yi Lee, Sunipa Dev, Jessy Li, Desmond Elliott
Venue:
Findings
SIG:
SIGDAT
Publisher:
Association for Computational Linguistics
Note:
Pages:
48933–48954
Language:
URL:
https://aclanthology.org/2026.findings-emnlp.2284/
DOI:
Bibkey:
Cite (ACL):
Ruize Xu, Chenxiao Yang, Yanhong Li, and David McAllester. 2026. Towards Training Transformers as a Universal Computer. In Findings of the Association for Computational Linguistics: EMNLP 2026, pages 48933–48954, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
Towards Training Transformers as a Universal Computer (Xu et al., Findings 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.findings-emnlp.2284.pdf