Transformers in Pseudo-Random Number Generation: A Dual Perspective on Theory and Practice

Ran Li, Lingshu Zeng
8/2/2025
cs.LG

No confident code implementation found for this paper.

Abstract

Pseudo-random number generators (PRNGs) are high-nonlinear processes, and they are key blocks in optimization of Large language models. Transformers excel at processing complex nonlinear relationships. Thus it is reasonable to generate high-quality pseudo-random numbers based on transformers. In this paper, we explore this question from both theoretical and practical perspectives, highlighting the potential benefits and implications of Transformer in PRNGs. We theoretically demonstrate that decoder-only Transformer models with Chain-of-Thought can simulate both the Linear Congruential Generator (LCG) and Mersenne Twister (MT) PRNGs. Based on this, we conclude that the log-precision decoder-only Transformer can represent non-uniform $\text{AC}^0$. Our simulative theoretical findings are validated through experiments. The random numbers generated by Transformer-based PRNGs successfully pass the majority of NIST tests, whose heat maps exhibit clear statistical randomness. Finally, we assess their capability in prediction attacks.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{li2025transformers,
  title  = {Transformers in Pseudo-Random Number Generation: A Dual Perspective on Theory and Practice},
  author = {Ran Li and Lingshu Zeng},
  year   = {2025},
  eprint = {2508.01134},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2508.01134v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2508.01134.svg)](https://codeofpaper.com/paper/2508.01134)

Discussion