ChatRWKV

BlinkDLApache-2.0活跃维护

用纯 RNN 架构的 RWKV 语言模型驱动的开源聊天机器人,效果对标 ChatGPT,可在本地部署运行。

ChatRWKV is like ChatGPT but powered by RWKV (100% RNN) language model, and open source.

暂无版本9,486star685fork同步于 2026-11-10 17:31 UTC

怎么上手

由 README 提炼,执行前请确认
pip install rwkv
python v2/chat.py
硬件要求按 README 说明

README 提到 v2 的 stream/split 策略加 INT8 时 3G 显存即可跑 RWKV 14B;CUDA kernel 需 NVIDIA CUDA 环境(Linux 或 Windows+VS2022);CPU 推理可借助社区 rwkv.cpp 项目,README 未给出具体 CPU 内存要求。

需要 CUDA支持 ROCm / AMD
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用纯 RNN 架构 RWKV 跑类 ChatGPT 对话的开源项目,比 Transformer 更快更省显存

用纯 RNN 架构的 RWKV 语言模型驱动的开源聊天机器人,效果对标 ChatGPT,可在本地部署运行。

核心能力

  • 提供 stream 与 split 策略及 INT8 量化推理
  • 3G 显存即可运行 RWKV 14B 模型
  • 可选编译 CUDA kernel 加速并省显存
  • 附带 150 行与 250 行的极简推理实现参考
  • 支持多轮对话状态复用,避免重复计算

容易踩的坑

需自行从 HuggingFace 下载模型权重,仓库不含模型文件;rwkv pip 包需始终检查并升级到最新版本;启用 RWKV_CUDA_ON 前要先 pip install ninja 并配好 CUDA 环境变量;对话文本须严格遵循 Bob/Alice 或 User/Assistant 格式且结尾不留空格。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

0 个版本

