ARWKV R1 1B5
ARWKV-R1-1B5 是基于RNN的70亿参数模型的早期预览版,通过从DeepSeek-R1-Distill-Qwen-1.5B进行三阶段知识蒸馏训练而成,上下文长度为2k。
下载量 164
发布时间 : 2/7/2025
模型简介
ARWKV-R1-1B5 是一个基于RWKV-7时间混合与Transformer MLP架构的混合设计模型,展示了RWKV-7的高效循环机制和无自注意力的优势。
模型特点
高效循环机制
基于RWKV-7的高效循环机制,无自注意力,完全O(n)复杂度。
恒定显存占用
模型在推理过程中保持恒定显存占用,适合单GPU训练和推理。
混合架构设计
结合RWKV-7时间混合与Transformer MLP架构,优化了模型性能和效率。
模型能力
文本生成
多语言支持
高效推理
使用案例
通用问答
Trivia问答
作为世界级的trivia AI,提供准确、简洁的回答。
翻译
多语言翻译
支持中英文之间的翻译任务。
化学方程式
化学方程式生成
生成化学方程式。
🚀 ARWKV🪿
基于RWKV-7时间混合和Transformer MLP的文本生成模型,具有高效递归机制和低显存占用等特性
🚀 快速开始
安装依赖
pip3 install --upgrade rwkv-fla transformers
环境配置
在训练前,需要设置环境变量:
export WKV_MODE=chunk
代码示例
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"RWKV-Red-Team/ARWKV-R1-1B5",
device_map="auto",
torch_dtype=torch.float16,
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(
"RWKV-Red-Team/ARWKV-R1-1B5"
)
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.
✨ 主要特性
- 高效递归机制:采用RWKV-7的高效递归机制,提升模型性能。
- 无自注意力机制:完全O(n)复杂度,无需自注意力计算。
- 显存使用恒定:在推理过程中保持恒定的显存使用。
- 单GPU可训练:支持在单GPU上进行训练。
📦 安装指南
依赖安装
pip3 install --upgrade rwkv-fla transformers
环境变量设置
在训练前,需要设置环境变量:
export WKV_MODE=chunk
💻 使用示例
基础用法
# 上述给出的代码示例即为基础用法示例
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"RWKV-Red-Team/ARWKV-R1-1B5",
device_map="auto",
torch_dtype=torch.float16,
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(
"RWKV-Red-Team/ARWKV-R1-1B5"
)
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()
📚 详细文档
关键特性详情
属性 | 详情 |
---|---|
架构 | RWKV-7 TimeMix + SwiGLU(混合设计) |
上下文窗口 | 2048训练上下文(预览版限制) |
训练令牌 | 4000万(专注于知识蒸馏) |
精度 | 推荐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
使用案例
案例 | 图片 |
---|---|
化学方程式 | 点击查看 |
翻译 | 点击查看 |
近期抑郁相关 | 点击查看1,点击查看2 |
核爆炸相关 | 点击查看1,点击查看2 |
核电站 | 点击查看 |
🔧 技术细节
本模型是一个基于RNN的70亿参数模型的早期预览版本,通过从DeepSeek-R1-Distill-Qwen-1.5B进行三阶段知识蒸馏,在2k上下文长度上进行训练(仅应用了第二阶段,未进行SFT或DPO)。模型采用了RWKV-7的时间混合和SwiGLU的混合架构,去除了传统的多头潜在注意力和RoPE位置编码,采用了RWKV-7时间混合和状态递归机制,实现了高效的递归计算和恒定的显存使用。
📄 许可证
本项目采用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