Update README_zh.md
Browse files- README_zh.md +45 -18
README_zh.md
CHANGED
@@ -18,14 +18,23 @@ license: other
|
|
18 |
|
19 |
悟道 · 天鹰 Aquila 模型的更多细节将在官方技术报告中呈现。请关注官方渠道更新。
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
|
22 |
|
23 |
-
## 基本模型性能
|
24 |
-
<br>
|
25 |
-
<p align="center">
|
26 |
-
<img src="base_metrics_CN.jpeg" width="1024"/>
|
27 |
-
<p>
|
28 |
-
<br>
|
29 |
|
30 |
|
31 |
|
@@ -35,28 +44,46 @@ license: other
|
|
35 |
## 使用方式/How to use
|
36 |
|
37 |
### 1. 推理/Inference
|
38 |
-
|
39 |
```python
|
40 |
-
from transformers import AutoTokenizer, AutoModelForCausalLM
|
41 |
import torch
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
model.eval()
|
|
|
47 |
model.to(device)
|
48 |
-
|
|
|
|
|
49 |
tokens = tokenizer.encode_plus(text)['input_ids']
|
50 |
tokens = torch.tensor(tokens)[None,].to(device)
|
51 |
-
|
52 |
with torch.no_grad():
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
```
|
57 |
|
58 |
|
59 |
-
|
60 |
## 证书/License
|
61 |
|
62 |
`Aquila2系列开源模型使用 [智源Aquila系列模型许可协议](https://huggingface.co/BAAI/Aquila2-7B/blob/main/BAAI-Aquila-Model-License%20-Agreement.pdf)
|
|
|
18 |
|
19 |
悟道 · 天鹰 Aquila 模型的更多细节将在官方技术报告中呈现。请关注官方渠道更新。
|
20 |
|
21 |
+
## 更新/Updates 2024.6.6
|
22 |
+
|
23 |
+
我们更新了基础语言模型 **Aquila2-7B**,该模型是基于原版模型经过继续训练得到的,和之前的模型相比,新的模型具备以下优势:
|
24 |
+
|
25 |
+
* 更换了具备更大压缩率的tokenizer,不同tokenizer的压缩率对比如下面表格:
|
26 |
+
|
27 |
+
| Tokenizer | Size | Zh | En | Code | Math | Average |
|
28 |
+
|-----------|-------|--------------------------|--------|-------|-------|---------|
|
29 |
+
| Aquila2-original | 100k | **4.70** | 4.42 | 3.20 | 3.77 | 4.02 |
|
30 |
+
| Qwen1.5 | 151k | 4.27 | 4.51 | 3.62 | 3.35 | 3.94 |
|
31 |
+
| Llama3 | 128k | 3.45 | **4.61** | 3.77 | **3.88** | 3.93 |
|
32 |
+
| Aquila2-new | 143k | 4.60 | **4.61** | **3.78** | **3.88** | **4.22** |
|
33 |
+
|
34 |
+
* 模型支持的最大处理长度从2048增加至8192
|
35 |
+
|
36 |
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
|
40 |
|
|
|
44 |
## 使用方式/How to use
|
45 |
|
46 |
### 1. 推理/Inference
|
47 |
+
|
48 |
```python
|
|
|
49 |
import torch
|
50 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
51 |
+
from transformers import BitsAndBytesConfig
|
52 |
+
|
53 |
+
device= "cuda:0"
|
54 |
+
|
55 |
+
# 模型名称/Model Name
|
56 |
+
model_name = 'BAAI/Aquila2-7B'
|
57 |
+
|
58 |
+
# 加载模型以及tokenizer
|
59 |
+
quantization_config=BitsAndBytesConfig(
|
60 |
+
load_in_4bit=True,
|
61 |
+
bnb_4bit_use_double_quant=True,
|
62 |
+
bnb_4bit_quant_type="nf4",
|
63 |
+
bnb_4bit_compute_dtype=torch.bfloat16,
|
64 |
+
)
|
65 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, trust_remote_code=True,
|
66 |
+
# quantization_config=quantization_config # Uncomment this one for 4-bit quantization
|
67 |
+
)
|
68 |
+
|
69 |
+
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True)
|
70 |
+
|
71 |
model.eval()
|
72 |
+
|
73 |
model.to(device)
|
74 |
+
|
75 |
+
# 对话测试样例/Example
|
76 |
+
text = "生命的意义是"
|
77 |
tokens = tokenizer.encode_plus(text)['input_ids']
|
78 |
tokens = torch.tensor(tokens)[None,].to(device)
|
79 |
+
|
80 |
with torch.no_grad():
|
81 |
+
out = llama.generate(tokens, do_sample=False, max_length=128, eos_token_id=tokenizer.eos_token_id)[0]
|
82 |
+
out = tokenizer.decode(out.cpu().numpy().tolist())
|
83 |
+
print(out)
|
84 |
```
|
85 |
|
86 |
|
|
|
87 |
## 证书/License
|
88 |
|
89 |
`Aquila2系列开源模型使用 [智源Aquila系列模型许可协议](https://huggingface.co/BAAI/Aquila2-7B/blob/main/BAAI-Aquila-Model-License%20-Agreement.pdf)
|