Introduction
Modern machine learning models, particularly those dealing with sequences like Large Language Models (LLMs), often struggle when the sequence length at inference time exceeds the length seen during training. This "length generalization" problem is typically addressed with empirical heuristics. This paper provides a theoretical foundation and provable algorithms for length generalization using spectral filtering.
The Challenge of Context Length
In sequence prediction, "context length" refers to the history used to predict the next token. Training on long contexts is computationally expensive due to the quadratic scaling of architectures like Transformers. The goal is to train on short, computationally cheap sequences while maintaining robust performance on much longer sequences during inference.
Theoretical Framework: Asymmetric-Regret
The authors introduce Asymmetric-Regret, a novel metric for evaluating length generalization. Unlike standard regret, which compares a learner to a benchmark under identical conditions, Asymmetric-Regret compares a learner restricted to a shorter context length $L'$ against a benchmark that utilizes a significantly longer context $L$.
Methodology: Spectral Filtering
The research focuses on Spectral Filtering (SF), a technique for learning Linear Dynamical Systems (LDS) with long-range dependencies.
- Vanilla SF: Standard spectral filtering can achieve length generalization, provided the system's eigenvalues avoid "bad" regions near 1 (marginal stability).
- Autoregressive SF: By incorporating an additional autoregressive term ($y_{t-2}$), the model achieves robust length generalization for any stable LDS without further assumptions.
- Tensorized SF: Utilizing Kronecker products to create "tensorized" filters increases expressivity, enabling the model to handle certain time-varying or non-linear systems.
Key Insights
- The "Bad" Region: The identification of specific eigenvalue ranges where short-context models struggle provides a mathematical explanation for generalization difficulties.
- Autoregression as a Stabilizer: A simple architectural change (adding $y_{t-2}$) significantly relaxes the requirements for generalization.
- Spectral Transform Units (STUs): The authors demonstrate that STUs, which use spectral filtering, possess inherent length generalization capabilities "out-of-the-box."
- Expressivity through Tensorization: While vanilla SF is effective for linear systems, tensorization allows for solving complex non-linear tasks like the "Copy" task.
Results and Empirical Validation
The authors prove that their algorithms achieve $O(\sqrt{T})$ Asymmetric-Regret, implying that the average error gap between short-context and long-context models vanishes as sequence length $T$ increases.
Experiments on synthetic LDS confirmed these bounds. For instance, models trained with a context of $T^{7/8}$ performed almost identically to those with full context. On the Induction Heads task, STUs generalized to longer sequences, and Tensorized STUs achieved near-perfect performance on the non-linear Copy task.
Conclusion
This work bridges the gap between empirical success and theoretical understanding in length generalization. By framing the problem through Asymmetric-Regret and leveraging spectral filtering, the authors provide a path toward more efficient and robust sequence models. Future work will focus on extending these guarantees to fully non-linear, multi-layer neural networks and large-scale real-world datasets.
Summary updated