# Repository Briefing: BlinkDL/ChatRWKV
> Source: https://repoforai.com/repo/BlinkDL/ChatRWKV (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/BlinkDL/ChatRWKV
- **Category**: Chat UI & AI Apps (聊天界面与 AI 应用)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: B (56/100 · Maintenance 12/35 · Adoption 18/25 · Releases 6/20 · License 20/20)
- **Review Snapshot**: 2026-12-01
- **Deployment / Stack Signals**: Local AI, CLI, GPU, API
- **Momentum**: 9,476 ★ total (+0 24h / +2 7d) · 684 forks
- **Topics**: `chatbot`, `chatgpt`, `language-model`, `pytorch`, `rnn`, `rwkv`
- **When to Use**: Best for: Running RWKV chat locally, inspecting recurrent inference, or prototyping Python integrations with control over weights and device placement. Skip if: You need a turnkey hosted chat product, a ready-to-operate HTTP service, or a deployment path that avoids managing checkpoints and runtime compatibility.

## Overview
```text
### Architecture & Core Mechanics
ChatRWKV is a Python local chat application and inference reference built around the RWKV recurrent language model. Its root chat.py uses src/model_run.py; v2/chat.py provides the strategy-oriented CLI path. Text is tokenized before inference, and generation advances token by token by updating recurrent state rather than appending a Transformer KV cache for every decoded token.

The runtime stack is Python and PyTorch. The supplied requirements.txt lists tokenizers>=0.13.2 and prompt_toolkit but does not pin a PyTorch build. API_DEMO.py, API_DEMO_CHAT.py, and API_DEMO_WORLD.py are Python integration examples, not a documented HTTP protocol or plugin system. Training and fine-tuning are handled in the separate RWKV-LM project.

### Key Capabilities & Differentiators
The v2 runtime provides stream and split strategies and INT8 inference. v2/convert_model.py prepares a checkpoint for a selected strategy ahead of time to reduce loading work and CPU memory pressure. RWKV_CUDA_ON enables a locally built CUDA kernel, and RWKV_v6_demo_cuda_bf16.py gives a separate example of a v6 CUDA BF16 path. These are options to validate against the chosen checkpoint and machine, not guarantees that every configuration will fit.

API_DEMO_WORLD.py and v2/benchmark_more.py cover World and Raven Q&A respectively. Standalone v5 and v6 demos make the inference code easier to inspect; RWKV-7 code, preview weights, and GGUF builds are linked externally. A link to a weight format is not evidence that the bundled CLI can load it directly or that checkpoints and tokenizers are interchangeable.

### Trade-offs & Limitations
Compared with hosted ChatGPT, ChatRWKV lets you run inference on hardware you control, choose the checkpoint, and modify generation code without a hosted model endpoint. In return, you own dependency setup, hardware sizing, and any service layer. Recurrent decoding avoids a growing KV cache, but weights and temporary buffers still need memory; concurrent sessions add state. Long-context answer quality and end-to-end latency should be measured on the intended workload, not inferred from the state representation.

Use the Python CLI when code visibility matters; evaluate a separate runtime such as rwkv.cpp when packaging or quantized CPU deployment is the stronger constraint. Apache-2.0 applies to the repository code. Review checkpoint terms independently, especially if you intend to bundle or redistribute the weights.

### Hardware & Deployment Guide
For a local setup, choose a checkpoint and matching tokenizer, install the Python dependencies and a suitable PyTorch build, and start with v2/chat.py. The separately published rwkv package is another integration path. Once the dependencies and weights are in place, the local CLI does not need a hosted model endpoint. No container recipe or ready-to-run HTTP service is supplied here; use the Python demos as an integration starting point or evaluate the separate Vulkan server.

For the optional CUDA kernel, install Ninja. The Linux setup exposes the CUDA bin and lib64 directories through PATH and LD_LIBRARY_PATH. The Windows recipe uses VS2022 Desktop C++ build tools, CUDA 11.7 with VC++ extensions, and the x64 native tools prompt; treat it as a specific build recipe, not a general compatibility matrix. There is no listed GitHub release, and RWKV-7 preview artifacts are linked separately rather than shipped as a ChatRWKV release.
```

## Key Capabilities
```text
- Architecture: RWKV generation carries recurrent state forward rather than extending a Transformer KV cache at each decoding step.
- Code paths: chat.py calls src/model_run.py; v2/chat.py and API_DEMO_CHAT.py provide separate CLI and Python starting points.
- Memory controls: v2 exposes stream, split, and INT8 options; v2/convert_model.py prepares weights for a selected strategy.
- GPU path: RWKV_CUDA_ON triggers a local CUDA kernel build with Ninja; RWKV_v6_demo_cuda_bf16.py is a separate CUDA BF16 example.
- Model ecosystem: World and Raven have dedicated examples; RWKV-7 preview weights and code are linked externally.
- Service boundary: The Python API demos are in-tree; the linked Vulkan inference server, Gradio demos, and mobile app are separate projects.
```

## Quick Start / Clone
```bash
os.environ["RWKV_JIT_ON"] = '1'
os.environ["RWKV_CUDA_ON"] = '0' # if '1' then use CUDA kernel for seq mode (much faster)
from rwkv.model import RWKV                         # pip install rwkv
model = RWKV(model='/fsx/BlinkDL/HF-MODEL/rwkv-4-pile-1b5/RWKV-4-Pile-1B5-20220903-8040', strategy='cuda fp16')

out, state = model.forward([187, 510, 1563, 310, 247], None)   # use 20B_tokenizer.json
print(out.detach().cpu().numpy())                   # get logits
out, state = model.forward([187, 510], None)
out, state = model.forward([1563], state)           # RNN has state (use deepcopy if you want to clone it)
out, state = model.forward([310, 247], state)
print(out.detach().cpu().numpy())                   # same result as above
```
