zhiyuan8 commited on
Commit
1df877d
·
verified ·
1 Parent(s): 8936b95

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +25 -0
README.md CHANGED
@@ -63,6 +63,31 @@ You can use this model just as any other HuggingFace models:
63
  from transformers import AutoModelForCausalLM, AutoTokenizer
64
  model = AutoModelForCausalLM.from_pretrained('fla-hub/rwkv7-2.9B-world', trust_remote_code=True)
65
  tokenizer = AutoTokenizer.from_pretrained('fla-hub/rwkv7-2.9B-world', trust_remote_code=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  ```
67
 
68
  ### Training Data
 
63
  from transformers import AutoModelForCausalLM, AutoTokenizer
64
  model = AutoModelForCausalLM.from_pretrained('fla-hub/rwkv7-2.9B-world', trust_remote_code=True)
65
  tokenizer = AutoTokenizer.from_pretrained('fla-hub/rwkv7-2.9B-world', trust_remote_code=True)
66
+ model = model.cuda()
67
+ prompt = "What is a large language model?"
68
+ messages = [
69
+ {"role": "user", "content": "Who are you?"},
70
+ {"role": "assistant", "content": "I am a GPT-3 based model."},
71
+ {"role": "user", "content": prompt}
72
+ ]
73
+ text = tokenizer.apply_chat_template(
74
+ messages,
75
+ tokenize=False,
76
+ add_generation_prompt=True
77
+ )
78
+
79
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
80
+
81
+ generated_ids = model.generate(
82
+ **model_inputs,
83
+ max_new_tokens=1024,
84
+ )
85
+ generated_ids = [
86
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
87
+ ]
88
+
89
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=False)[0]
90
+ print(response)
91
  ```
92
 
93
  ### Training Data