Saved in:
Bibliographic Details
Main Authors: Li, Belinda Z., Guo, Zifan Carl, Andreas, Jacob
Format: Preprint
Published: 2025
Subjects:
Online Access:https://arxiv.org/abs/2503.02854
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866908621672022016
author Li, Belinda Z.
Guo, Zifan Carl
Andreas, Jacob
author_facet Li, Belinda Z.
Guo, Zifan Carl
Andreas, Jacob
contents Transformer language models (LMs) exhibit behaviors -- from storytelling to code generation -- that seem to require tracking the unobserved state of an evolving world. How do they do this? We study state tracking in LMs trained or fine-tuned to compose permutations (i.e., to compute the order of a set of objects after a sequence of swaps). Despite the simple algebraic structure of this problem, many other tasks (e.g., simulation of finite automata and evaluation of boolean expressions) can be reduced to permutation composition, making it a natural model for state tracking in general. We show that LMs consistently learn one of two state tracking mechanisms for this task. The first closely resembles the "associative scan" construction used in recent theoretical work by Liu et al. (2023) and Merrill et al. (2024). The second uses an easy-to-compute feature (permutation parity) to partially prune the space of outputs, and then refines this with an associative scan. LMs that learn the former algorithm tend to generalize better and converge faster, and we show how to steer LMs toward one or the other with intermediate training tasks that encourage or suppress the heuristics. Our results demonstrate that transformer LMs, whether pre-trained or fine-tuned, can learn to implement efficient and interpretable state-tracking mechanisms, and the emergence of these mechanisms can be predicted and controlled.
format Preprint
id arxiv_https___arxiv_org_abs_2503_02854
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle (How) Do Language Models Track State?
Li, Belinda Z.
Guo, Zifan Carl
Andreas, Jacob
Computation and Language
Artificial Intelligence
Machine Learning
Transformer language models (LMs) exhibit behaviors -- from storytelling to code generation -- that seem to require tracking the unobserved state of an evolving world. How do they do this? We study state tracking in LMs trained or fine-tuned to compose permutations (i.e., to compute the order of a set of objects after a sequence of swaps). Despite the simple algebraic structure of this problem, many other tasks (e.g., simulation of finite automata and evaluation of boolean expressions) can be reduced to permutation composition, making it a natural model for state tracking in general. We show that LMs consistently learn one of two state tracking mechanisms for this task. The first closely resembles the "associative scan" construction used in recent theoretical work by Liu et al. (2023) and Merrill et al. (2024). The second uses an easy-to-compute feature (permutation parity) to partially prune the space of outputs, and then refines this with an associative scan. LMs that learn the former algorithm tend to generalize better and converge faster, and we show how to steer LMs toward one or the other with intermediate training tasks that encourage or suppress the heuristics. Our results demonstrate that transformer LMs, whether pre-trained or fine-tuned, can learn to implement efficient and interpretable state-tracking mechanisms, and the emergence of these mechanisms can be predicted and controlled.
title (How) Do Language Models Track State?
topic Computation and Language
Artificial Intelligence
Machine Learning
url https://arxiv.org/abs/2503.02854