Constrained belief updates explain geometric structures in transformer representations

Mateusz Piotrowski, P. Riechers, Daniel Filan, A. Shai
2/1/2025
transformer-attentionbayesian

No confident code implementation found for this paper.

Abstract

What computational structures emerge in transformers trained on next-token prediction? In this work, we provide evidence that transformers implement constrained Bayesian belief updating -- a parallelized version of partial Bayesian inference shaped by architectural constraints.

Show full abstract

We integrate the model-agnostic theory of optimal prediction with mechanistic interpretability to analyze transformers trained on a tractable family of hidden Markov models that generate rich geometric patterns in neural activations. Our primary analysis focuses on single-layer transformers, revealing how the first attention layer implements these constrained updates, with extensions to multi-layer architectures demonstrating how subsequent layers refine these representations. We find that attention carries out an algorithm with a natural interpretation in the probability simplex, and create representations with distinctive geometric structure. We show how both the algorithmic behavior and the underlying geometry of these representations can be theoretically predicted in detail -- including the attention pattern, OV-vectors, and embedding vectors -- by modifying the equations for optimal future token predictions to account for the architectural constraints of attention. Our approach provides a principled lens on how architectural constraints shape the implementation of optimal prediction, revealing why transformers develop specific intermediate geometric structures.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{piotrowski2025constrained,
  title  = {Constrained belief updates explain geometric structures in transformer representations},
  author = {Mateusz Piotrowski and P. Riechers and Daniel Filan and A. Shai},
  year   = {2025},
  eprint = {2502.01954},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2502.01954},
  journal = {ICML 2025 2025}
}

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/2502.01954.svg)](https://codeofpaper.com/paper/2502.01954)

Discussion