Mini_RWKV_7 is an open-source project for training a small RWKV-V7 language model from scratch, aiming to enable developers to train their own lightweight language models. The Mini in the project name reflects its lightweight nature, with only 34.2M model parameters and a model file size of about 68.4MB.
Purpose
This project's main purpose is to provide a complete, reproducible training pipeline for a small language model, including pretraining, supervised fine-tuning (SFT), and inference. It is suitable for deployment on devices with extremely limited resources and for rapid iterative development, and is also suitable as a teaching project for learning the RWKV architecture and language model training.
Main Capabilities
- Supports three RWKV V7 architecture variants: pure RWKV V7, RWKV V7 with Deep Embedding, and RWKV V7 with Deep Embedding Attention.
- Provides complete training code, including pretraining, SFT training scripts, and datasets.
- Open-sources the pretrained and SFT model weights.
- Provides an online experience via HuggingFace Space, including two versions: pure RWKV V7 and RWKV V7 with Deep Embedding.
- The vocabulary is consistent with MiniMind.
- Supports training on consumer-grade hardware, such as a 4060 laptop GPU, and even a Radeon 780M integrated GPU.
Usage
The project provides multiple bash scripts for the training process:
- demo-training-prepare.sh: model weight initialization.
- demo-training-run.sh: pretraining.
- demo-training-run-sft.sh: supervised fine-tuning training.
The model architecture can be adjusted by modifying MODEL_TYPE="x070" in the script. The training process is divided into multiple stages:
- Pretraining Binidx dataset conversion.
- Stage 1: model weight initialization, generating rwkv-init.pth.
- Stage 2: pretraining, generating rwkv-final.pth.
- Stage 3-5: supervised fine-tuning training, corresponding to context lengths 512, 1024, and 2048 respectively.
Regarding training parameters, pretraining uses LR_INIT=6e-4, LR_FINAL=2e-5; SFT uses LR_INIT=2e-5, LR_FINAL=1e-6. The pretraining loss converges at around 2.12, and the final SFT loss is around 0.5.
For AMD GPU users, the corresponding version of torch needs to be installed, for example: pip3 install torch --index-url https://download.pytorch.org/whl/rocm6.3。
Applicable Scenarios
- Language model deployment in resource-constrained environments.
- Rapid iterative development of small language models.
- Learning the RWKV architecture and language model training process.
- Conducting model training experiments on thin-and-light laptops or consumer-grade GPUs.
Limitations
- The amount of pretraining data is relatively small, so the model's capabilities are limited.
- The project does not provide detailed performance benchmark data.
- No specific commercial use license information is provided.
- The training dataset comes from MiniMind; for the specific data content, refer to the original project.