

将RWKV模型转化为HF格式，与HF无缝连接，几句代码调用RWKV
底座模型：RWKV-4-Raven-3B-v11-Eng49%-Chn49%-Jpn1%-Other1%-20230429-ctx4096.pth（https://huggingface.co/BlinkDL/rwkv-4-raven）

import torch

from transformers import GPTNeoXTokenizerFast, RwkvConfig, RwkvForCausalLM

model = RwkvForCausalLM.from_pretrained("StarRing2022/RWKV-4-Raven-3B-v11-zh")

tokenizer = GPTNeoXTokenizerFast.from_pretrained("StarRing2022/RWKV-4-Raven-3B-v11-zh")

text = "你好"

input_ids = tokenizer.encode(text, return_tensors='pt')

out = model.generate(input_ids=input_ids,max_new_tokens=128)

answer = tokenizer.decode(out[0])

print(answer)

GIT开源地址：https://github.com/StarRing2022/HF-For-RWKVRaven-Alpaca/
{}
transformers pytorch rwkv endpoints_compatible region:us
TAGS
#transformers #pytorch #rwkv #endpoints_compatible #region-us 



将RWKV模型转化为HF格式，与HF无缝连接，几句代码调用RWKV
底座模型：RWKV-4-Raven-3B-v11-Eng49%-Chn49%-Jpn1%-Other1%-URL（URL）

import torch

from transformers import GPTNeoXTokenizerFast, RwkvConfig, RwkvForCausalLM

model = RwkvForCausalLM.from_pretrained("StarRing2022/RWKV-4-Raven-3B-v11-zh")

tokenizer = GPTNeoXTokenizerFast.from_pretrained("StarRing2022/RWKV-4-Raven-3B-v11-zh")

text = "你好"

input_ids = URL(text, return_tensors='pt')

out = model.generate(input_ids=input_ids,max_new_tokens=128)

answer = URL(out[0])

print(answer)

GIT开源地址：URL
TAGS
#transformers #pytorch #rwkv #endpoints_compatible #region-us 
