ARWKV R1 7B
基于纯RNN的70亿参数模型,通过知识蒸馏训练,展示RWKV-7的高效循环机制和无自注意力架构。
下载量 113
发布时间 : 2/7/2025
模型简介
ARWKV-R1-7B是一个基于RWKV-7时间混合与Transformer MLP的混合架构模型,专注于文本生成任务,具有高效循环机制和恒定显存占用。
模型特点
高效循环机制
采用RWKV-7的高效循环机制,无自注意力,完全O(n)复杂度。
恒定显存占用
模型在推理过程中保持恒定显存占用,适合单GPU训练和推理。
知识蒸馏训练
通过从DeepSeek-R1-Distill-Qwen-1.5B进行三阶段知识蒸馏训练。
混合架构
结合RWKV-7时间混合与Transformer MLP的优势,提升模型性能。
模型能力
文本生成
问答系统
知识蒸馏
使用案例
问答系统
世界级问答AI
提供准确、简洁的回答,适用于各种问答场景。
在MMLU基准测试中达到67.25分。
数学推理
数学问题解答
能够解答基础的数学问题,适用于教育场景。
在GSM8K基准测试中达到56.06分。
🚀 ARWKV🪿
ARWKV是一个基于纯RNN的模型,结合了RWKV-7的时间混合机制和Transformer的MLP,具有高效的循环机制、无需自注意力机制、恒定的显存使用和单GPU可训练性等特点。本项目还提供了在AMD Radeon GPU上的推理方法,以及模型的使用示例和性能基准测试。
🚀 快速开始
环境准备
在AMD Radeon GPU上使用llama.cpp
进行推理,可按以下步骤操作:
git clone https://github.com/MollySophia/llama.cpp.git -b rwkv-v7
cd llama.cpp
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \
cmake -S . -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=gfx1030 -DCMAKE_BUILD_TYPE=Release \
&& cmake --build build --config Release -- -j 16
cd ./build/bin
模型转换
将safetensor
模型转换为gguf
格式:
python ./convert_hf_to_gguf.py [model_dir]
模型量化
对模型进行量化:
./llama-quantize [model_dir] [Quantization accuracy]
在Webui中推理
使用llama-server
在Webui中推理模型:
/llama-server -m [model_dir] -t [use_cpu_thread_number] -ngl 99 --host [host_number] --port [port_number]
注意:Radeon 7000
系列使用gfx1100
,Radeon 6000
系列使用gfx1030
。
在Nvidia GPU上推理
git clone https://github.com/MollySophia/llama.cpp.git -b rwkv-v7
cd llama.cpp
cmake -B build -DGGML_CUDA=ON
cmake --build build --config Release
cd ./build/bin
模型转换
python ./convert_hf_to_gguf.py [model_dir]
模型量化
./llama-quantize [model_dir] [Quantization_accuracy]
在Webui中推理
/llama-server -m [model_dir] -t [use_cpu_thread_number] -ngl 99 --host [host_number] --port [port_number]
✨ 主要特性
模型特性
- 高效循环机制:采用RWKV-7的高效循环机制。
- 无自注意力机制:完全O(n)复杂度,无需自注意力机制。
- 恒定显存使用:显存使用恒定,可在单GPU上训练。
未来规划
- 长上下文能力:即将开源支持16k+上下文的增强版本。
- 数学能力提升:针对数学问题进行特定改进。
- 强化推理模型:通过强化学习提升推理能力。
📦 安装指南
pip3 install --upgrade transformers rwkv-fla
训练前需设置环境变量:
export WKV_MODE=chunk
💻 使用示例
基础用法
from transformers import AutoModelForCausalLM, AutoTokenizer
import threading
model = AutoModelForCausalLM.from_pretrained(
"RWKV-Red-Team/ARWKV-R1-7B",
device_map="auto",
torch_dtype=torch.float16,
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(
"RWKV-Red-Team/ARWKV-R1-7B"
)
system_prompt = "You are a world class trivia AI - provide accurate, succinct responses. "
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": prompt}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
text = text + "<think>"
print(text)
model_inputs = tokenizer([text], return_tensors="pt").to(device)
streamer = TextIteratorStreamer(tokenizer, skip_prompt=False, skip_special_tokens=False)
generation_kwargs = dict(model_inputs, streamer=streamer, max_new_tokens=8192, do_sample=True,tokenizer=tokenizer,stop_strings=["<|end▁of▁sentence|>"])
thread = threading.Thread(target=model.generate, kwargs=generation_kwargs)
thread.start()
print("Streaming output:")
for new_text in streamer:
print(new_text, end="", flush=True)
thread.join()
输出示例
<|begin▁of▁sentence|>You are a world class trivia AI - provide accurate, succinct responses. <|User|>The world's largest rainforest, home to approximately three million species of plants and animals, is named after which river?<|Assistant|><think>
Okay, so I'm trying to solve this question about the world's largest rainforest and which river it's named after. Hmm, first, I think rainforest names often have links related to the region it's in. The most famous rainforest in the world is the Amazon. I remember hearing a lot about it being called that because rainforests are connected to specific river systems.
Now, I'm trying to recall which river is named after the Amazon. I think it's the Amazon River. But I want to be sure. Let me see... the Amazon is a major rainforest located in South America. The Amazon River flows through it, which is why it's named after it. That makes sense because it's a very important river. I recall reading somewhere that all the rainforests are named after rivers related to their regions. So if the Amazon is named after its River, then the name would naturally be related to its source.
I wonder if it's the Amazon itself that's named after it, or another river named after it. But the official name for the Amazon is the Amazon Rainforest. The most significant rainforest in the world is the Amazon, and its name probably started with river-sounding names.
</think>
The largest rainforest located in South America is the Amazon. It is named after the river named after it, which is the Amazon River. Therefore, the Amazon River is the name given to the Amazon Rain Forest.
📚 详细文档
性能基准测试
Qwen2.5-7B-Instruct | ARWKV_7B | ARWKV_R1_7B | |
---|---|---|---|
MMLU | 71.72 |
62.41 |
67.25 ↗️ |
GSM8K | 82.34 |
39.95 |
56.06 ↗️ |
WinoGrande | 71.35 |
68.67 |
51.93 ↘️ |
IfEval | 73.62 |
52.16 |
60.31 ↗️ |
Arc-c | 54.86 |
52.22 |
44.11 ↘️ |
关键特性
属性 | 详情 | 备注 |
---|---|---|
架构 | RWKV-7 TimeMix + SwiGLU | 混合设计 |
上下文窗口 | 2048训练上下文 | 预览版限制 |
训练数据 | 40M | 专注于知识蒸馏 |
精度 | 推荐FP16推理(需要16G显存) | 比BF16高15% |
架构亮点
核心修改流程
Transformer Decoder Layer:
- Multi-head Latent Attention(MLA)
+ RWKV-7 Time Mixing (Eq.3)
- RoPE Positional Encoding
+ State Recurrence
= Hybrid Layer Output
📄 许可证
本项目采用Apache-2.0
许可证。
Phi 2 GGUF
其他
Phi-2是微软开发的一个小型但强大的语言模型,具有27亿参数,专注于高效推理和高质量文本生成。
大型语言模型 支持多种语言
P
TheBloke
41.5M
205
Roberta Large
MIT
基于掩码语言建模目标预训练的大型英语语言模型,采用改进的BERT训练方法
大型语言模型 英语
R
FacebookAI
19.4M
212
Distilbert Base Uncased
Apache-2.0
DistilBERT是BERT基础模型的蒸馏版本,在保持相近性能的同时更轻量高效,适用于序列分类、标记分类等自然语言处理任务。
大型语言模型 英语
D
distilbert
11.1M
669
Llama 3.1 8B Instruct GGUF
Meta Llama 3.1 8B Instruct 是一个多语言大语言模型,针对多语言对话用例进行了优化,在常见的行业基准测试中表现优异。
大型语言模型 英语
L
modularai
9.7M
4
Xlm Roberta Base
MIT
XLM-RoBERTa是基于100种语言的2.5TB过滤CommonCrawl数据预训练的多语言模型,采用掩码语言建模目标进行训练。
大型语言模型 支持多种语言
X
FacebookAI
9.6M
664
Roberta Base
MIT
基于Transformer架构的英语预训练模型,通过掩码语言建模目标在海量文本上训练,支持文本特征提取和下游任务微调
大型语言模型 英语
R
FacebookAI
9.3M
488
Opt 125m
其他
OPT是由Meta AI发布的开放预训练Transformer语言模型套件,参数量从1.25亿到1750亿,旨在对标GPT-3系列性能,同时促进大规模语言模型的开放研究。
大型语言模型 英语
O
facebook
6.3M
198
1
基于transformers库的预训练模型,适用于多种NLP任务
大型语言模型
Transformers

1
unslothai
6.2M
1
Llama 3.1 8B Instruct
Llama 3.1是Meta推出的多语言大语言模型系列,包含8B、70B和405B参数规模,支持8种语言和代码生成,优化了多语言对话场景。
大型语言模型
Transformers 支持多种语言

L
meta-llama
5.7M
3,898
T5 Base
Apache-2.0
T5基础版是由Google开发的文本到文本转换Transformer模型,参数规模2.2亿,支持多语言NLP任务。
大型语言模型 支持多种语言
T
google-t5
5.4M
702
精选推荐AI模型
Llama 3 Typhoon V1.5x 8b Instruct
专为泰语设计的80亿参数指令模型,性能媲美GPT-3.5-turbo,优化了应用场景、检索增强生成、受限生成和推理任务
大型语言模型
Transformers 支持多种语言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一个基于SODA数据集训练的超小型对话模型,专为边缘设备推理设计,体积仅为Cosmo-3B模型的2%左右。
对话系统
Transformers 英语

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基于RoBERTa架构的中文抽取式问答模型,适用于从给定文本中提取答案的任务。
问答系统 中文
R
uer
2,694
98
智启未来,您的人工智能解决方案智库
简体中文