[Paper Review] RWKV: Reinventing RNNs for the Transformer Era
RWKV introduces a hybrid architecture that combines the training efficiency of Transformers with the inference efficiency of RNNs, achieving linear memory/compute scaling and competing with similarly sized Transformers up to 14B parameters.
Transformers have revolutionized almost all natural language processing (NLP) tasks but suffer from memory and computational complexity that scales quadratically with sequence length. In contrast, recurrent neural networks (RNNs) exhibit linear scaling in memory and computational requirements but struggle to match the same performance as Transformers due to limitations in parallelization and scalability. We propose a novel model architecture, Receptance Weighted Key Value (RWKV), that combines the efficient parallelizable training of transformers with the efficient inference of RNNs. Our approach leverages a linear attention mechanism and allows us to formulate the model as either a Transformer or an RNN, thus parallelizing computations during training and maintains constant computational and memory complexity during inference. We scale our models as large as 14 billion parameters, by far the largest dense RNN ever trained, and find RWKV performs on par with similarly sized Transformers, suggesting future work can leverage this architecture to create more efficient models. This work presents a significant step towards reconciling trade-offs between computational efficiency and model performance in sequence processing tasks.
Motivation & Objective
- Address the memory and quadratic-complexity bottlenecks of self-attention in Transformers for long sequences.
- Propose a model that can be trained like a Transformer but inferred like an RNN, with linear scaling in both time and space.
- Show that RWKV can scale to billions of parameters and perform competitively with transformer baselines on standard NLP benchmarks.
- Provide pretrained RWKV models and demonstrate the practical benefits for large-scale sequence modeling.
Proposed method
- Introduce the Receptance Weighted Key Value (RWKV) architecture combining time-mixing and channel-mixing blocks.
- Replace traditional dot-product attention with a linear-time WKV operator that decays over time per channel.
- Use token shift and time-dependent softmax to stabilize gradients and enable deep stacking with layer normalization.
- Allow Transformer-like training via time-parallel mode while enabling RNN-like autoregressive inference.
- Apply custom kernels and initialization strategies to improve efficiency and convergence on large models.

Experimental results
Research questions
- RQ1Can RWKV achieve the training parallelism of Transformers while maintaining the linear inference cost of RNNs?
- RQ2How does RWKV scale and perform compared with quadratic-transformer architectures at similar compute budgets?
- RQ3What is the impact of long-context processing and context length on RWKV's performance and efficiency?
- RQ4What optimizations and initialization strategies are effective for training very large RWKV models on large corpora?
Key findings
- RWKV models up to 14B parameters are trainable and achieve competitive performance to similarly sized Transformers.
- RWKV exhibits linear inference cost with respect to sequence length, contrasting with Transformer’s quadratic scaling.
- RWKV follows a scaling form similar to Transformers, with strong fits to loss versus compute across model sizes.
- Increasing context length during finetuning reduces test loss, indicating effective use of long contextual information.
- RWKV shows competitive zero-shot results on standard NLP benchmarks and favorable text-generation speed/memory profiles on CPU/GPU inference.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.