sixsixcoder
commited on
Update README_zh.md
Browse files- README_zh.md +53 -25
README_zh.md
CHANGED
@@ -1,27 +1,20 @@
|
|
1 |
-
#
|
2 |
|
3 |
-
|
4 |
|
5 |
-
|
6 |
|
7 |
-
|
8 |
|
9 |
-
|
10 |
|
11 |
-
GLM-4-9B
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
reasoning (supporting up to 128K context). This generation of models has added multi-language support, supporting 26
|
17 |
-
languages including Japanese, Korean, and German. We have also launched the **GLM-4-9B-Chat-1M** model that supports 1M
|
18 |
-
context length (about 2 million Chinese characters) and the multimodal model GLM-4V-9B based on GLM-4-9B.
|
19 |
-
**GLM-4V-9B** possesses dialogue capabilities in both Chinese and English at a high resolution of 1120*1120.
|
20 |
-
In various multimodal evaluations, including comprehensive abilities in Chinese and English, perception & reasoning,
|
21 |
-
text recognition, and chart understanding, GLM-4V-9B demonstrates superior performance compared to
|
22 |
-
GPT-4-turbo-2024-04-09, Gemini 1.0 Pro, Qwen-VL-Max, and Claude 3 Opus.
|
23 |
|
24 |
-
|
25 |
|
26 |
| Model | MMLU | C-Eval | GPQA | GSM8K | MATH | HumanEval |
|
27 |
|:--------------------|:--------:|:--------:|:--------:|:--------:|:--------:|:---------:|
|
@@ -30,18 +23,53 @@ We evaluated the GLM-4-9B base model on some typical tasks, and the results are
|
|
30 |
| ChatGLM3-6B-Base | 61.4 | 69.0 | - | 72.3 | 25.7 | - |
|
31 |
| GLM-4-9B | **74.7** | **77.1** | **34.3** | **84.0** | **30.4** | **70.1** |
|
32 |
|
33 |
-
|
|
|
|
|
|
|
34 |
|
35 |
-
|
36 |
|
37 |
-
|
38 |
|
39 |
-
|
40 |
|
|
|
|
|
|
|
|
|
41 |
|
42 |
-
|
43 |
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
```
|
47 |
@misc{glm2024chatglm,
|
@@ -52,4 +80,4 @@ If you find our work useful, please consider citing the following paper.
|
|
52 |
archivePrefix={arXiv},
|
53 |
primaryClass={id='cs.CL' full_name='Computation and Language' is_active=True alt_name='cmp-lg' in_archive='cs' is_general=False description='Covers natural language processing. Roughly includes material in ACM Subject Class I.2.7. Note that work on artificial languages (programming languages, logics, formal systems) that does not explicitly address natural-language issues broadly construed (natural-language processing, computational linguistics, speech, text retrieval, etc.) is not appropriate for this area.'}
|
54 |
}
|
55 |
-
```
|
|
|
1 |
+
# glm-4-9b
|
2 |
|
3 |
+
Read this in [English](README.md).
|
4 |
|
5 |
+
如果您使用的是这个仓库中的权重,请更新到
|
6 |
|
7 |
+
<span style="color:red; font-weight:bold;"> transformers>=4.46.0 </span>
|
8 |
|
9 |
+
这些权重 **不兼容** 较早版本的 transformers 库。
|
10 |
|
11 |
+
GLM-4-9B 是智谱 AI 推出的最新一代预训练模型 GLM-4 系列中的开源版本。
|
12 |
+
在语义、数学、推理、代码和知识等多方面的数据集测评中,GLM-4-9B 及其人类偏好对齐的版本 GLM-4-9B-Chat 均表现出较高的性能。
|
13 |
+
除了能进行多轮对话,GLM-4-9B-Chat 还具备网页浏览、代码执行、自定义工具调用(Function Call)和长文本推理(支持最大 128K
|
14 |
+
上下文)等高级功能。
|
15 |
+
本代模型增加了多语言支持,支持包括日语,韩语,德语在内的 26 种语言。我们还推出了支持 1M 上下文长度(约 200 万中文字符)的模型。
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
我们在一些典型任务上对 GLM-4-9B 基座模型进行了评测,结果如下:
|
18 |
|
19 |
| Model | MMLU | C-Eval | GPQA | GSM8K | MATH | HumanEval |
|
20 |
|:--------------------|:--------:|:--------:|:--------:|:--------:|:--------:|:---------:|
|
|
|
23 |
| ChatGLM3-6B-Base | 61.4 | 69.0 | - | 72.3 | 25.7 | - |
|
24 |
| GLM-4-9B | **74.7** | **77.1** | **34.3** | **84.0** | **30.4** | **70.1** |
|
25 |
|
26 |
+
**本仓库是 GLM-4-9B 的基座版本,支持`8K`上下文长度。**
|
27 |
+
|
28 |
+
|
29 |
+
## 运行模型
|
30 |
|
31 |
+
**更多推理代码和依赖信息,请访问我们的 [github](https://github.com/THUDM/GLM-4)。**
|
32 |
|
33 |
+
**请严格按照[依赖](https://github.com/THUDM/GLM-4/blob/main/basic_demo/requirements.txt)安装,否则无法正常运行。**
|
34 |
|
35 |
+
### Transformers 推理代码
|
36 |
|
37 |
+
```python
|
38 |
+
import torch
|
39 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
40 |
+
import os
|
41 |
|
42 |
+
os.environ['CUDA_VISIBLE_DEVICES'] = '0' # 设置 GPU 编号,如果单机单卡指定一个,单机多卡指定多个 GPU 编号
|
43 |
|
44 |
+
MODEL_PATH = "THUDM/glm-4-9b-hf"
|
45 |
+
|
46 |
+
model = AutoModelForCausalLM.from_pretrained(
|
47 |
+
MODEL_PATH,
|
48 |
+
torch_dtype=torch.bfloat16,
|
49 |
+
low_cpu_mem_usage=True,
|
50 |
+
trust_remote_code=True,
|
51 |
+
device_map="auto"
|
52 |
+
).eval()
|
53 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
54 |
+
tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH, trust_remote_code=True)
|
55 |
+
|
56 |
+
encoding = tokenizer("你是谁<|endoftext|>")
|
57 |
+
inputs = {key: torch.tensor([value]).to(device) for key, value in encoding.items()}
|
58 |
+
|
59 |
+
gen_kwargs = {"max_length": 2500, "do_sample": True, "top_k": 1}
|
60 |
+
with torch.no_grad():
|
61 |
+
outputs = model.generate(**inputs, **gen_kwargs)
|
62 |
+
outputs = outputs[:, inputs['input_ids'].shape[1]:]
|
63 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
64 |
+
```
|
65 |
+
|
66 |
+
## 协议
|
67 |
+
|
68 |
+
GLM-4 模型的权重的使用则需要遵循 [LICENSE](LICENSE)。
|
69 |
+
|
70 |
+
## 引用
|
71 |
+
|
72 |
+
如果你觉得我们的工作有帮助的话,请考虑引用下列论文。
|
73 |
|
74 |
```
|
75 |
@misc{glm2024chatglm,
|
|
|
80 |
archivePrefix={arXiv},
|
81 |
primaryClass={id='cs.CL' full_name='Computation and Language' is_active=True alt_name='cmp-lg' in_archive='cs' is_general=False description='Covers natural language processing. Roughly includes material in ACM Subject Class I.2.7. Note that work on artificial languages (programming languages, logics, formal systems) that does not explicitly address natural-language issues broadly construed (natural-language processing, computational linguistics, speech, text retrieval, etc.) is not appropriate for this area.'}
|
82 |
}
|
83 |
+
```
|