Large Language Models Develop Belief State Geometry In-Context

Daniel Balcells, Andrew Jun Lee, Chirag Rastogi, Paul M. Riechers, Adam Shai, Xavier Poncini

TL;DR

Researchers have discovered that Large Language Models (LLMs) perform in-context learning by building internal geometric representations of a process's "belief state"—the probability distribution over hidden states. By testing models on data from Hidden Markov Models (HMMs), they proved that these belief states are linearly encoded in the model's activations and are causally responsible for the model's next-token predictions.

What Problem Does This Paper Address?

While we know LLMs are incredible at in-context learning (ICL)—picking up new tasks just from a few examples in a prompt—we don't really know how they do it under the hood. Is the model just performing a sophisticated version of "fuzzy matching" on recent tokens, or is it actually inferring the underlying logic of the data-generating process?

The authors turn to computational mechanics, a field that studies how systems represent information to predict the future. Theory suggests that to predict a stochastic process optimally, an agent must track its "belief state": the posterior probability of being in any given hidden state based on the observed history. This paper asks: Do production-scale LLMs actually develop these belief state representations when they encounter new types of data in their context window?

Methods

The researchers prompted six open-source LLMs (including Qwen 3.5, Llama 3.1, and Gemma 4) with sequences of tokens generated by Hidden Markov Models (HMMs). HMMs are perfect for this because they have clear, mathematically defined "hidden states" and "belief states" that the researchers can compare against the model's internal activations.

The study employed three main techniques:

  1. Linear Probing: They trained simple linear regressions to see if they could "read" the HMM's ground-truth belief state directly from the LLM's residual stream activations.
  2. Causal Interventions (Steering and Patching): To prove the model actually uses these representations, they manually edited the activations. "Patching" involves overwriting a specific subspace with a target belief, while "steering" involves nudging the activation in a specific direction.
  3. Tuned Lens: They decoded activations from intermediate layers to see if the model's "internal" predictions at layer 10, for example, were already approximating the ground truth.
Overview of HMMs inducing belief state geometry in LLMs

Datasets

The study used synthetic sequences generated from 40 different HMMs across four families: Mess3, Arch, Wing, and Strata.

  • Novelty: 30 of these HMMs were newly designed for this paper to ensure the LLMs hadn't seen these specific patterns during their massive pre-training phases.
  • Complexity: The HMMs were selected for having "non-trivial belief structure," meaning you can't predict the next token accurately just by looking at the last one or two tokens; you have to track the hidden state over time.

Key Insights and Ideas

  • The Geometry of Logic: The most striking finding is that the belief state—a purely mathematical probability distribution—is mapped onto a linear subspace within the LLM. This means the model's "thoughts" about the probability of hidden states are organized geometrically.
  • In-Context Bayesian Inference: The results suggest that ICL isn't just pattern matching; it's an approximation of optimal Bayesian inference. The model identifies the "generative model" from the context and then tracks the state of that model.
  • Causal Relevance: The belief state isn't just a "read-only" log. When the researchers intervened on the belief subspace, the model's final output changed in exactly the way the HMM math predicted it should.
  • Self-Repair: The authors noticed a "self-repair" mechanism. If they tried to steer the model's beliefs in very early layers, the model often "corrected" itself in later layers to match the actual token history it saw in the prompt.
Linear probes recovering belief geometry

Key Results

  • High Decodability: Linear probes achieved peak $R^2$ values between 0.83 and 0.99 across different model and HMM combinations. This shows the belief state is represented with incredible clarity.
  • Outperforming Baselines: LLMs significantly outperformed "Markov order-k" baselines. While a simple heuristic might look at the last 1 or 2 tokens, the LLMs performed as well as an optimal predictor looking at the last 4 to 11 tokens.
  • Successful Steering: Patching the belief state into the model's activations caused the model to shift its predictions toward the "injected" belief, even when that belief contradicted the actual token history provided in the prompt.
Patching results showing shifted predictions

Limitations and Future Work

The authors acknowledge a few key bounds to their study:

  • Scope of Processes: They only tested HMMs with low entropy and specific mixing rates. It's unclear if these geometric representations hold for much more complex or high-dimensional processes.
  • Linearity Concerns: While linear probes are standard, some researchers argue they can find "structure" in random noise if the target is low-dimensional enough. The authors used rigorous controls to mitigate this, but unsupervised evidence would be a stronger next step.
  • Scaling: The smallest model (Gemma-4-E2B) showed weaker results, suggesting that the ability to develop this internal geometry might be a "capability" that emerges or sharpens as models get larger.

Future work could explore how this geometry changes as models scale up, or how LLMs handle "factored" processes where multiple hidden variables interact simultaneously.

Summary updated

BibTeX
@inproceedings{balcells2026large,
  author = {Daniel Balcells and Andrew Jun Lee and Chirag Rastogi and Paul M. Riechers and Adam Shai and Xavier Poncini},
  title = {{Large Language Models Develop Belief State Geometry In-Context}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=XrED7AYb8U},
}
Figure