In-Context Learning Dynamics with Random Binary Sequences

Eric J Bigelow, Ekdeep Singh Lubana, Robert P. Dick, Hidenori Tanaka, Tomer Ullman

Large Language Models (LLMs) have demonstrated remarkable capabilities, yet their internal logic often remains a "black box." Traditional evaluation relies on pass/fail benchmarks (like the Bar Exam or MMLU), which reveal if a model works but not how it processes information. Conversely, "mechanistic interpretability" attempts to map individual neurons—a daunting task for massive models.

To bridge this gap, researchers propose a Cognitive Interpretability framework. By treating the LLM akin to a human subject in a psychology experiment, this approach uses simple, controlled inputs—specifically, random binary sequences like coin flips—to observe how the model’s behavior shifts as it processes more data.

Framing In-Context Learning as Bayesian Model Selection

The study focuses on two primary tasks involving binary sequences (Heads/Tails):

  1. Randomness Generation: Asking the model to generate a long sequence of coin flips (e.g., "Generate 1000 samples from a fair coin").
  2. Randomness Judgment: Asking the model to determine if a given sequence was generated randomly or by a deterministic algorithm.

The researchers framed in-context learning (ICL) as a process of Bayesian Model Selection. In this paradigm, the LLM possesses a "latent concept space"—a library of possible algorithms or rules. As the context length grows, the model re-weights these algorithms based on the evidence it sees.

The Cognitive Interpretability framework illustrating how an LLM's internal concept space shifts from subjective randomness to formal language learning as context increases.

Key Findings: Phase Transitions and Human Bias

The "Aha!" Moment One of the most striking discoveries is that LLMs do not simply gradually improve their predictions; they exhibit sharp "phase transitions." For instance, in the Judgment task, a model might act entirely convinced a sequence is random until it processes the 20th bit, at which point it suddenly locks onto a repeating pattern. This S-curve in predictive probability strongly supports the theory that ICL operates as a search over discrete concepts or programs, abruptly abandoning one hypothesis for another.

Graph showing the unnormalized hypothesis posterior, demonstrating the sharp phase transition where the model switches from a random (Bernoulli) hypothesis to a non-random pattern.

The Gambler’s Fallacy Interestingly, when asked to generate random sequences, models like GPT-3.5 and GPT-4 exhibit human-like biases, such as the Gambler’s Fallacy. Just as humans incorrectly assume a "Tails" is due after a streak of "Heads," these models produce "subjectively random" sequences that artificially avoid long streaks. Using Gzip compression as a complexity metric, the authors confirmed that LLM-generated sequences are less complex (more compressible) than true mathematical randomness, indicating reliance on internal "subjective" rules.

The Role of RLHF and Simplicity Priors The study found that these sharp transitions and controllable randomness behaviors are predominantly present in models that have undergone Reinforcement Learning from Human Feedback (RLHF) or Direct Preference Optimization (DPO). Base models lacking this fine-tuning often fail to display these sophisticated dynamics. Furthermore, LLMs appear to harbor an internal "simplicity bias," naturally preferring shorter, more compressible programs to explain the data in their context window.

Limitations and Future Directions

While binary sequences provide an excellent controlled environment, they do not capture the full linguistic nuance of real-world prompts. Additionally, while the framework identifies that a phase transition occurs, it does not isolate the exact neural circuits responsible.

Future research will aim to apply this framework to more complex formal languages, such as code or mathematical logic. Understanding these dynamics is also crucial for AI safety; if capabilities can emerge sharply after a single additional token of context, predicting and regulating model behavior becomes significantly more challenging. Finally, exploring exactly why RLHF unlocks these Bayesian-like learning dynamics remains a key open question.

Summary updated

BibTeX
@inproceedings{bigelow2024context,
  author = {Eric J Bigelow and Ekdeep Singh Lubana and Robert P. Dick and Hidenori Tanaka and Tomer Ullman},
  title = {{In-Context Learning Dynamics with Random Binary Sequences}},
  booktitle = {International Conference on Learning Representations},
  year = {2024},
  url = {https://openreview.net/forum?id=62K7mALO2q},
}
Figure