Update README.md
Browse files
README.md
CHANGED
@@ -1,11 +1,216 @@
|
|
1 |
-
###
|
2 |
|
3 |
> HF compatible model for Finch-14B.
|
4 |
-
> This is an early preview for testing.
|
5 |
-
> **This is not final**
|
6 |
|
7 |
-
![
|
8 |
|
9 |
-
> origin pth weight at https://huggingface.co/BlinkDL/rwkv-6-world/blob/main/ .
|
10 |
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
### Huggingface RWKV Finch 14B Model
|
2 |
|
3 |
> HF compatible model for Finch-14B.
|
|
|
|
|
4 |
|
5 |
+
![Finch Bird](./imgs/finch.jpg)
|
6 |
|
|
|
7 |
|
8 |
+
> **! Important Note !**
|
9 |
+
>
|
10 |
+
> The following is the HF transformers implementation of the Finch 14B model. This is meant to be used with the huggingface transformers
|
11 |
+
>
|
12 |
+
>
|
13 |
+
|
14 |
+
|
15 |
+
## Quickstart with the hugging face transformer library
|
16 |
+
|
17 |
+
```
|
18 |
+
model = AutoModelForCausalLM.from_pretrained("RWKV/v6-Finch-14B-HF", trust_remote_code=True).to(torch.float32)
|
19 |
+
tokenizer = AutoTokenizer.from_pretrained("RWKV/v6-Finch-14B-HF", trust_remote_code=True)
|
20 |
+
```
|
21 |
+
|
22 |
+
## Evaluation
|
23 |
+
|
24 |
+
The following demonstrates the improvements from Eagle 7B to Finch 14B
|
25 |
+
|
26 |
+
| | [Eagle 7B](https://huggingface.co/RWKV/v5-Eagle-7B-HF) | [Finch 7B](https://huggingface.co/RWKV/v6-Finch-7B-HF) | [Finch 14B](https://huggingface.co/RWKV/v6-Finch-14B-HF) |
|
27 |
+
| --- | --- | --- | --- |
|
28 |
+
| [ARC](https://github.com/EleutherAI/lm-evaluation-harness/tree/main/lm_eval/tasks/arc) | 39.59% | 41.47% | 46.33% |
|
29 |
+
| [HellaSwag](https://github.com/EleutherAI/lm-evaluation-harness/tree/main/lm_eval/tasks/hellaswag) | 53.09% | 55.96% | 57.69% |
|
30 |
+
| [MMLU](https://github.com/EleutherAI/lm-evaluation-harness/tree/main/lm_eval/tasks/mmlu) | 30.86% | 41.70% | 56.05% |
|
31 |
+
| [Truthful QA](https://github.com/EleutherAI/lm-evaluation-harness/tree/main/lm_eval/tasks/truthfulqa) | 33.03% | 34.82% | 39.27% |
|
32 |
+
| [Winogrande](https://github.com/EleutherAI/lm-evaluation-harness/tree/main/lm_eval/tasks/winogrande) | 67.56% | 71.19% | 74.43% |
|
33 |
+
|
34 |
+
#### Running on CPU via HF transformers
|
35 |
+
|
36 |
+
```python
|
37 |
+
import torch
|
38 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
39 |
+
|
40 |
+
def generate_prompt(instruction, input=""):
|
41 |
+
instruction = instruction.strip().replace('\r\n','\n').replace('\n\n','\n')
|
42 |
+
input = input.strip().replace('\r\n','\n').replace('\n\n','\n')
|
43 |
+
if input:
|
44 |
+
return f"""Instruction: {instruction}
|
45 |
+
|
46 |
+
Input: {input}
|
47 |
+
|
48 |
+
Response:"""
|
49 |
+
else:
|
50 |
+
return f"""User: hi
|
51 |
+
|
52 |
+
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.
|
53 |
+
|
54 |
+
User: {instruction}
|
55 |
+
|
56 |
+
Assistant:"""
|
57 |
+
|
58 |
+
|
59 |
+
model = AutoModelForCausalLM.from_pretrained("RWKV/v5-Eagle-7B-HF", trust_remote_code=True).to(torch.float32)
|
60 |
+
tokenizer = AutoTokenizer.from_pretrained("RWKV/v5-Eagle-7B-HF", trust_remote_code=True)
|
61 |
+
|
62 |
+
text = "请介绍北京的旅游景点"
|
63 |
+
prompt = generate_prompt(text)
|
64 |
+
|
65 |
+
inputs = tokenizer(prompt, return_tensors="pt")
|
66 |
+
output = model.generate(inputs["input_ids"], max_new_tokens=333, do_sample=True, temperature=1.0, top_p=0.3, top_k=0, )
|
67 |
+
print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))
|
68 |
+
```
|
69 |
+
|
70 |
+
output:
|
71 |
+
|
72 |
+
```shell
|
73 |
+
User: hi
|
74 |
+
|
75 |
+
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.
|
76 |
+
|
77 |
+
User: 请介绍北京的旅游景点
|
78 |
+
|
79 |
+
Assistant: 北京是中国的首都,拥有众多的旅游景点,以下是其中一些著名的景点:
|
80 |
+
1. 故宫:位于北京市中心,是明清两代的皇宫,内有大量的文物和艺术品。
|
81 |
+
2. 天安门广场:是中国最著名的广场之一,是中国人民政治协商会议的旧址,也是中国人民政治协商会议的中心。
|
82 |
+
3. 颐和园:是中国古代皇家园林之一,有着悠久的历史和丰富的文化内涵。
|
83 |
+
4. 长城:是中国古代的一道长城,全长约万里,是中国最著名的旅游景点之一。
|
84 |
+
5. 北京大学:是中国著名的高等教育机构之一,有着悠久的历史和丰富的文化内涵。
|
85 |
+
6. 北京动物园:是中国最大的动物园之一,有着丰富的动物资源和丰富的文化内涵。
|
86 |
+
7. 故宫博物院:是中国最著名的博物馆之一,收藏了大量的文物和艺术品,是中国最重要的文化遗产之一。
|
87 |
+
8. 天坛:是中国古代皇家
|
88 |
+
```
|
89 |
+
|
90 |
+
#### Running on GPU via HF transformers
|
91 |
+
|
92 |
+
```python
|
93 |
+
import torch
|
94 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
95 |
+
|
96 |
+
def generate_prompt(instruction, input=""):
|
97 |
+
instruction = instruction.strip().replace('\r\n','\n').replace('\n\n','\n')
|
98 |
+
input = input.strip().replace('\r\n','\n').replace('\n\n','\n')
|
99 |
+
if input:
|
100 |
+
return f"""Instruction: {instruction}
|
101 |
+
|
102 |
+
Input: {input}
|
103 |
+
|
104 |
+
Response:"""
|
105 |
+
else:
|
106 |
+
return f"""User: hi
|
107 |
+
|
108 |
+
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.
|
109 |
+
|
110 |
+
User: {instruction}
|
111 |
+
|
112 |
+
Assistant:"""
|
113 |
+
|
114 |
+
|
115 |
+
model = AutoModelForCausalLM.from_pretrained("RWKV/v5-Eagle-7B-HF", trust_remote_code=True, torch_dtype=torch.float16).to(0)
|
116 |
+
tokenizer = AutoTokenizer.from_pretrained("RWKV/v5-Eagle-7B-HF", trust_remote_code=True)
|
117 |
+
|
118 |
+
text = "介绍一下大熊猫"
|
119 |
+
prompt = generate_prompt(text)
|
120 |
+
|
121 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(0)
|
122 |
+
output = model.generate(inputs["input_ids"], max_new_tokens=128, do_sample=True, temperature=1.0, top_p=0.3, top_k=0, )
|
123 |
+
print(tokenizer.decode(output[0].tolist(), skip_special_tokens=True))
|
124 |
+
```
|
125 |
+
|
126 |
+
output:
|
127 |
+
|
128 |
+
```shell
|
129 |
+
User: hi
|
130 |
+
|
131 |
+
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.
|
132 |
+
|
133 |
+
User: 介绍一下大熊猫
|
134 |
+
|
135 |
+
Assistant: 大熊猫是一种中国特有的哺乳动物,也是中国的国宝之一。它们的外貌特征是圆形的黑白相间的身体,有着黑色的毛发和白色的耳朵。大熊猫的食物主要是竹子,它们会在竹林中寻找竹子,并且会将竹子放在竹笼中进行储存。大熊猫的寿命约为20至30年,但由于栖息地的丧失和人类活动的
|
136 |
+
```
|
137 |
+
|
138 |
+
#### Batch Inference
|
139 |
+
|
140 |
+
```python
|
141 |
+
import torch
|
142 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
143 |
+
|
144 |
+
def generate_prompt(instruction, input=""):
|
145 |
+
instruction = instruction.strip().replace('\r\n', '\n').replace('\n\n', '\n')
|
146 |
+
input = input.strip().replace('\r\n', '\n').replace('\n\n', '\n')
|
147 |
+
if input:
|
148 |
+
return f"""Instruction: {instruction}
|
149 |
+
|
150 |
+
Input: {input}
|
151 |
+
|
152 |
+
Response:"""
|
153 |
+
else:
|
154 |
+
return f"""User: hi
|
155 |
+
|
156 |
+
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.
|
157 |
+
|
158 |
+
User: {instruction}
|
159 |
+
|
160 |
+
Assistant:"""
|
161 |
+
|
162 |
+
model = AutoModelForCausalLM.from_pretrained("RWKV/v5-Eagle-7B-HF", trust_remote_code=True).to(torch.float32)
|
163 |
+
tokenizer = AutoTokenizer.from_pretrained("RWKV/v5-Eagle-7B-HF", trust_remote_code=True)
|
164 |
+
|
165 |
+
texts = ["请介绍北京的旅游景点", "介绍一下大熊猫", "乌兰察布"]
|
166 |
+
prompts = [generate_prompt(text) for text in texts]
|
167 |
+
|
168 |
+
inputs = tokenizer(prompts, return_tensors="pt", padding=True)
|
169 |
+
outputs = model.generate(inputs["input_ids"], max_new_tokens=128, do_sample=True, temperature=1.0, top_p=0.3, top_k=0, )
|
170 |
+
|
171 |
+
for output in outputs:
|
172 |
+
print(tokenizer.decode(output.tolist(), skip_special_tokens=True))
|
173 |
+
|
174 |
+
```
|
175 |
+
|
176 |
+
output:
|
177 |
+
|
178 |
+
```shell
|
179 |
+
User: hi
|
180 |
+
|
181 |
+
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.
|
182 |
+
|
183 |
+
User: 请介绍北京的旅游景点
|
184 |
+
|
185 |
+
Assistant: 北京是中国的首都,拥有丰富的旅游资源和历史文化遗产。以下是一些北京的旅游景点:
|
186 |
+
1. 故宫:位于北京市中心,是明清两代的皇宫,是中国最大的古代宫殿建筑群之一。
|
187 |
+
2. 天安门广场:位于北京市中心,是中国最著名的城市广场之一,也是中国最大的城市广场。
|
188 |
+
3. 颐和
|
189 |
+
User: hi
|
190 |
+
|
191 |
+
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.
|
192 |
+
|
193 |
+
User: 介绍一下大熊猫
|
194 |
+
|
195 |
+
Assistant: 大熊猫是一种生活在中国中部地区的哺乳动物,也是中国的国宝之一。它们的外貌特征是圆形的黑白相间的身体,有着黑色的毛发和圆圆的眼睛。大熊猫是一种濒危物种,目前只有在野外的几个保护区才能看到它们的身影。大熊猫的食物主要是竹子,它们会在竹子上寻找食物,并且可以通
|
196 |
+
User: hi
|
197 |
+
|
198 |
+
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.
|
199 |
+
|
200 |
+
User: 乌兰察布
|
201 |
+
|
202 |
+
Assistant: 乌兰察布是中国新疆维吾尔自治区的一个县级市,位于新疆维吾尔自治区中部,是新疆的第二大城市。乌兰察布市是新疆的第一大城市,也是新疆的重要城市之一。乌兰察布市是新疆的经济中心,也是新疆的重要交通枢纽之一。乌兰察布市的人口约为2.5万人,其中汉族占绝大多数。乌
|
203 |
+
```
|
204 |
+
|
205 |
+
## Links
|
206 |
+
- [Our wiki](https://wiki.rwkv.com)
|
207 |
+
- [Recursal.AI Cloud Platform](https://recursal.ai)
|
208 |
+
- [Featherless Inference](https://featherless.ai/models/RWKV/Finch-14B)
|
209 |
+
- [Blog article, detailing our model launch](https://blog.rwkv.com/p/rwkv-v6-finch-14b-is-here)
|
210 |
+
|
211 |
+
## Acknowledgement
|
212 |
+
We are grateful for the help and support from the following key groups:
|
213 |
+
|
214 |
+
- [Recursal.ai](https://recursal.ai) team for financing the GPU resources, and managing the training of this foundation model - you can run the Eagle line of RWKV models on their cloud / on-premise platform today.
|
215 |
+
- EleutherAI for their support, especially in the v5/v6 Eagle/Finch paper
|
216 |
+
- Linux Foundation AI & Data group for supporting and hosting the RWKV project
|