Abstract
Large Language Models (LLMs) based on the Transformer architecture face significant scalability challenges due to the quadratic computational complexity of the self-attention mechanism. While linear recurrent models offer $O(T)$ scaling, transitioning existing pretrained models to these structures typically requires prohibitive retraining costs. We present Liger (Linearizing LLMs to Gated Recurrent Structures), a framework that converts standard Transformers into efficient gated recurrent models by repurposing existing weights. By utilizing the pretrained Key matrix as a gating mechanism and introducing a hybrid "Liger Attention" module, our approach recovers up to 93% of the original model's performance using only 0.02% of the tokens required for initial pre-training.
1. Introduction
The "Attention Is All You Need" paradigm established the Transformer as the state-of-the-art for language modeling. However, the $O(T^2)$ complexity of Softmax attention imposes severe constraints on sequence length and inference speed. While linear recurrent models (e.g., Mamba, Gated Linear Attention) offer $O(T)$ scaling and constant memory inference, training them from scratch is a massive investment. Liger addresses this by "linearizing" existing, high-performing Transformers, leveraging their pretrained knowledge to jumpstart efficient inference without adding a single new parameter.
2. Methodology
Liger's architecture is defined by three primary innovations that bridge the gap between quadratic attention and linear recurrence.
2.1 Gate Construction via Key Projection
A significant hurdle in linearization is the need for gating mechanisms to manage memory. Instead of introducing new, untrained weights, Liger "repurposes" the pretrained Key matrix ($W_K$). By applying a parameter-free pooling operation to the projected keys, the model generates dynamic gates that control information flow. This approach exploits the inherent structural redundancy already present in large-scale models.
2.2 Liger Attention
To mitigate the loss of local precision common in pure linear attention, we introduce Liger Attention. This hybrid module combines Gated Recurrent Modeling (GRM) for long-range context with a narrow Sliding Window Attention (SWA) for local dependencies. This dual-pathway ensures the model retains high-frequency information while maintaining linear scaling for the majority of the sequence.
2.3 Lightweight Fine-tuning
Post-conversion, the model undergoes a brief fine-tuning phase using Low-Rank Adaptation (LoRA). This step "re-aligns" the model's existing knowledge with the new recurrent logic using a minimal dataset of approximately 20 million tokens.
3. Experimental Setup
We evaluated Liger using Llama-3.2 (1B, 3B), Llama-3 (8B), and Mistral-7B as base models. Training was performed on 50,000 instruction samples from the Cleaned Alpaca dataset. Evaluation spanned several standard benchmarks, including PiQA (physical reasoning), ARC-e/c (science questions), HellaSwag (common sense), WinoGrande (logic), and MMLU (general knowledge).
4. Results and Discussion
Liger demonstrates a remarkable ability to recover performance with minimal data. As shown in the performance analysis, the Liger-GLA-1B model closely tracks the performance of the original Llama-3.2-1B across multiple reasoning tasks.
4.1 Data Efficiency
Compared to traditional "uptraining" or distillation methods that require billions of tokens, Liger achieves competitive results with just 0.02B tokens—a 1000x to 10,000x reduction in data requirements. This efficiency makes the transition to linear-time models accessible even with limited compute resources.
4.2 Scalability and Inference Efficiency
The performance gap between the original Transformer and its Liger counterpart decreases as model size increases, narrowing from 4.8% at the 1B scale to just 1.8% at the 8B scale. Furthermore, Liger maintains constant GPU memory usage regardless of sequence length, avoiding the "Out of Memory" (OOM) errors that plague standard Transformers as the KV cache grows.
5. Conclusion
Liger provides a practical pathway for upgrading existing LLMs to linear-time architectures. By repurposing existing weights and employing a hybrid attention mechanism, it achieves high performance recovery with unprecedented data efficiency. Future work will focus on closing the remaining performance gap on complex reasoning tasks like MMLU and exploring more sophisticated gating functions.
Summary updated