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