暂无 release 数据(可能没有发版,或尚未同步)。

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    ChatRWKV (pronounced as "RwaKuv" (rʌkuv in IPA), from 4 major params: R W K V)

    RWKV homepage: https://www.rwkv.com

    RWKV-7 code: https://github.com/BlinkDL/RWKV-LM/tree/main/RWKV-v7

    ChatRWKV is like ChatGPT but powered by my RWKV (100% RNN) language model, which is the only RNN (as of now) that can match transformers in quality and scaling, while being faster and saves VRAM.

    Our latest version is RWKV-7 https://arxiv.org/abs/2503.14456 (Preview models: https://huggingface.co/BlinkDL/temp )

    Gradio Demo 1: https://huggingface.co/spaces/BlinkDL/RWKV-Gradio-1

    Gradio Demo 2: https://huggingface.co/spaces/BlinkDL/RWKV-Gradio-2

    RWKV-LM main repo: https://github.com/BlinkDL/RWKV-LM (explanation, fine-tuning, training, etc.)

    Chat Demo for developers: https://github.com/BlinkDL/ChatRWKV/blob/main/API_DEMO_CHAT.py

    Efficient inference project: https://github.com/BlinkDL/Albatross

    RWKV APP: https://github.com/RWKV-APP/RWKV_APP (local inference for Android / iOS)

    RWKV Discord: https://discord.gg/bDSBUMeFpc (7k+ members)

    Twitter: https://twitter.com/BlinkDL_AI

    Homepage: https://www.rwkv.com/

    Raw cutting-edge RWKV weights: https://huggingface.co/BlinkDL

    GGUF: https://huggingface.co/collections/shoumenchougou/rwkv7-gxx-gguf

    HF-compatible RWKV weights: https://huggingface.co/RWKV

    Use v2/convert_model.py to convert a model for a strategy, for faster loading & saves CPU RAM.

    Note RWKV_CUDA_ON will build a CUDA kernel (much faster & saves VRAM). Here is how to build it ("pip install ninja" first):

    # How to build in Linux: set these and run v2/chat.py
    export PATH=/usr/local/cuda/bin:$PATH
    export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
    # How to build in win:
    Install VS2022 build tools (https://aka.ms/vs/17/release/vs_BuildTools.exe select Desktop C++). Reinstall CUDA 11.7 (install VC++ extensions). Run v2/chat.py in "x64 native tools command prompt". 
    

    RWKV pip package: https://pypi.org/project/rwkv/ (please always check for latest version and upgrade)

    https://github.com/cgisky1980/ai00_rwkv_server Fastest GPU inference API with vulkan (good for nvidia/amd/intel)

    https://github.com/cryscan/web-rwkv backend for ai00_rwkv_server

    https://github.com/saharNooby/rwkv.cpp Fast CPU/cuBLAS/CLBlast inference: int4/int8/fp16/fp32

    https://github.com/JL-er/RWKV-PEFT lora/pissa/Qlora/Qpissa/state tuning

    https://github.com/RWKV/RWKV-infctx-trainer Infctx trainer

    World demo script: https://github.com/BlinkDL/ChatRWKV/blob/main/API_DEMO_WORLD.py

    Raven Q&A demo script: https://github.com/BlinkDL/ChatRWKV/blob/main/v2/benchmark_more.py

    ChatRWKV-strategy

    RWKV in 150 lines (model, inference, text generation): https://github.com/BlinkDL/ChatRWKV/blob/main/RWKV_in_150_lines.py

    🔥 RWKV v5 in 250 lines 🔥 (with tokenizer too): https://github.com/BlinkDL/ChatRWKV/blob/main/RWKV_v5_demo.py

    🔥 Building your own RWKV inference engine 🔥: begin with https://github.com/BlinkDL/ChatRWKV/blob/main/src/model_run.py which is easier to understand (used by https://github.com/BlinkDL/ChatRWKV/blob/main/chat.py).

    RWKV preprint https://arxiv.org/abs/2305.13048

    RWKV-paper

    RWKV v6 illustrated:

    RWKV-v6

    Cool Community RWKV Projects:

    https://github.com/saharNooby/rwkv.cpp fast i4 i8 fp16 fp32 CPU inference using ggml

    https://github.com/harrisonvanderbyl/rwkv-cpp-cuda fast windows/linux & cuda/rocm/vulkan GPU inference (no need for python & pytorch)

    https://github.com/Blealtan/RWKV-LM-LoRA LoRA fine-tuning

    https://github.com/josStorer/RWKV-Runner cool GUI

    More RWKV projects: https://github.com/search?o=desc&q=rwkv&s=updated&type=Repositories

    ChatRWKV v2: with "stream" and "split" strategies, and INT8. 3G VRAM is enough to run RWKV 14B :) https://github.com/BlinkDL/ChatRWKV/tree/main/v2

    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
    

    RWKV-eval

    Here is https://huggingface.co/BlinkDL/rwkv-4-raven/blob/main/RWKV-4-Raven-14B-v7-Eng-20230404-ctx4096.pth in action: ChatRWKV

    When you build a RWKV chatbot, always check the text corresponding to the state, in order to prevent bugs.

    1. Never call raw forward() directly. Instead, put it in a function that will record the text corresponding to the state.

    (For v4-raven models, use Bob/Alice. For v4/v5/v6-world models, use User/Assistant)

    1. The best chat format (check whether your text is of this format): Bob: xxxxxxxxxxxxxxxxxx\n\nAlice: xxxxxxxxxxxxx\n\nBob: xxxxxxxxxxxxxxxx\n\nAlice:
    • There should not be any space after the final "Alice:". The generation result will have a space in the beginning, and you can simply strip it.
    • You can use \n in xxxxx, but avoid \n\n. So simply do xxxxx = xxxxx.strip().replace('\r\n','\n').replace('\n\n','\n')

    If you are building your own RWKV inference engine, begin with https://github.com/BlinkDL/ChatRWKV/blob/main/src/model_run.py which is easier to understand (used by https://github.com/BlinkDL/ChatRWKV/blob/main/chat.py)

    The lastest "Raven"-series Alpaca-style-tuned RWKV 14B & 7B models are very good (almost ChatGPT-like, good at multiround chat too). Download: https://huggingface.co/BlinkDL/rwkv-4-raven

    Previous old model results: ChatRWKV ChatRWKV ChatRWKV ChatRWKV ChatRWKV ChatRWKV ChatRWKV

    中文模型

    QQ群 553456870(加入时请简单自我介绍)。有研发能力的朋友加群 325154699。

    中文使用教程:https://zhuanlan.zhihu.com/p/618011122 https://zhuanlan.zhihu.com/p/616351661

    推荐UI:https://github.com/l15y/wenda

    Star History

    Star History Chart