arXiv(opens in a new tab)cs.LGSep 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2609.17376

Large Language Models Develop Belief State Geometry In-Context

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

Daniel Balcells*

Independent

Andrew Jun Lee*

UCLA

Paul M. Riechers

Simplex

Astera Institute

Chirag Rastogi*

UIUC

Adam Shai

Simplex

Astera Institute

Xavier Poncini†

Simplex

Abstract

Large language models (LLMs) trained on next-token prediction exhibit remarkable in-context learning (ICL) abilities, yet the representations that support ICL remain poorly understood. We consider such representations in a controlled setting: prompting LLMs with data emitted from hidden Markov models (HMMs) and probing for the corresponding belief state—the posterior distribution over the HMM's hidden states given the observed token history. Across six open-source LLMs prompted with data from 40 HMMs selected for non-trivial belief structure, we find that belief states are linearly decodable from residual stream activations, with peak probe R2R^{2}-values from 0.83–0.99 across HMM and LLM combinations, ranging from early to late layers. To establish functional relevance, we intervene directly on the probe-identified subspace via patching and steering, resulting in downstream prediction quality on the order of the untampered model, while controls degrade performance substantially. Together, these results provide representation-level evidence that ICL in open-source LLMs approximates optimal Bayesian prediction over a context-inferred generative model. More broadly, our findings extend prior results linking input-distribution structure to activation geometry: from toy networks trained explicitly on HMM data to production-scale LLMs.

1 Introduction

How do the activations in large language models (LLMs) organize themselves when they see tokens from a process that was not present in the training distribution? The capability to do well on such tasks, called in-context learning (ICL), has been characterized extensively at the level of behavior (Wei et al., 2022; Min et al., 2022; Chan et al., 2022; Dong et al., 2024), and a smaller body of work has begun probing the representations that underlie it (Hendel et al., 2023; Todd et al., 2024; Park et al., 2025; Sarfati et al., 2026). But theoretically-derived, falsifiable predictions about these representations are largely absent (though see Park et al., 2025 for a notable exception). Not only do such predictions provide specific representational targets that can be probed and intervened upon, but perhaps more importantly the theory behind such predictions tells us what these representations mean and where they come from. In this work, we draw on the framework of computational mechanics to make a concrete prediction (Shalizi and Crutchfield, 2001; Crutchfield, 2012; Shai et al., 2024): LLMs that learn in-context to predict data generated by a hidden Markov model (HMM) represent the belief state of the process—the posterior distribution over the HMM's hidden states given the observed context (Figure 1). We show, across a suite of open-source LLMs, that this hypothesized belief state representation is linearly decodable from the residual stream when LLMs perform near-optimal prediction and is causally relevant for LLMs' downstream prediction.

∗^{*}Equal contribution; authors listed alphabetically. †\daggerCorrespondence to xponcini@gmail.com.

Preprint.

A) HIDDEN MARKOV MODEL

PRE-TRAINED LLM

ACTIVATIONS

Figure

Emits Tokens

Bayesian Updating

Figure

B)

LLMs predict HMM data in context...

Figure

represent belief state geometry...

and use belief states for predictions.

Figure

Figure 1: HMMs induce belief state geometry in LLMs. (a) An HMM (left) emits tokens by transitioning between hidden states (S1, S2, S3). Conditioning on this sequence in-context, an LLM (middle) predicts the next token. Computational mechanics suggests that optimal prediction requires tracking the belief state—the posterior over the HMM’s hidden states—whose reachable set traces a characteristic geometry in the activation space (right). (b) Results preview for one HMM (Wing). The LLM predicts near-optimally in-context (left), linear probes recover the belief geometry far beyond controls (middle), and intervening on the belief subspace influences the predictions (right).

Theoretical accounts frame ICL as inference over latent structure. In the mixture-of-HMMs setting of Xie et al. (2022), ICL corresponds to Bayesian inference over the class of generative models consistent with the context. We take this to be the first of two levels at which ICL operates. In the second level, operating simultaneously with the first, the LLM must infer the latent state of each candidate process as tokens arrive in-context. HMMs, which are simple generative models of natural text, are well-suited processes for studying this second level because an HMM admits a well-defined notion of belief state which is the canonical representation of Bayesian inference at this level (Shalizi and Crutchfield, 2001; Crutchfield, 2012). Toy transformers trained to predict HMM data have been shown to linearly encode the belief state in their activations (Shai et al., 2024), and open-source LLMs demonstrate the ability to predict HMM-generated sequences competently in-context, despite never being trained on them (Dai et al., 2025). Taken together, these two observations suggest that the hypothesized belief state representation of computational mechanics may also arise in production-scale LLMs. For a broader discussion of related work, see Appendix B.

Our setting combines the two levels of inference discussed above. We hypothesize that an LLM prompted with data from an unseen HMM simultaneously identifies the process and, for that process, tracks the posterior over hidden states. Across six open-source LLMs, we select 40 HMMs (among which are 30 newly designed processes) on which the chosen LLMs achieve near-optimal next-token prediction (Dai et al., 2025), and find that the belief state is linearly decodable from residual stream activations after sufficient context. To establish that this representation is computationally relevant, we apply targeted interventions, namely steering and patching, to the probe-identified subspace. Both preserve downstream prediction quality (measured as the Kullback–Leibler divergence to the ground-truth distribution) on the order of the untampered model, while interventions that substitute an unrelated point on the identified subspace degrade performance substantially. Together, these results provide representation-level evidence that ICL of HMM data in open-source LLMs approximates optimal Bayesian prediction over the ground truth generative process. More generally, they extend the computational-mechanics account of belief state geometry from toy transformers trained on HMM data to open-source LLMs.

Our contributions are summarized as follows:

• Belief-state geometry is linearly decodable from LLMs prompted with HMM data. Across six open-source LLMs and 40 HMMs selected for non-trivial belief structure, linear probes recover the predicted geometry from residual stream activations, with peak R2R^{2}-values ranging from 0.83 to 0.99 in early to late layers.

• The belief-state subspace is causally relevant. Targeted interventions on the subspace, patching and steering, preserve downstream prediction quality on the order of the untampered model, while interventions that substitute an unrelated point on the simplex degrade it substantially.

• Computational mechanics applies to production-scale LLMs. Our representational and causal findings extend the computational mechanics account of belief-state geometry beyond toy transformers trained explicitly on HMM data to open-source LLMs that have encountered a wide variety of data.

References (77)