Researchers analyzed a two-layer transformer trained to predict the next state in sequences generated by a finite set of discrete Markov chains. They identified four phases, differing in whether the network memorized the training processes or generalized beyond them, and whether it relied on one-point or two-point statistics.

The phases were implemented by different multi-layer subcircuits. One circuit estimated transition patterns directly from the sequence, while another identified the underlying process, pooled that information into a compact task representation and used it to make predictions. Two boundaries linked the shift between memorization and generalization to the diversity of the training data, with one arising from competition between circuits and the other from a limit on the network’s representation.