LlamaPi 初步试用 RWKV, Ollama
Ping Zhou, 2025-06-21
最近RWKV有不少进展,RWKV-7出了思考模型 rwkv-7-world-g1
,RWKV-8也即将发布。
RWKV的模型架构,在计算量和内存上相比Transformer有很大的优势,对于LlamaPi这种在边缘设备上运行的应用很有吸引力。因此尝试在LlamaPi上适配RWKV,看看效果如何。
目前初步尝试,总的来说不太成功,可能是使用方法或适配上还有些问题,模型始终不能很好的遵循系统指令,生成符合要求的响应。
llama.cpp运行
按照文档步骤:
- 编译最新的llama.cpp
- 下载
rwkv7-g1-1.5b-20250429-ctx4096
,转换成gguf,Q80量化
用 llama-cli
命令行运行,提示词参考LlamaPi:
./build/bin/llama-cli -m models/rwkv7-g1-1.5b-20250429-ctx4096-Q8_0.gguf -p "Your name is Skyler. You are a helpful assistant.\n\n" -cnv -t 4 -ngl 99 -n 500
启动后本来应该就进入对话的,但它先进入了自嗨模式,输出了一大通不相关的东西,然后才停下进入提示符。这可能还是因为我设了n=500的参数,否则不知道它什么时候会停下:

然后检查一下提示词的有效性,结果是完全没用:
> hello, what's your name? My name is [My name] > who are you? My name is [My name] >
命令行不行,那试试Web界面?
/build/bin/llama-server -m models/rwkv7-g1-1.5b-20250429-ctx4096-Q8_0.gguf
先设置一下系统提示:

试一下,这次系统提示词似乎有效了。

试试LlamaPi的完整提示词:

复杂一点的提示词,就不行了,不能按照要求输出。

Ollama运行
Ollama可以运行在Raspberry Pi上,最新版的Ollama也支持RWKV,并且Ollama服务器兼容OpenAI API,理论上可以直接用作LlamaPi的后端。
ollama run mollysama/rwkv-7-g1:2.9b
设置系统提示:
>>> /set system """ ... You are Skyler, a friendly AI assistant. Keep your response in 50 words using spoken language. ... Keep your response short in 50 words using spoken language. ... At the end of your answer, always append a command according these rules: ... - If the user says hello, append a command "$greet". ... - If the user sounds happen, append command "$smile". ... - If the user requests to retrieve or hand over something, append command "$retrieve". ... - In all other cases or if you are unsure, append command "$idle". ... ... """ Set system message.
然后输入hello,模型就陷入了反复thinking的循环,直到我Ctrl-C中断。

用 /set nothink
关闭思考模式,不会陷入循环了,但是输出也没有按照提示词的要求:
>>> hello <answer> Hello! How can I assist you today? </answer>
下一步
目前RWKV输出不符合要求,可能是使用或适配上还有些问题,需要进一步研究。这些问题解决后,才能接入LlamaPi并跑在树莓派上。