RWKV Runner
本项目旨在消除使用大语言模型的门槛,为用户自动化一切。你只需要一个几兆大小的轻量级可执行程序。此外,本项目提供了兼容 OpenAI API 的接口,这意味着每一个 ChatGPT 客户端都可以成为 RWKV 客户端。
[![license][license-image]][license-url]
[![release][release-image]][release-url]
[![py-version][py-version-image]][py-version-url]
[English](README.md) | 简体中文 | [日本語](README_JA.md)
### 安装
[![Windows][Windows-image]][Windows-url]
[![MacOS][MacOS-image]][MacOS-url]
[![Linux][Linux-image]][Linux-url]
[常见问题](https://github.com/josStorer/RWKV-Runner/wiki/FAQs) | [预览](#预览) | [下载][download-url] | [简易部署示例](#简易部署示例) | [服务器部署示例](https://github.com/josStorer/RWKV-Runner/tree/master/deploy-examples) | [MIDI 硬件输入](#MIDI-输入)
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg
[license-url]: https://github.com/josStorer/RWKV-Runner/blob/master/LICENSE
[release-image]: https://img.shields.io/github/release/josStorer/RWKV-Runner.svg
[release-url]: https://github.com/josStorer/RWKV-Runner/releases/latest
[py-version-image]: https://img.shields.io/pypi/pyversions/fastapi.svg
[py-version-url]: https://github.com/josStorer/RWKV-Runner/tree/master/backend-python
[download-url]: https://github.com/josStorer/RWKV-Runner/releases
[Windows-image]: https://img.shields.io/badge/-Windows-blue?logo=windows
[Windows-url]: https://github.com/josStorer/RWKV-Runner/blob/master/build/windows/Readme_Install.txt
[MacOS-image]: https://img.shields.io/badge/-MacOS-black?logo=apple
[MacOS-url]: https://github.com/josStorer/RWKV-Runner/blob/master/build/darwin/Readme_Install.txt
[Linux-image]: https://img.shields.io/badge/-Linux-black?logo=linux
[Linux-url]: https://github.com/josStorer/RWKV-Runner/blob/master/build/linux/Readme_Install.txt
提示
-
你可以将 backend-python 部署在服务器上,然后仅将此程序作为客户端使用。在设置页面的 API URL 中填入你的服务器地址即可。
-
如果你要部署并提供公共服务,请通过 API 网关限制请求大小,以防止提交过长的提示导致资源过度消耗。此外,请根据实际情况限制请求 max_tokens 的上限:https://github.com/josStorer/RWKV-Runner/blob/master/backend-python/utils/rwkv.py#L567 ,默认设置为 le=102400,在极端情况下可能导致单次响应消耗大量资源。
-
默认配置已启用自定义 CUDA 内核加速,速度更快且显存占用更低。如果你遇到可能的兼容性问题(输出乱码),请前往配置页面关闭 使用自定义 CUDA 内核加速,或尝试升级显卡驱动。
-
如果 Windows Defender 声称这是病毒,你可以尝试下载 v1.3.7_win.zip 并让它自动更新到最新版本,或将其加入信任列表(Windows 安全中心 -> 病毒和威胁防护 -> 管理设置 -> 排除项 -> 添加或删除排除项 -> 添加排除项 -> 文件夹 -> RWKV-Runner)。
-
对于不同任务,调整 API 参数可以获得更好的效果。例如,对于翻译任务,可以尝试将 Temperature 设为 1,Top_P 设为 0.3。
功能特性
- RWKV 模型管理与一键启动。
- 前后端分离,如果你不想使用客户端,也可以单独部署前端服务、后端推理服务,或带 WebUI 的后端推理服务。
简易部署示例 | 服务器部署示例
- 兼容 OpenAI API,让每一个 ChatGPT 客户端都成为 RWKV 客户端。启动模型后,打开 http://127.0.0.1:8000/docs 查看更多详情。
- 自动安装依赖,仅需一个轻量级可执行程序。
- 预设多级显存配置,几乎可在所有电脑上良好运行。在配置页面将 Strategy 切换为 WebGPU,还可以在 AMD、Intel 及其他显卡上运行。
- 内置用户友好的聊天、补全与作曲交互界面。同时支持聊天预设、附件上传、MIDI 硬件输入与音轨编辑。
预览 | MIDI 硬件输入
- 内置 WebUI 选项,一键启动 Web 服务,共享你的硬件资源。
- 易于理解和操作的参数配置,以及各种操作引导提示。
- 内置模型转换工具。
- 内置下载管理与远程模型检测。
- 内置一键 LoRA 微调。(仅限 Windows)
- 也可用作 OpenAI ChatGPT、GPT-Playground、Ollama、llmman 等客户端。(在设置页面填入 API URL 和 API Key)
- 多语言本地化。
- 主题切换。
- 自动更新。
简易部署示例
git clone https://github.com/josStorer/RWKV-Runner
# 然后
cd RWKV-Runner
python ./backend-python/main.py # 后端推理服务已启动,请求 /switch-model API 加载模型,参考 API 文档:http://127.0.0.1:8000/docs
# 或
cd RWKV-Runner/frontend
npm ci
npm run build # 编译前端
cd ..
python ./backend-python/webui_server.py # 单独启动前端服务
# 或
python ./backend-python/main.py --webui # 同时启动前端和后端服务
# 帮助信息
python ./backend-python/main.py -h
API 并发压力测试
ab -p body.json -T application/json -c 20 -n 100 -l http://127.0.0.1:8000/chat/completions
body.json:
{
"messages": [
{
"role": "user",
"content": "Hello"
}
]
}
Embeddings API 示例
注意:v1.4.0 改进了 embeddings API 的质量。生成的结果与之前版本不兼容。如果你正在使用 embeddings API 生成知识库或类似内容,请重新生成。
如果你使用 langchain,只需使用 OpenAIEmbeddings(openai_api_base="http://127.0.0.1:8000", openai_api_key="sk-")
import numpy as np
import requests
def cosine_similarity(a, b):
return np.dot(a, b) / (np.linalg.norm(a) * np.linalg.norm(b))
values = [
"I am a girl",
"我是个女孩",
"私は女の子です",
"广东人爱吃福建人",
"我是个人类",
"I am a human",
"that dog is so cute",
"私はねこむすめです、にゃん♪",
"宇宙级特大事件!号外号外!"
]
embeddings = []
for v in values:
r = requests.post("http://127.0.0.1:8000/embeddings", json={"input": v})
embedding = r.json()["data"][0]["embedding"]
embeddings.append(embedding)
compared_embedding = embeddings[0]
embeddings_cos_sim = [cosine_similarity(compared_embedding, e) for e in embeddings]
for i in np.argsort(embeddings_cos_sim)[::-1]:
print(f"{embeddings_cos_sim[i]:.10f} - {values[i]}")
MIDI 输入
提示:你可以下载 https://github.com/josStorer/sgm_plus 并解压到程序的 assets/sound-font 目录,将其用作离线音源。请注意,如果你是从源代码编译程序,请不要将其放在源代码目录中。
如果你没有 MIDI 键盘,可以使用 Virtual Midi Controller 3 LE 等虚拟 MIDI 输入软件,配合 loopMIDI,将普通电脑键盘用作 MIDI 输入。
USB MIDI 连接
- USB MIDI 设备即插即用,你可以在作曲页面选择输入设备

Mac MIDI 蓝牙连接
Windows MIDI 蓝牙连接
- Windows 似乎仅对 UWP(通用 Windows 平台)应用实现了蓝牙 MIDI 支持。因此,需要多个步骤来建立连接。我们需要创建一个本地虚拟 MIDI 设备,然后启动一个 UWP 应用。通过这个 UWP 应用,我们将蓝牙 MIDI 输入重定向到虚拟 MIDI 设备,然后本软件将监听来自虚拟 MIDI 设备的输入。
- 因此,首先你需要下载 loopMIDI 来创建虚拟 MIDI 设备。点击左下角的加号创建设备。

- 接下来,你需要下载 Bluetooth LE Explorer 来发现并连接蓝牙 MIDI 设备。点击 "Start" 搜索设备,然后点击 "Pair" 绑定 MIDI 设备。

- 最后,你需要安装 MIDIberry,这个 UWP 应用可以将蓝牙 MIDI 输入重定向到虚拟 MIDI 设备。启动后,在输入字段中双击你实际的蓝牙 MIDI 设备名称,在输出字段中双击我们之前创建的虚拟 MIDI 设备名称。

- 现在,你可以在作曲页面选择虚拟 MIDI 设备作为输入。Bluetooth LE Explorer 不再需要运行,你也可以关闭 loopMIDI 窗口,它会在后台自动运行。只需保持 MIDIberry 打开即可。

相关仓库:
- RWKV-5-World: https://huggingface.co/BlinkDL/rwkv-5-world/tree/main
- RWKV-4-World: https://huggingface.co/BlinkDL/rwkv-4-world/tree/main
- RWKV-4-Raven: https://huggingface.co/BlinkDL/rwkv-4-raven/tree/main
- ChatRWKV: https://github.com/BlinkDL/ChatRWKV
- RWKV-LM: https://github.com/BlinkDL/RWKV-LM
- RWKV-LM-LoRA: https://github.com/Blealtan/RWKV-LM-LoRA
- RWKV-v5-lora: https://github.com/JL-er/RWKV-v5-lora
- MIDI-LLM-tokenizer: https://github.com/briansemrau/MIDI-LLM-tokenizer
- ai00_rwkv_server: https://github.com/cgisky1980/ai00_rwkv_server
- rwkv.cpp: https://github.com/saharNooby/rwkv.cpp
- web-rwkv-py: https://github.com/cryscan/web-rwkv-py
- web-rwkv: https://github.com/cryscan/web-rwkv
预览
主页

聊天


补全

作曲
提示:你可以下载 https://github.com/josStorer/sgm_plus 并解压到程序的 assets/sound-font 目录,将其用作离线音源。请注意,如果你是从源代码编译程序,请不要将其放在源代码目录中。


配置

模型管理

下载管理

LoRA 微调

设置
