about
Learning Pseudorandom Numbers with Transformers (arxiv.org)
11 points by pizza 154 days ago | hide | past | pdf | 3 comments on HN

In plain words: Trained on sequences from a random-number generator that scrambles its state with bit shifts, XORs, and rotations, a Transformer predicts the next numbers. It nails new sequences, even single-bit outputs, after seeing about the square root of the range size, and needs smaller ones first.

Abstract · Learning Pseudorandom Numbers with Transformers: Permuted Congruential Generators, Curricula, and Interpretability

We study the ability of Transformer models to learn sequences generated by Permuted Congruential Generators (PCGs), a widely used family of pseudo-random number generators (PRNGs). PCGs introduce substantial additional difficulty over linear congruential generators (LCGs) by applying a series of bit-wise shifts, XORs, rotations and truncations to the hidden state. We show that Transformers can nevertheless successfully perform in-context prediction on unseen sequences from diverse PCG variants, in tasks that are beyond published classical attacks. In our experiments we scale moduli up to $2^{22}$ using up to $50$ million model parameters and datasets with up to $5$ billion tokens. Surprisingly, we find even when the output is truncated to a single bit, it can be reliably predicted by the model. When multiple distinct PRNGs are presented together during training, the model can jointly learn them, identifying structures from different permutations. We demonstrate a scaling law with modulus $m$: the number of in-context sequence elements required for near-perfect prediction grows as $\sqrt{m}$. For larger moduli, optimization enters extended stagnation phases; in our experiments, learning moduli $m \geq 2^{20}$ requires incorporating training data from smaller moduli, demonstrating a critical necessity for curriculum learning. Finally, we analyze embedding layers and uncover a novel clustering phenomenon: the top principal components spontaneously group the integer inputs into bitwise rotationally-invariant clusters, revealing how representations can transfer from smaller to larger moduli.

Tao Tao, Maissam Barkeshli
arXiv:2510.26792 · cs.LG, cond-mat.dis-nn, cs.CR · submitted Oct 30, 2025 · updated Feb 16, 2026
abstract · pdf · html · 10+13 pages, 8+21 figures

add comment on HN

Uh this is apocalyptic for computer security, no?
No, anyone needing secure pseudorandom numbers already knows to reach for a CSPRNG, not a PRNG.
A unappreciated downstream risk is of adapting this for efficient hash reversal, compromising the strength of signatures and of cryptocurrencies.