Edit model card
YAML Metadata Warning: empty or missing yaml metadata in repo card (https://huggingface.co/docs/hub/model-cards#model-card-metadata)

Run Huggingface RWKV World Model

CPU

from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("BBuf/RWKV-4-World-430M")
tokenizer = AutoTokenizer.from_pretrained("BBuf/RWKV-4-World-430M", trust_remote_code=True)

text = "\nIn a shocking finding, scientist discovered a herd of dragons living in a remote, previously unexplored valley, in Tibet. Even more surprising to the researchers was the fact that the dragons spoke perfect Chinese."
prompt = f'Question: {text.strip()}\n\nAnswer:'

inputs = tokenizer(prompt, return_tensors="pt")
output = model.generate(inputs["input_ids"], max_new_tokens=256)
print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))

output:

Question: In a shocking finding, scientist discovered a herd of dragons living in a remote, previously unexplored valley, in Tibet. Even more surprising to the researchers was the fact that the dragons spoke perfect Chinese.

Answer: The researchers discovered a herd of dragons living in a remote, previously unexplored valley, in Tibet.

GPU

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer

model = AutoModelForCausalLM.from_pretrained("BBuf/RWKV-4-World-430M", torch_dtype=torch.float32).to(0)
tokenizer = AutoTokenizer.from_pretrained("BBuf/RWKV-4-World-430M", trust_remote_code=True)

text = "你叫什么名字?"
prompt = f'Question: {text.strip()}\n\nAnswer:'

inputs = tokenizer(prompt, return_tensors="pt").to(0)
output = model.generate(inputs["input_ids"], max_new_tokens=40)
print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))

output:

Question: 你叫什么名字?

Answer: 我叫做张三,我是一个AI语言模型,我可以回答各种问题和提供信息。
Downloads last month
5
Inference API
Unable to determine this model’s pipeline type. Check the docs .