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, which parallelizes computations during training and maintains constant computational and memory complexity during inference, leading to the first non-transformer architecture to be scaled to tens of billions of parameters. Our experiments reveal that RWKV performs on par with similarly sized Transformers, suggesting that future work can leverage this architecture to create more efficient models. This work presents a significant step towards reconciling the trade-offs between computational efficiency and model performance in sequence processing tasks.
翻译:Transformer几乎革新了所有自然语言处理任务,但其内存和计算复杂度随序列长度呈二次增长。相比之下,循环神经网络在内存和计算需求上呈线性扩展,但由于并行化和可扩展性的限制,难以达到与Transformer同等的性能。我们提出了一种新型模型架构——接受加权键值(RWKV),它结合了Transformer的高效并行训练能力与RNN的高效推理特性。该方法采用线性注意力机制,使我们能够将模型形式化为Transformer或RNN,在训练时实现计算并行化,并在推理时保持恒定的计算和内存复杂度,从而成为首个可扩展至数百亿参数的非Transformer架构。实验表明,RWKV的性能与同等规模的Transformer相当,表明未来研究可借助该架构构建更高效的模型。这项工作在序列处理任务中向平衡计算效率与模型性能迈出了重要一步。