SuperAPIAI Directory

RWKV-LM

github.com · AI developer platforms

RWKV-LM is the official code repository for the RWKV series of language models, with the current version being RWKV-7 "Goose". RWKV is an architecture that combines the advantages of RNNs and Transformers: it can be trained in parallel like a GPT Transformer, while also possessing RNN characteristics such as linear time, constant space (no KV cache required), infinite context length, and free sentence embeddings. The repository provides code for model training, inference, and fine-tuning, as well as CUDA kernels, supports models of various sizes, and includes demo scripts and a toolchain.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsLinux

About this tool

RWKV-LM is the official GitHub repository for the RWKV language model, maintained by BlinkDL. RWKV (pronounced RwaKuv) is an RNN architecture with Transformer-level LLM performance that can be trained in parallel like a GPT Transformer and requires no attention mechanism at all. The current latest version is RWKV-7 "Goose", a linear-time, constant-space (no KV cache), attention-free, 100% RNN architecture suitable for LLMs and multimodal applications. RWKV-7 is a meta-context learner that trains its state at test time via context gradient descent on each token. RWKV is a Linux Foundation AI project and is completely free, and its runtime has been integrated into Windows and Office.

In terms of key capabilities, RWKV-7 has an extremely small state size, making it suitable for large-batch inference. Official data shows that on an RTX5090, the RWKV-7 7.2B fp16 model can reach 145+ tokens/s at bsz1 decoding and 10250+ tokens/s at bsz960, with constant speed and VRAM usage. For training, RWKV-7 7.2B bf16 trained on 4x8xH100 (ctx57344, DeepSpeed zero2+gradcp) can reach 305k tokens/s with an MFU of 41.6%. The repository provides a reference implementation (train_temp), and the default configuration only requires a single GPU with 7G of VRAM for testing.

In terms of usage, the repository includes several demo scripts: rwkv_v7_demo.py (GPT mode), rwkv_v7_demo_rnn.py (RNN mode), and rwkv_v7_demo_fast.py (both modes, fastest). For training, refer to the train_temp directory, which supports training on the MiniPile (1.5G tokens) or Pile (332G tokens) datasets. Fine-tuning supports SFT, State-tuning, and other methods, and provides data preparation tools such as make_data.py. For inference, you can use the rwkv pip package, the Albatross efficient inference library, the RWKV-Runner GUI, the Ai00 Server, and others. The mobile inference library is rwkv-mobile.

Applicable scenarios include: language model applications requiring infinite context length, large-batch high-throughput inference, deployment in resource-constrained environments (due to constant VRAM usage), multimodal applications, and academic work researching hybrid RNN and Transformer architectures. In terms of limitations, the FLA implementation of RWKV-7 has not yet been aligned with the reference implementation and has poor performance; there is no simple "RWKV-7 layer" that can be directly reused, and the train_temp code (several hundred lines) must be studied for adaptation; for training, note that weight decay should only be applied to large matrix parameters, and correct initialization and PreLN LayerNorm should be used.

Up/Down to navigate · Enter to open · ESC to closeBrowse all tools