picocreator
commited on
Commit
•
c7ecaf3
1
Parent(s):
346fc40
readme update
Browse files
README.md
CHANGED
@@ -14,65 +14,10 @@ license: apache-2.0
|
|
14 |
>
|
15 |
> This is not an instruct tune model! (soon...)
|
16 |
|
17 |
-
- [
|
|
|
18 |
- [Our wiki](https://wiki.rwkv.com)
|
19 |
-
- [pth model weights](https://huggingface.co/
|
20 |
-
|
21 |
-
#### Running on CPU via HF transformers
|
22 |
-
|
23 |
-
```python
|
24 |
-
import torch
|
25 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
26 |
-
|
27 |
-
def generate_prompt(instruction, input=""):
|
28 |
-
instruction = instruction.strip().replace('\r\n','\n').replace('\n\n','\n')
|
29 |
-
input = input.strip().replace('\r\n','\n').replace('\n\n','\n')
|
30 |
-
if input:
|
31 |
-
return f"""Instruction: {instruction}
|
32 |
-
|
33 |
-
Input: {input}
|
34 |
-
|
35 |
-
Response:"""
|
36 |
-
else:
|
37 |
-
return f"""User: hi
|
38 |
-
|
39 |
-
Assistant: Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.
|
40 |
-
|
41 |
-
User: {instruction}
|
42 |
-
|
43 |
-
Assistant:"""
|
44 |
-
|
45 |
-
|
46 |
-
model = AutoModelForCausalLM.from_pretrained("RWKV/HF_v5-Eagle-7B", trust_remote_code=True).to(torch.float32)
|
47 |
-
tokenizer = AutoTokenizer.from_pretrained("RWKV/HF_v5-Eagle-7B", trust_remote_code=True)
|
48 |
-
|
49 |
-
text = "请介绍北京的旅游景点"
|
50 |
-
prompt = generate_prompt(text)
|
51 |
-
|
52 |
-
inputs = tokenizer(prompt, return_tensors="pt")
|
53 |
-
output = model.generate(inputs["input_ids"], max_new_tokens=333, do_sample=True, temperature=1.0, top_p=0.3, top_k=0, )
|
54 |
-
print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))
|
55 |
-
```
|
56 |
-
|
57 |
-
output:
|
58 |
-
|
59 |
-
```shell
|
60 |
-
User: hi
|
61 |
-
|
62 |
-
Assistant: Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.
|
63 |
-
|
64 |
-
User: 请介绍北京的旅游景点
|
65 |
-
|
66 |
-
Assistant: 北京是中国的首都,拥有众多的旅游景点,以下是其中一些著名的景点:
|
67 |
-
1. 故宫:位于北京市中心,是明清两代的皇宫,内有大量的文物和艺术品。
|
68 |
-
2. 天安门广场:是中国最著名的广场之一,是中国人民政治协商会议的旧址,也是中国人民政治协商会议的中心。
|
69 |
-
3. 颐和园:是中国古代皇家园林之一,有着悠久的历史和丰富的文化内涵。
|
70 |
-
4. 长城:是中国古代的一道长城,全长约万里,是中国最著名的旅游景点之一。
|
71 |
-
5. 北京大学:是中国著名的高等教育机构之一,有着悠久的历史和丰富的文化内涵。
|
72 |
-
6. 北京动物园:是中国最大的动物园之一,有着丰富的动物资源和丰富的文化内涵。
|
73 |
-
7. 故宫博物院:是中国最著名的博物馆之一,收藏了大量的文物和艺术品,是中国最重要的文化遗产之一。
|
74 |
-
8. 天坛:是中国古代皇家
|
75 |
-
```
|
76 |
|
77 |
#### Running on GPU via HF transformers
|
78 |
|
@@ -99,10 +44,10 @@ User: {instruction}
|
|
99 |
Assistant:"""
|
100 |
|
101 |
|
102 |
-
model = AutoModelForCausalLM.from_pretrained("
|
103 |
-
tokenizer = AutoTokenizer.from_pretrained("
|
104 |
|
105 |
-
text = "
|
106 |
prompt = generate_prompt(text)
|
107 |
|
108 |
inputs = tokenizer(prompt, return_tensors="pt").to(0)
|
@@ -117,74 +62,7 @@ User: hi
|
|
117 |
|
118 |
Assistant: Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.
|
119 |
|
120 |
-
User:
|
121 |
|
122 |
-
Assistant:
|
123 |
```
|
124 |
-
|
125 |
-
#### Batch Inference
|
126 |
-
|
127 |
-
```python
|
128 |
-
import torch
|
129 |
-
from transformers import AutoModelForCausalLM, AutoTokenizer
|
130 |
-
|
131 |
-
def generate_prompt(instruction, input=""):
|
132 |
-
instruction = instruction.strip().replace('\r\n', '\n').replace('\n\n', '\n')
|
133 |
-
input = input.strip().replace('\r\n', '\n').replace('\n\n', '\n')
|
134 |
-
if input:
|
135 |
-
return f"""Instruction: {instruction}
|
136 |
-
|
137 |
-
Input: {input}
|
138 |
-
|
139 |
-
Response:"""
|
140 |
-
else:
|
141 |
-
return f"""User: hi
|
142 |
-
|
143 |
-
Assistant: Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.
|
144 |
-
|
145 |
-
User: {instruction}
|
146 |
-
|
147 |
-
Assistant:"""
|
148 |
-
|
149 |
-
model = AutoModelForCausalLM.from_pretrained("RWKV/HF_v5-Eagle-7B", trust_remote_code=True).to(torch.float32)
|
150 |
-
tokenizer = AutoTokenizer.from_pretrained("RWKV/HF_v5-Eagle-7B", trust_remote_code=True)
|
151 |
-
|
152 |
-
texts = ["请介绍北京的旅游景点", "介绍一下大熊猫", "乌兰察布"]
|
153 |
-
prompts = [generate_prompt(text) for text in texts]
|
154 |
-
|
155 |
-
inputs = tokenizer(prompts, return_tensors="pt", padding=True)
|
156 |
-
outputs = model.generate(inputs["input_ids"], max_new_tokens=128, do_sample=True, temperature=1.0, top_p=0.3, top_k=0, )
|
157 |
-
|
158 |
-
for output in outputs:
|
159 |
-
print(tokenizer.decode(output.tolist(), skip_special_tokens=True))
|
160 |
-
|
161 |
-
```
|
162 |
-
|
163 |
-
output:
|
164 |
-
|
165 |
-
```shell
|
166 |
-
User: hi
|
167 |
-
|
168 |
-
Assistant: Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.
|
169 |
-
|
170 |
-
User: 请介绍北京的旅游景点
|
171 |
-
|
172 |
-
Assistant: 北京是中国的首都,拥有丰富的旅游资源和历史文化遗产。以下是一些北京的旅游景点:
|
173 |
-
1. 故宫:位于北京市中心,是明清两代的皇宫,是中国最大的古代宫殿建筑群之一。
|
174 |
-
2. 天安门广场:位于北京市中心,是中国最著名的城市广场之一,也是中国最大的城市广场。
|
175 |
-
3. 颐和
|
176 |
-
User: hi
|
177 |
-
|
178 |
-
Assistant: Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.
|
179 |
-
|
180 |
-
User: 介绍一下大熊猫
|
181 |
-
|
182 |
-
Assistant: 大熊猫是一种生活在中国中部地区的哺乳动物,也是中国的国宝之一。它们的外貌特征是圆形的黑白相间的身体,有着黑色的毛发和圆圆的眼睛。大熊猫是一种濒危物种,目前只有在野外的几个保护区才能看到它们的身影。大熊猫的食物主要是竹子,它们会在竹子上寻找食物,并且可以通
|
183 |
-
User: hi
|
184 |
-
|
185 |
-
Assistant: Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.
|
186 |
-
|
187 |
-
User: 乌兰察布
|
188 |
-
|
189 |
-
Assistant: 乌兰察布是中国新疆维吾尔自治区的一个县级市,位于新疆维吾尔自治区中部,是新疆的第二大城市。乌兰察布市是新疆的第一大城市,也是新疆的重要城市之一。乌兰察布市是新疆的经济中心,也是新疆的重要交通枢纽之一。乌兰察布市的人口约为2.5万人,其中汉族占绝大多数。乌
|
190 |
-
```
|
|
|
14 |
>
|
15 |
> This is not an instruct tune model! (soon...)
|
16 |
|
17 |
+
- [Our cloud platform](https://recursal.ai)
|
18 |
+
- [HF Demo](https://huggingface.co/spaces/recursal/EagleX-7B-1.7T-Gradio-Demo)
|
19 |
- [Our wiki](https://wiki.rwkv.com)
|
20 |
+
- [pth model weights](https://huggingface.co/recursal/EagleX_1-7)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
#### Running on GPU via HF transformers
|
23 |
|
|
|
44 |
Assistant:"""
|
45 |
|
46 |
|
47 |
+
model = AutoModelForCausalLM.from_pretrained("recursal/EagleX_1-7T_HF", trust_remote_code=True, torch_dtype=torch.float16).to(0)
|
48 |
+
tokenizer = AutoTokenizer.from_pretrained("recursal/EagleX_1-7T_HF", trust_remote_code=True)
|
49 |
|
50 |
+
text = "Tell me a fun fact"
|
51 |
prompt = generate_prompt(text)
|
52 |
|
53 |
inputs = tokenizer(prompt, return_tensors="pt").to(0)
|
|
|
62 |
|
63 |
Assistant: Hi. I am your assistant and I will provide expert full response in full details. Please feel free to ask any question and I will always answer it.
|
64 |
|
65 |
+
User: Tell me a fun fact
|
66 |
|
67 |
+
Assistant: Did you know that the human brain has 100 billion neurons?
|
68 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|