Learning Pseudorandom Numbers with Transformers: Permuted Congruential Generators, Curricula, and Interpretability
This paper demonstrates that Transformer models can successfully learn and predict sequences from complex Permuted Congruential Generators (PCGs) through curriculum learning and by discovering bitwise rotationally-invariant representations, revealing a scaling law where the required context length grows as the square root of the modulus.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are trying to teach a robot to predict the next number in a magic trick. You show it a sequence like 3, 7, 15, 31, and it has to guess what comes next. In the real world, computers use special recipes called "Pseudo-Random Number Generators" (PRNGs) to create numbers that look completely random to us, like the shuffle of a deck of cards or the static on an old TV. But to the computer, these numbers aren't random at all; they follow a strict, hidden mathematical rule. If you know the rule and the starting number, you can predict the entire future of the sequence perfectly.
For a long time, scientists have wondered: Can modern AI, specifically a type of model called a "Transformer" (the same kind of brain behind many chatbots and image generators), figure out these hidden rules just by looking at examples? It's like asking if a student can learn the secret code of a lock just by watching someone open it a few times, without ever being told how the lock works. This is a big deal because these number generators are the backbone of computer security. If AI can crack them too easily, it could mean our digital locks aren't as safe as we think. But if AI can't crack them, it tells us something profound about how these models learn patterns and where their limits lie.
The Paper's Story: Cracking the Code with a Twist
In this paper, the authors set up a challenge for Transformers using a specific, tough family of number generators called "Permuted Congruential Generators" (PCGs). Think of a standard number generator as a simple machine that adds and multiplies numbers to get the next one. A PCG is that same machine, but with a twist: before it shows you the result, it scrambles the bits (the tiny 0s and 1s that make up the number) using a series of shifts, flips, and rotations. It's like taking a secret message, writing it down, and then shuffling the letters around so it looks like gibberish, even though the original message was perfectly logical.
The researchers found that Transformers are surprisingly good at this. Even when the computer only sees a tiny, scrambled piece of the output—sometimes just a single bit, like a simple "yes" or "no"—the model can still predict the next number with high accuracy. It's as if the robot is looking at a single pixel of a scrambled image and somehow knowing exactly what the whole picture looks like. The models learned to do this without being told the rules; they just figured out the pattern from the examples provided.
However, there's a catch. The harder the puzzle, the more help the robot needs. The authors discovered a "scaling law": as the numbers get bigger (specifically, as the modulus, or the size of the number pool, grows), the model needs to see more examples in a row to solve the puzzle. If the numbers are small, the model needs to see about 128 examples. If the numbers are huge (like ), the model needs to see roughly examples, which means the context length has to grow significantly. It's like trying to solve a jigsaw puzzle: if the pieces are tiny, you need to hold a lot of them in your hand to see the picture.
The most exciting discovery was about how the model learns. When the researchers tried to train the model directly on the hardest, biggest puzzles, it got stuck. The model would stare at the data for a long time, making almost no progress, like a student staring at a math problem they don't understand. But when they used a "curriculum"—a teaching strategy where they started the model on easy, small puzzles and slowly introduced harder ones—the model suddenly got it. It was as if the model needed to learn to walk before it could run. By starting small, the model learned the basic "grammar" of the number generation, and then it could apply that knowledge to the giant, complex puzzles.
The authors also peeked inside the model's "brain" (its internal data representations) and found something fascinating. The model didn't just memorize the numbers; it organized them based on their binary structure. It grouped numbers that had similar patterns of zeros and ones, even if those numbers looked totally different on the surface. It seems the model discovered that the "scrambling" rules used by the generators treat certain patterns of bits as the same, and it learned to respect those rules. This suggests the model isn't just guessing; it's building a mental map of the hidden mathematical symmetries.
In short, the paper shows that Transformers can learn to predict complex, scrambled number sequences, even when the information is heavily cut down. But they need the right training path: starting small and building up. While they can outperform some old-school hacking methods, they still hit a wall when the numbers get too big without that helpful curriculum. This tells us that while AI is getting better at finding hidden patterns, it still relies on a structured way of learning, much like a human student, to tackle the most difficult mathematical mysteries.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.