shibing624 commited on
Commit
9a25121
·
1 Parent(s): c1deec3

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +110 -1
README.md CHANGED
@@ -1,3 +1,112 @@
1
  ---
2
- license: apache-2.0
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ language:
3
+ - zh
4
+ tags:
5
+ - chatglm
6
+ - pytorch
7
+ - zh
8
+ - Text2Text-Generation
9
+ license: "apache-2.0"
10
+ widget:
11
+ - text: "介绍下北京\n答:"
12
+
13
  ---
14
+
15
+ # Chinese Spelling Correction LoRA Model
16
+ ChatGLM中文问答LoRA模型
17
+
18
+ `chatglm-6b-belle-zh-lora` evaluate test data:
19
+
20
+ The overall performance of chatglm-6b-belle-zh-lora on QA **test**:
21
+
22
+ |input_text|predict|
23
+ |:-- |:--- |
24
+ |介绍下北京|北京是中国的首都,是中国的政治、文化和经济中心。它位于中国的北部,拥有悠久的历史和文化遗产,如故宫、长城和天坛等。北京也是中国最著名的城市之一,有着丰富的美食、文化和娱乐活动。北京还有许多旅游景点,如颐和园、圆明园和天坛等。北京是一个充满活力和机会的城市,吸引了来自全国和世界各地的人们前来探索。|
25
+
26
+ 在CSC测试集上生成结果纠错准确率高,由于是基于大模型,结果常常能带给人惊喜,不仅能纠错,还带有句子润色和改写功能。
27
+
28
+
29
+ ## Usage
30
+
31
+ 本项目开源在lmft项目:[lmft](https://github.com/shibing624/lmft),可支持ChatGLM模型,通过如下命令调用:
32
+
33
+ Install package:
34
+ ```shell
35
+ pip install -U lmft
36
+ ```
37
+
38
+ ```python
39
+ from lmft import ChatGlmModel
40
+ model = ChatGlmModel("chatglm", "THUDM/chatglm-6b", lora_name="shibing624/chatglm-6b-belle-zh-lora")
41
+ r = model.predict(["介绍下北京\n答:"])
42
+ print(r) # ['北京是中国的首都,是中国的政治、文化和经济中心。...']
43
+ ```
44
+
45
+ ## Usage (HuggingFace Transformers)
46
+ Without [lmft](https://github.com/shibing624/lmft), you can use the model like this:
47
+
48
+ First, you pass your input through the transformer model, then you get the generated sentence.
49
+
50
+ Install package:
51
+ ```
52
+ pip install transformers
53
+ ```
54
+
55
+ ```python
56
+ import sys
57
+ from peft import PeftModel
58
+ from transformers import AutoModel, AutoTokenizer
59
+
60
+ sys.path.append('..')
61
+
62
+ model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True, device_map='auto')
63
+ model = PeftModel.from_pretrained(model, "shibing624/chatglm-6b-belle-zh-lora")
64
+ model = model.half().cuda() # fp16
65
+ tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True)
66
+
67
+ sents = ['介绍下北京\n答:',]
68
+ for s in sents:
69
+ response = model.chat(tokenizer, s, max_length=128, eos_token_id=tokenizer.eos_token_id)
70
+ print(response)
71
+ ```
72
+
73
+ output:
74
+ ```shell
75
+ 介绍下北京
76
+ 北京是中国的首都,是中国的政治、文化和经济中心。它位于中国的北部,拥有悠久的历史和文化遗产,如故宫、长城和天坛等。北京也是中国最著名的城市之一,有着丰富的美食、文化和娱乐活动。北京还有许多旅游景点,如颐和园、圆明园和天坛等。北京是一个充满活力和机会的城市,吸引了来自全国和世界各地的人们前来探索。
77
+ ```
78
+
79
+
80
+ 模型文件组成:
81
+ ```
82
+ chatglm-6b-belle-zh-lora
83
+ ├── adapter_config.json
84
+ └── adapter_model.bin
85
+ ```
86
+
87
+
88
+ ### 训练数据集
89
+
90
+ 1. 50万条中文ChatGPT指令Belle数据集:[BelleGroup/train_0.5M_CN](https://huggingface.co/datasets/BelleGroup/train_0.5M_CN)
91
+ 2. 100万条中文ChatGPT指令Belle数据集:[BelleGroup/train_1M_CN](https://huggingface.co/datasets/BelleGroup/train_1M_CN)
92
+ 3. 5万条英文ChatGPT指令Alpaca数据集:[50k English Stanford Alpaca dataset](https://github.com/tatsu-lab/stanford_alpaca#data-release)
93
+ 4. 2万条中文ChatGPT指令Alpaca数据集:[shibing624/alpaca-zh](https://huggingface.co/datasets/shibing624/alpaca-zh)
94
+ 5. 69万条中文指令Guanaco数据集(Belle50万条+Guanaco19万条):[Chinese-Vicuna/guanaco_belle_merge_v1.0](https://huggingface.co/datasets/Chinese-Vicuna/guanaco_belle_merge_v1.0)
95
+
96
+
97
+ 如果需要训练ChatGLM模型,请参考[https://github.com/shibing624/lmft](https://github.com/shibing624/lmft)
98
+
99
+
100
+ ## Citation
101
+
102
+ ```latex
103
+ @software{lmft,
104
+ author = {Xu Ming},
105
+ title = {lmft: Implementation of language model finetune},
106
+ year = {2023},
107
+ url = {https://github.com/shibing624/lmft},
108
+ }
109
+ ```
110
+
111
+
112
+