Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model = AutoModelForCausalLM.from_pretrained("BBuf/RWKV-4-World-169M")
4tokenizer = AutoTokenizer.from_pretrained("BBuf/RWKV-4-World-169M", trust_remote_code=True)
5
6text = "\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."
7prompt = f'Question: {text.strip()}\n\nAnswer:'
8
9inputs = tokenizer(prompt, return_tensors="pt")
10output = model.generate(inputs["input_ids"], max_new_tokens=256)
11print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))1Question: 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.
2
3Answer: The researchers discovered a mysterious finding in a remote, undisclosed valley, in a remote, undisclosed valley.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model = AutoModelForCausalLM.from_pretrained("BBuf/RWKV-4-World-169M", torch_dtype=torch.float32).to(0)
5tokenizer = AutoTokenizer.from_pretrained("BBuf/RWKV-4-World-169M", trust_remote_code=True)
6
7text = "你叫什么名字?"
8prompt = f'Question: {text.strip()}\n\nAnswer:'
9
10inputs = tokenizer(prompt, return_tensors="pt").to(0)
11output = model.generate(inputs["input_ids"], max_new_tokens=40)
12print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))1Question: 你叫什么名字?
2
3Answer: 我是一个人工智能语言模型,没有具体的身份或者特征,也没有能力进行人类的任何任务