Halting in Recurrent Sequence Models
Abstract
Recurrent sequence models, such as recurrent neural networks (RNNs) and state space models (SSMs), are often trained to emit an end-of-sequence (EOS) token when their output sequence is complete. During training, EOS is treated as another token without a special loss term or incentive. Although this training paradigm is widely used, it is not understood how models decide to output EOS. We study a minimal version of the EOS halting problem in which networks are trained to emit a given input sequence an instructed number of times, followed by EOS. We train tanh RNNs and linear SSMs on this task, finding that the RNNs encode the number of tokens left to copy in a linear subspace, of which two principal components capture most of the variation. Hidden states with the same remaining count converge to a shared representation regardless of their instructed repeat count. By modulating the hidden state using an affine transformation at the boundary between copied sequences, we shift the RNN's state to the representation shared by states with one fewer copy remaining. The unchanged network emits EOS one copy earlier while reproducing the shortened target sequence in 94.4% of new sequences, revealing that this representation causally determines the stopping time. In the SSMs, the difference between trajectories with different repeat counts is separated across two-dimensional rotation planes whose contributions to the EOS comparison cancel during copying and align near the stopping time. Rotating the planes independently removes most of the intended stopping while preserving the copied content, which shows that the stopping time depends on the planes' relative phases. These results identify two candidate primitives of EOS halting in recurrent models: a shared encoding of the number of remaining tokens in tanh RNNs and phase alignment across fixed rotations in linear SSMs.
Create a lesson
Metadata
- Comments
- 16 pages, 7 figures, 2 tables. Accepted at the NeurIPS 2026 Workshop on Interpretability as a Science
Related papers
Boundary Representation-Driven Graph Transformer Modeling for Machining Operation Sequencing
Shared title terminologycs.LGFatemeh Elhambakhsh, Gaurav Ameta, Aditi Roy et al.
How to build and train your recurrent-depth model: A fixed-point perspective
Shared title terminologycs.LGThomas Pethick
Yggdrasil: Tree-Routed Recurrent Experts for State Tracking and Fast CPU Inference
Shared title terminologycs.LGCosmo Santoni
LoopPrune: Recurrent Pruning for Looped Diffusion Transformers
Shared title terminologycs.LGWeizhong Huang, Huaijia Kou, Yan Zhang et al.
A Log-Timescale Perturbation Bound for Selective State Space Models at Every Sequence Length
Shared title terminologycs.LGJack Humphries, Daniel Midgley
SemiNovo: Learning Beyond Search-Identified Spectra for De Novo Peptide Sequencing
Shared title terminologycs.LGPan Liu, Dongxin Lyu, Yusen Tan et al.