Uncovering the Computational Roles of Nonlinearity in Sequence Modeling Using Almost-Linear RNNs
Manuel Brenner, Georgia Koppe
TL;DR
The paper introduces Almost-Linear RNNs (AL-RNNs) to systematically study when nonlinear recurrence is truly necessary for sequence modeling. By controlling the number of nonlinear units $P$ and partitioning the hidden state into $2^P$ linear subregions via piecewise linear units, the work reveals how memory can be implemented through slow linear modes while nonlinear switches enable gating, routing, and regime changes. Across a diverse set of tasks—including sentiment and image/audio sequence integration, memory recall, gating in addition, contextual integration, and SCAN—the authors show that sparse nonlinearity greatly improves interpretability and sample efficiency, enabling reusable nonlinear motifs in multi-task settings. In contrast, fully nonlinear models often underperform or train less robustly, highlighting the inductive benefit of sparsity. The results provide a principled design principle for balancing performance, efficiency, and interpretability in recurrent architectures and offer a framework for analyzing latent dynamics in both artificial and biological systems.
Abstract
Sequence modeling tasks across domains such as natural language processing, time series forecasting, and control require learning complex input-output mappings. Nonlinear recurrence is theoretically required for universal approximation of sequence-to-sequence functions, yet linear recurrent models often prove surprisingly effective. This raises the question of when nonlinearity is truly required. We present a framework to systematically dissect the functional role of nonlinearity in recurrent networks, identifying when it is computationally necessary and what mechanisms it enables. We address this using Almost Linear Recurrent Neural Networks (AL-RNNs), which allow recurrence nonlinearity to be gradually attenuated and decompose network dynamics into analyzable linear regimes, making computational mechanisms explicit. We illustrate the framework across diverse synthetic and real-world tasks, including classic sequence modeling benchmarks, a neuroscientific stimulus-selection task, and a multi-task suite. We demonstrate how the AL-RNN's piecewise linear structure enables identification of computational primitives such as gating, rule-based integration, and memory-dependent transients, revealing that these operations emerge within predominantly linear backbones. Across tasks, sparse nonlinearity improves interpretability by reducing and localizing nonlinear computations, promotes shared representations in multi-task settings, and reduces computational cost. Moreover, sparse nonlinearity acts as a useful inductive bias: in low-data regimes or when tasks require discrete switching between linear regimes, sparsely nonlinear models often match or exceed fully nonlinear architectures. Our findings provide a principled approach for identifying where nonlinearity is functionally necessary, guiding the design of recurrent architectures that balance performance, efficiency, and interpretability.
