atlas

Research map / Architectures and efficiency / Attention and transformers

(How) Can Transformers Predict Pseudo-Random Numbers?

ICML 2025 · Architectures and efficiency › Attention and transformers · approach: Transformer expressivity and learnability · 0 citations (OpenAlex)

Read the paperCheck your idea against 108,967 papers

AI-extracted summary. Written by AI from the paper's full text. Numbers and claims can be wrong or missing context, so check the paper before you cite or build on it.

Shows that decoder-only Transformers can learn to predict linear congruential generator (LCG) sequences in-context, both for fixed moduli up to 2^32 and for unseen moduli up to 2^16, and reverse-engineers the learned algorithms (residue number system representations, modulus estimation).

Problem

Whether and how Transformers can learn to predict pseudo-random number sequences from linear congruential generators with unseen multipliers, increments, and moduli, and what algorithm they implement.

Approach

Trains GPT-style autoregressive Transformers on LCG sequences, then reverse-engineers the learned algorithm: models build residue-number-system (prime-factor) digit representations in embeddings and attention heads, and for unseen moduli first estimate the modulus from context. Scales via base-b tokenization and abacus embeddings.

Key results

Measured effects reported in the paper

What was changedWhereMeasuredEffect
Use Steele multipliers instead of arbitrary multipliersFixed-modulus Transformer · LCG, m = 2^32test accuracyHurt
Increase depth from below 3 layers to 3 layersUnseen-modulus Transformer · Unseen-modulus LCG predictiontest accuracyHelped
Increase the number of attention heads, especially from one to twoUnseen-modulus Transformer · Unseen-modulus LCG predictiontest accuracyHelped
Train only on long-period sequences instead of only low-period sequences (ablation)Unseen-modulus Transformer · Unseen-modulus LCG predictiongeneralizationHelped
Keep attention to both t-2^k and t-2^(k-1), rather than only t-2^k (ablation)Fixed-modulus Transformer · LCG, m = 2048, higher digitsper-digit accuracyHelped
Remove the attention head specializing in the relevant prime factor (ablation)Unseen-modulus Transformer · Unseen-modulus LCG, corresponding prime-factor digitsper-digit accuracyHurt
Remove the modulo-3 head (ablation)Unseen-modulus Transformer · m_test = 2048, selected token positionsper-digit accuracyMixed
Use tokenization base 243 instead of base 256 (ablation)Unseen-modulus Transformer · Unseen moduli that are powers of 3test accuracyHelped
Use tokenization base 256 instead of base 243 (ablation)Unseen-modulus Transformer · Unseen moduli that are powers of 2test accuracyHelped

Surprising findings

Limitations

Experimental setup

Datasets: synthetic LCG sequences generated via Hull-Dobell theorem parameter selection

Benchmarks: held-out LCG sequences with unseen (a,c) at fixed modulus held-out LCG sequences with unseen moduli (e.g., 1800, 2048, 2352, 16384, 2^k and 3^k)

Metrics: per-position next-token accuracy per-digit accuracy in-context length needed for 100% (or 60%) test accuracy

Builds on: GPT abacus embeddings grokking Hull-Dobell theorem

Closest papers by meaning

Writing a paper in this area? scime draft is a free LaTeX editor with AI included, real-time co-authors and a check of your references and venue rules before you submit. It also imports OpenAI Prism projects.

Open scime draft

Get the next scime Dispatch and a monthly field update

Free. We send a confirmation link first; every email has a one-click unsubscribe. Privacy