picocreator commited on
Commit
053671f
1 Parent(s): 1fe8f0d

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +1 -186
README.md CHANGED
@@ -2,189 +2,4 @@
2
  license: apache-2.0
3
  ---
4
 
5
- ![An eagle soaring above a transformer robot](https://substackcdn.com/image/fetch/w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6bbd31a7-21b4-4ff6-b43f-8735d1decf25_2048x1652.png)
6
-
7
- ### Huggingface RWKV-5 Eagle 7B Model - via HF Transformers Library
8
-
9
- > **! Important Note !**
10
- >
11
- > The following is the HF transformers implementation of the RWKV-5 Eagle 7B model. **This is meant to be used with the huggingface transformers**
12
- >
13
- > For the full model weights on its own, to use with other RWKV libraries, refer to [here](https://huggingface.co/RWKV/v5-Eagle-7B)
14
- >
15
- > This is not an instruct tune model! (soon...)
16
-
17
- - [HF Demo](https://huggingface.co/spaces/BlinkDL/RWKV-Gradio-2)
18
- - [Our wiki](https://wiki.rwkv.com)
19
- - [pth model weights](https://huggingface.co/RWKV/v5-Eagle-7B)
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
-
79
- ```python
80
- import torch
81
- from transformers import AutoModelForCausalLM, AutoTokenizer
82
-
83
- def generate_prompt(instruction, input=""):
84
- instruction = instruction.strip().replace('\r\n','\n').replace('\n\n','\n')
85
- input = input.strip().replace('\r\n','\n').replace('\n\n','\n')
86
- if input:
87
- return f"""Instruction: {instruction}
88
-
89
- Input: {input}
90
-
91
- Response:"""
92
- else:
93
- return f"""User: hi
94
-
95
- 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.
96
-
97
- User: {instruction}
98
-
99
- Assistant:"""
100
-
101
-
102
- model = AutoModelForCausalLM.from_pretrained("RWKV/HF_v5-Eagle-7B", trust_remote_code=True, torch_dtype=torch.float16).to(0)
103
- tokenizer = AutoTokenizer.from_pretrained("RWKV/HF_v5-Eagle-7B", trust_remote_code=True)
104
-
105
- text = "介绍一下大熊猫"
106
- prompt = generate_prompt(text)
107
-
108
- inputs = tokenizer(prompt, return_tensors="pt").to(0)
109
- output = model.generate(inputs["input_ids"], max_new_tokens=128, do_sample=True, temperature=1.0, top_p=0.3, top_k=0, )
110
- print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))
111
- ```
112
-
113
- output:
114
-
115
- ```shell
116
- 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: 大熊猫是一种中国特有的哺乳动物,也是中国的国宝之一。它们的外貌特征是圆形的黑白相间的身体,有着黑色的毛发和白色的耳朵。大熊猫的食物主要是竹子,它们会在竹林中寻找竹子,并且会将竹子放在竹笼中进行储存。大熊猫的寿命约为20至30年,但由于栖息地的丧失和人类活动的
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
- ```
 
2
  license: apache-2.0
3
  ---
4
 
5
+ This is an experimental version of Eagle 7B 1T - this is NOT meant for general usage