TL;DR
This paper introduces SUPRA, a method to convert large pre-trained Transformer LLMs into RNNs with minimal retraining. This approach leverages existing powerful LLMs to achieve competitive performance with significantly reduced compute costs, while also highlighting persistent limitations of recurrent models in in-context learning.
What Problem Does This Paper Address?
Transformers have revolutionized NLP, but their quadratic complexity in sequence length makes inference computationally expensive. Recurrent Neural Networks (RNNs), on the other hand, offer constant inference cost per token due to their fixed-size hidden state. However, traditional RNNs have historically lagged behind Transformers in performance. Linear Transformers offer a potential bridge, achieving subquadratic complexity and enabling RNN-like inference. Yet, these models often underperform compute-matched Transformers. The challenge is to efficiently create high-performing recurrent models that can leverage the vast knowledge embedded in pre-trained Transformers without incurring prohibitive training costs.
Methods
The core contribution is the Scalable UPtraining for Recurrent Attention (SUPRA) method. Instead of pre-training linear models from scratch, SUPRA takes existing, large pre-trained Transformer LLMs and "uptrains" them into RNNs. This involves:
- Linearization of Attention: The standard softmax attention mechanism in Transformers is replaced with a linear attention formulation. This is achieved by modifying the attention block:
- The softmax normalization is replaced with a GroupNorm operation.
- A small MLP is introduced to project queries and keys, enabling a trainable kernel.
- Rotary Positional Embeddings (RoPE) are used, with a specific scaling strategy (similar to YaRN) for better long-context handling.
- A fixed decay vector is applied.
- Uptraining: The modified model is then trained for a modest number of steps (e.g., 5% of the original pre-training cost) on a fraction of the pre-training data. This process fine-tunes the new parameters and adapts the existing Transformer weights to the recurrent architecture.
The paper builds upon prior work like T2R (Kasai et al., 2021) but addresses its instability and performance drop by introducing GroupNorm instead of a simple normalization factor and by leveraging stronger base models.
Datasets
The paper mentions using the following datasets:
- Training: The authors leverage large-scale, proprietary pre-training datasets (e.g., C4, RefinedWeb) for the base Transformer models. For the "uptraining" phase, they use a fraction of these datasets.
- Evaluation:
- Standard NLU Benchmarks: HellaSwag, PIQA, WG, ARC-E, ARC-C, MMLU.
- Long-Context Evaluation: Qasper (2-shot) and NarrativeQA (0-shot) from the SCROLLS benchmark.
Key Insights and Ideas
- Leveraging Pre-trained LLMs is Key: The SUPRA method demonstrates that "uptraining" existing, powerful Transformer LLMs is a more efficient and effective way to create high-performing recurrent models than pre-training linear models from scratch, especially when compute is limited.
- Normalization is Crucial for Stability: The paper highlights that the choice of normalization (specifically GroupNorm) is critical for stable uptraining of large models, preventing performance degradation seen in prior methods.
- Linear Models Inherit Limitations: Despite achieving competitive performance on many tasks, the linearized models (SUPRA) still exhibit significant shortfalls in in-context learning (e.g., MMLU) and long-context modeling, suggesting these are inherent limitations of the linear attention mechanism itself, rather than just a consequence of the training process.
- Attention Matrices are Not Approximated: The analysis in Appendix A shows that the attention matrices produced by SUPRA are not simple approximations of the original softmax attention matrices, indicating a fundamental architectural shift rather than just a reparameterization.
Key Results
- Competitive Performance: SUPRA models (e.g., Mistral-SUPRA, Llama2-SUPRA) achieve performance competitive with state-of-the-art pre-trained recurrent models like RWKV and Mamba, often outperforming them with significantly less training cost (around 5% of the original pre-training cost).
- Efficiency Gains: The uptraining process requires a fraction of the compute needed for pre-training from scratch. For example, a 7B model can be uptrained with just 20B tokens.
- Long-Context Performance: While transformers with modifications like YaRN can scale well, SUPRA models show a more consistent ability to maintain performance at longer contexts compared to some other recurrent models, though a gap remains with modified transformers.
- In-Context Learning Shortfall: A persistent gap is observed on tasks requiring in-context learning (like MMLU), where linear models generally underperform their Transformer counterparts.
Limitations and Future Work
- Inherited Biases: SUPRA models inherit any biases and weaknesses present in the base pre-trained Transformer LLMs.
- Instruct-Tuned Models: Models that are already instruct-tuned do not linearize as well as base models.
- In-Context Learning Gap: The paper explicitly identifies the persistent weakness of linear models on in-context learning tasks (e.g., MMLU) as a significant limitation.
- Future Work Suggestions:
- Explicitly training for in-context learning.
- Exploring more sophisticated gating mechanisms or higher-order linear attention.
- Investigating specialized and instruct data for linear transformers.
- Extending linear models to better leverage lower inference costs for long-context inference.
Summary updated