Transformers represent belief state geometry in their residual stream

Adam S. Shai, Sarah E. Marzen, Lucas Teixeira, Alexander Gietelink Oldenziel, Paul M. Riechers
5/24/2024
cs.LGcs.CL

No official code found. Best implementation: Gabe-Thomp/Belief-State-Replication (0 stars, last commit 2025-04-23). 1 more below.

Abstract

What computational structure are we building into large language models when we train them on next-token prediction? Here, we present evidence that this structure is given by the meta-dynamics of belief updating over hidden states of the data-generating process. Leveraging the theory of optimal prediction, we anticipate and then find that belief states are linearly represented in the residual stream of transformers, even in cases where the predicted belief state geometry has highly nontrivial fractal structure. We investigate cases where the belief state geometry is represented in the final residual stream or distributed across the residual streams of multiple layers, providing a framework to explain these observations. Furthermore we demonstrate that the inferred belief states contain information about the entire future, beyond the local next-token prediction that the transformers are explicitly trained on. Our work provides a general framework connecting the structure of training data to the geometric structure of activations inside transformers.

View on arXivView PDF

Code Implementations(2)

A quick replication of the paper Transformers Represent Belief State Geometry in their Residual Stream!

00Jupyter NotebookApr 23, 20251 years ago
machine-learningmechanistic-interpretability

Trying to replicate the paper "Transformers Represent Belief State Geometry in their Residual Stream", and further analyzing the internal model circuitry

00Jupyter NotebookApr 19, 20251 years ago

Cite this paper

@article{shai2024transformers,
  title  = {Transformers represent belief state geometry in their residual stream},
  author = {Adam S. Shai and Sarah E. Marzen and Lucas Teixeira and Alexander Gietelink Oldenziel and Paul M. Riechers},
  year   = {2024},
  eprint = {2405.15943},
  archivePrefix = {arXiv},
  doi    = {10.48550/arXiv.2405.15943},
  url    = {http://arxiv.org/abs/2405.15943v3},
  journal = {NEURIPS 2024 2024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2405.15943.svg)](https://codeofpaper.com/paper/2405.15943)

Discussion