TL;DR
This paper introduces Griffin, a novel hybrid language model that combines gated linear recurrences with local attention. Griffin achieves performance comparable to large Transformer models like Llama-2, but with significantly less training data and computational cost. Crucially, Griffin demonstrates superior inference speed and the ability to handle much longer sequences than it was trained on, addressing key limitations of current Transformer architectures.
What Problem Does This Paper Address?
The paper tackles the trade-offs between recurrent neural networks (RNNs) and Transformer models for large language models (LLMs). While RNNs offer efficient inference and scalability on long sequences, they have historically been difficult to train and scale. Transformers, on the other hand, are highly scalable and efficient to train on modern hardware but suffer from quadratic complexity in attention mechanisms, leading to slow inference and memory issues with long sequences. The authors aim to bridge this gap by developing models that retain the training efficiency and scalability of Transformers while offering the inference benefits of RNNs, particularly for long contexts.
Methods
The core innovation lies in two new model architectures: Hawk and Griffin.
- Hawk: A pure RNN model that utilizes a novel "Real-Gated Linear Recurrent Unit" (RG-LRU) layer. This RG-LRU incorporates a gating mechanism inspired by LSTMs and GRUs, designed for numerical stability and efficient computation.
- Griffin: A hybrid model that mixes RG-LRU recurrent blocks with local attention mechanisms. This combination aims to leverage the strengths of both approaches: the long-range memory of recurrences and the localized context processing of attention.
Both models are built upon a standard Transformer-like residual block and gated MLP block structure. The RG-LRU layer itself is a key novelty, featuring a diagonal recurrence weight for element-wise operations and a gating mechanism that allows for flexible interpolation between retaining past information and incorporating new input, potentially enabling "super-exponential memory."
Datasets
- MassiveText: Used for training models across various scales. The paper mentions using a slightly different data subset distribution than previous work.
- Held-out books dataset: Used for evaluating long-context modeling and extrapolation capabilities.
- arXiv articles dataset: Also used for evaluating long-context modeling.
- Synthetic tasks:
- Selective Copying Task: Models learn to copy data tokens while ignoring noise tokens.
- Induction Heads Task: Models learn to recall the token immediately following a special token.
- Phone number lookup task: Used to evaluate pre-trained models on copying and retrieval capabilities.
Key Insights and Ideas
- Hybridization is Key: Griffin's success highlights that a hybrid approach, combining the strengths of recurrent mechanisms and local attention, can outperform pure RNNs or Transformers on certain tasks and metrics.
- RG-LRU's Gating Power: The novel RG-LRU gate appears to be crucial for achieving strong performance and enabling efficient long-context handling, offering a different interpolation behavior than existing gates.
- Extrapolation Beyond Training: Griffin and Hawk demonstrate a remarkable ability to generalize to sequence lengths significantly longer than those seen during training, a capability often limited in standard Transformers.
- Inference Efficiency is Achievable: The paper convincingly shows that RNN-based architectures can match or exceed Transformer inference speeds, especially for longer sequences, by reducing memory overhead (e.g., smaller KV cache).
- Hardware Co-design Matters: The authors emphasize the importance of efficient kernel implementations (e.g., Pallas kernel for RG-LRU on TPUs) to unlock the potential of these new architectures on modern hardware.
Key Results
- Performance: Griffin-7B and Griffin-14B match Llama-2 performance despite being trained on ~7x fewer tokens. Hawk-3B outperforms Mamba-3B on downstream tasks while trained on half the tokens.
- Training Efficiency: Griffin and Hawk exhibit comparable training efficiency to Transformers on TPU-v3.
- Inference Speed: Griffin and Hawk achieve significantly higher throughput and lower latency than MQA Transformers, especially for longer sequences.
- Long Context Extrapolation: Griffin and Hawk can extrapolate to sequences at least 4x longer than their training length, with Griffin showing particularly strong performance even with local attention.
- Copying/Retrieval: While Transformers excel at these tasks, Griffin shows promising capabilities, especially when its local attention window aligns with the context length.
Limitations and Future Work
- Copying/Retrieval for Fixed-State Models: The authors note that while Griffin shows promise, more work is needed to improve the copying and retrieval capabilities of fixed-state models.
- Local Attention Window Size: For Griffin, the performance gap with global attention Transformers reduces as sequence length grows, suggesting that the local attention window size might need to grow with the training sequence length for optimal performance.
- Hardware Dependence: The efficiency gains are demonstrated on TPUs, and the authors acknowledge that conclusions might differ for other accelerators.
- Future Directions: The paper implicitly suggests further exploration of hybrid architectures, novel gating mechanisms, and optimizing these models for various hardware platforms. The ability to extrapolate and handle long contexts efficiently opens doors for applications requiring deeper understanding of extended texts.
Summary updated