(How) Can Transformers Predict Pseudo-Random Numbers?
Tao Tao, Darshil Doshi, Dayal Singh Kalra, Tianyu He, Maissam Barkeshli

TL;DR
This paper investigates the capacity of Transformer models to learn and predict pseudo-random sequences generated by linear congruential generators, revealing their ability to develop algorithmic strategies for sequence prediction and generalization.
Contribution
It demonstrates that Transformers can learn to predict LCG sequences with unseen parameters and moduli, uncovering their internal mechanisms and generalization capabilities.
Findings
Transformers can predict LCG sequences with unseen parameters up to 2^{32}.
Models generalize to unseen moduli up to 2^{16} by estimating the modulus.
Prediction accuracy sharply improves at a model depth of 3.
Abstract
Transformers excel at discovering patterns in sequential data, yet their fundamental limitations and learning mechanisms remain crucial topics of investigation. In this paper, we study the ability of Transformers to learn pseudo-random number sequences from linear congruential generators (LCGs), defined by the recurrence relation . We find that with sufficient architectural capacity and training data variety, Transformers can perform in-context prediction of LCG sequences with unseen moduli () and parameters (). By analyzing the embedding layers and attention patterns, we uncover how Transformers develop algorithmic structures to learn these sequences in two scenarios of increasing complexity. First, we investigate how Transformers learn LCG sequences with unseen () but fixed modulus; and demonstrate successful learning up to $m =…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
Taxonomy
TopicsStatistical Mechanics and Entropy
MethodsSoftmax · Attention Is All You Need
