duzx16
commited on
Commit
•
d0886d5
1
Parent(s):
90387f4
Update README.md
Browse files
README.md
CHANGED
@@ -7,9 +7,9 @@ tags:
|
|
7 |
- chatglm
|
8 |
- thudm
|
9 |
---
|
10 |
-
#
|
11 |
<p align="center">
|
12 |
-
|
13 |
</p>
|
14 |
|
15 |
<p align="center">
|
@@ -17,14 +17,22 @@ tags:
|
|
17 |
</p>
|
18 |
|
19 |
## 介绍
|
20 |
-
ChatGLM
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
## 软件依赖
|
25 |
|
26 |
```shell
|
27 |
-
pip install protobuf
|
28 |
```
|
29 |
|
30 |
## 代码调用
|
@@ -33,8 +41,9 @@ pip install protobuf==3.20.0 transformers==4.27.1 icetk cpm_kernels
|
|
33 |
|
34 |
```ipython
|
35 |
>>> from transformers import AutoTokenizer, AutoModel
|
36 |
-
>>> tokenizer = AutoTokenizer.from_pretrained("THUDM/
|
37 |
-
>>> model = AutoModel.from_pretrained("THUDM/
|
|
|
38 |
>>> response, history = model.chat(tokenizer, "你好", history=[])
|
39 |
>>> print(response)
|
40 |
你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。
|
@@ -52,29 +61,27 @@ pip install protobuf==3.20.0 transformers==4.27.1 icetk cpm_kernels
|
|
52 |
如果这些方法无法帮助你入睡,你可以考虑咨询医生或睡眠专家,寻求进一步的建议。
|
53 |
```
|
54 |
|
55 |
-
关于更多的使用说明,包括如何运行命令行和网页版本的 DEMO,以及使用模型量化以节省显存,请参考我们的 [Github Repo](https://github.com/THUDM/
|
56 |
|
57 |
-
For more instructions, including how to run CLI and web demos, and model quantization, please refer to our [Github Repo](https://github.com/THUDM/
|
58 |
|
59 |
## Change Log
|
60 |
-
* v0.1.0
|
61 |
|
62 |
## 协议
|
63 |
|
64 |
-
本仓库的代码依照 [Apache-2.0](LICENSE) 协议开源,
|
65 |
|
66 |
## 引用
|
67 |
|
68 |
-
|
69 |
|
70 |
```
|
71 |
-
@
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
year={2023},
|
77 |
-
url={https://openreview.net/forum?id=-Aw0rrrPUF}
|
78 |
}
|
79 |
```
|
80 |
```
|
|
|
7 |
- chatglm
|
8 |
- thudm
|
9 |
---
|
10 |
+
# ChatGLM2-6B
|
11 |
<p align="center">
|
12 |
+
💻 <a href="https://github.com/THUDM/ChatGLM-6B" target="_blank">Github Repo</a> • 🐦 <a href="https://twitter.com/thukeg" target="_blank">Twitter</a> • 📃 <a href="https://arxiv.org/abs/2103.10360" target="_blank">[GLM@ACL 22]</a> <a href="https://github.com/THUDM/GLM" target="_blank">[GitHub]</a> • 📃 <a href="https://arxiv.org/abs/2210.02414" target="_blank">[GLM-130B@ICLR 23]</a> <a href="https://github.com/THUDM/GLM-130B" target="_blank">[GitHub]</a> <br>
|
13 |
</p>
|
14 |
|
15 |
<p align="center">
|
|
|
17 |
</p>
|
18 |
|
19 |
## 介绍
|
20 |
+
ChatGLM**2**-6B 是开源中英双语对话模型 [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B) 的第二代版本,在保留了初代模型对话流畅、部署门槛较低等众多优秀特性的基础之上,ChatGLM**2**-6B 引入了如下新特性:
|
21 |
|
22 |
+
1. **更强大的性能**:基于 ChatGLM 初代模型的开发经验,我们全面升级了 ChatGLM2-6B 的基座模型。ChatGLM2-6B 使用了 [GLM](https://github.com/THUDM/GLM) 的混合目标函数,经过了 1.4T 中英标识符的预训练与人类偏好对齐训练,[评测结果](#评测结果)显示,相比于初代模型,ChatGLM2-6B 在 MMLU(+23%)、CEval(+33%)、GSM8K(+571%) 、BBH(+60%)等数据集上的性能取得了大幅度的提升,在同尺寸开源模型中具有较强的竞争力。
|
23 |
+
2. **更长的上下文**:基于 [FlashAttention](https://github.com/HazyResearch/flash-attention) 技术,我们将基座模型的上下文长度(Context Length)由 ChatGLM-6B 的 2K 扩展到了 32K,并在对话阶段使用 8K 的上下文长度训练,允许更多轮次的对话。但当前版本的 ChatGLM2-6B 对单轮超长文档的理解能力有限,我们会在后续迭代升级中着重进行优化。
|
24 |
+
3. **更高效的推理**:基于 [Multi-Query Attention](http://arxiv.org/abs/1911.02150) 技术,ChatGLM2-6B 有更高效的推理速度和更低的显存占用:在官方的模型实现下,推理速度相比初代提升了 42%,INT4 量化下,6G 显存支持的对话长度由 1K 提升到了 8K。
|
25 |
+
|
26 |
+
ChatGLM**2**-6B is the second-generation version of the open-source bilingual (Chinese-English) chat model [ChatGLM-6B](https://github.com/THUDM/ChatGLM-6B). It retains the smooth conversation flow and low deployment threshold of the first-generation model, while introducing the following new features:
|
27 |
+
|
28 |
+
1. **Stronger Performance**: Based on the development experience of the first-generation ChatGLM model, we have fully upgraded the base model of ChatGLM2-6B. ChatGLM2-6B uses the hybrid objective function of [GLM](https://github.com/THUDM/GLM), and has undergone pre-training with 1.4T bilingual tokens and human preference alignment training. The [evaluation results](README.md#evaluation-results) show that, compared to the first-generation model, ChatGLM2-6B has achieved substantial improvements in performance on datasets like MMLU (+23%), CEval (+33%), GSM8K (+571%), BBH (+60%), showing strong competitiveness among models of the same size.
|
29 |
+
2. **Longer Context**: Based on [FlashAttention](https://github.com/HazyResearch/flash-attention) technique, we have extended the context length of the base model from 2K in ChatGLM-6B to 32K, and trained with a context length of 8K during the dialogue alignment, allowing for more rounds of dialogue. However, the current version of ChatGLM2-6B has limited understanding of single-round ultra-long documents, which we will focus on optimizing in future iterations.
|
30 |
+
3. **More Efficient Inference**: Based on [Multi-Query Attention](http://arxiv.org/abs/1911.02150) technique, ChatGLM2-6B has more efficient inference speed and lower GPU memory usage: under the official implementation, the inference speed has increased by 42% compared to the first generation; under INT4 quantization, the dialogue length supported by 6G GPU memory has increased from 1K to 8K.
|
31 |
|
32 |
## 软件依赖
|
33 |
|
34 |
```shell
|
35 |
+
pip install protobuf transformers==4.27.1 cpm_kernels torch>=2.0 gradio mdtex2html sentencepiece accelerate
|
36 |
```
|
37 |
|
38 |
## 代码调用
|
|
|
41 |
|
42 |
```ipython
|
43 |
>>> from transformers import AutoTokenizer, AutoModel
|
44 |
+
>>> tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True)
|
45 |
+
>>> model = AutoModel.from_pretrained("THUDM/chatglm2-6b", trust_remote_code=True).half().cuda()
|
46 |
+
>>> model = model.eval()
|
47 |
>>> response, history = model.chat(tokenizer, "你好", history=[])
|
48 |
>>> print(response)
|
49 |
你好👋!我是人工智能助手 ChatGLM-6B,很高兴见到你,欢迎问我任何问题。
|
|
|
61 |
如果这些方法无法帮助你入睡,你可以考虑咨询医生或睡眠专家,寻求进一步的建议。
|
62 |
```
|
63 |
|
64 |
+
关于更多的使用说明,包括如何运行命令行和网页版本的 DEMO,以及使用模型量化以节省显存,请参考我们的 [Github Repo](https://github.com/THUDM/ChatGLM2-6B)。
|
65 |
|
66 |
+
For more instructions, including how to run CLI and web demos, and model quantization, please refer to our [Github Repo](https://github.com/THUDM/ChatGLM2-6B).
|
67 |
|
68 |
## Change Log
|
69 |
+
* v0.1.0
|
70 |
|
71 |
## 协议
|
72 |
|
73 |
+
本仓库的代码依照 [Apache-2.0](LICENSE) 协议开源,ChatGLM2-6B 模型的权重的使用则需要遵循 [Model License](MODEL_LICENSE)。
|
74 |
|
75 |
## 引用
|
76 |
|
77 |
+
如果你觉得我们的工作有帮助的话,请考虑引用下列论文,ChatGLM2-6B 的论文会在近期公布,尽情期待~
|
78 |
|
79 |
```
|
80 |
+
@article{zeng2022glm,
|
81 |
+
title={Glm-130b: An open bilingual pre-trained model},
|
82 |
+
author={Zeng, Aohan and Liu, Xiao and Du, Zhengxiao and Wang, Zihan and Lai, Hanyu and Ding, Ming and Yang, Zhuoyi and Xu, Yifan and Zheng, Wendi and Xia, Xiao and others},
|
83 |
+
journal={arXiv preprint arXiv:2210.02414},
|
84 |
+
year={2022}
|
|
|
|
|
85 |
}
|
86 |
```
|
87 |
```
|