RWKV-LM is the official codebase for the RWKV language model, hosted on GitHub. RWKV (pronounced RwaKuv) is an RNN with Transformer-level LLM performance that can also be trained directly in parallel like a GPT Transformer. The current version is RWKV-7 "Goose", a linear-time, constant-space (no KV cache), attention-free 100% RNN architecture suitable for large language models and multimodal applications.
Purpose: RWKV-LM is mainly used for training, fine-tuning, and inference of the RWKV series of models, supporting training from scratch, continued pre-training, supervised fine-tuning (SFT), state-tuning, etc.
Main capabilities:
- Combines the advantages of RNN and Transformer: high performance, fast inference, memory savings, fast training, infinite context length, free sentence embeddings (using the final hidden state).
- RWKV-7 has an extremely small state size, suitable for large-batch inference.
- Provides multiple inference modes: GPT mode, RNN mode, and the fastest mode combining both.
- Provides CUDA kernel optimization, supporting efficient training and inference.
- Supports extensions such as PEFT (LoRA, etc.) and RLHF.
- Provides a mobile inference library, WebGPU demo, Gradio demo, etc.
- Provides data preparation tools (jsonl to binidx), tokenizer tools, training scripts, etc.
Usage:
- Training: Refer to the reference implementation in RWKV-v7/train_temp; the default configuration only needs a single GPU with 7G of VRAM to test. Before training, prepare data (you can use make_data.py to convert jsonl to binidx) and set the relevant parameters (such as --my_exit_tokens, --magic_prime).
- Inference: You can use the rwkv pip package, the Albatross efficient inference library, the RWKV-Runner GUI, Ai00 Server, etc.
- Fine-tuning: Supports SFT, state-tuning, etc.; you need to prepare data in jsonl format and use the corresponding scripts and parameters.
- Demos: Provides multiple Gradio Demos, WebGPU Demos, and example code in ChatRWKV.
Applicable scenarios:
- For applications requiring long context, low VRAM usage, and fast inference, LLM applications.
- Multimodal applications (such as Vision-RWKV, Diffusion-RWKV).
- Mobile/edge device inference (rwkv-mobile).
- Academic research and model architecture exploration.
Limitations:
- The RWKV-7 reference implementation contains a large number of carefully tuned hyperparameters such as initialization, weight decay, and learning rate; there is no simple "RWKV-7 layer" that can be reused directly, so you need to study the train_temp code and adapt it.
- FLA RWKV-7 has not yet been aligned with the reference implementation and performs poorly.
- Training requires some GPU resources, although the minimum configuration requirement is low.
- Some links and tools may depend on community maintenance, and stability must be assessed on your own.
- Some content in the official documentation (such as the wiki) was written by AI and may contain errors.