Halting in Recurrent Sequence Models
Organizations: Salk Institute for Biological Studies
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.
Figures & tables
| Secants used in the transport | Continuation accuracy |
|---|---|
| Exact | |
| Identity, | |
| Permuted across hidden units | |
| Mean across hidden units, same sequence and step | |
| Circularly shifted in time | |
| Taken from other sequences |
| Intervention | Stopping | Content | Complete |
|---|---|---|---|
| RNN, affine state transformation from to copies remaining | |||
| Fitted transformation, new sequences | |||
| Mean change, same count and cycle | |||
| Targets shuffled across sequences | |||
| replaced by mean target state | |||
| SSM, amplitude-preserving phase rotations | |||
Appendix figures & tables3 assets
Supplementary material from the paper’s appendix.
Appendix
Recurrent Neural Networks
Recurrent neural networks process sequences by updating a persistent hidden state, enabling temporal modeling, memory, and streaming computation.
See all 333 papers