ClueAI commited on
Commit
4fe1145
1 Parent(s): 96b429e

Upload 11 files

Browse files
ChatYuan.jpeg ADDED
README.md CHANGED
@@ -1,3 +1,211 @@
1
  ---
 
 
 
 
 
2
  license: creativeml-openrail-m
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ inference:
3
+ parameters:
4
+ max_length: 250
5
+ temperature: 0.7
6
+ top_p: 1
7
  license: creativeml-openrail-m
8
+ widget:
9
+ - text: 用户:帮我写个请假条,我因为新冠不舒服,需要请假3天,请领导批准\n小元:
10
+ - text: 用户:新冠什么症状?\n小元:新冠是指新型冠状病毒,其症状包括发热、干咳、乏力、嗅味觉减退、呼吸困难等。\n用户:可以吃什么药?\n小元:根据您提供的病史,目前没有明确的抗新冠病毒的药物,建议您在家进行自我隔离,避免与他人接触,多喝开水,清淡易消化饮食,避免熬夜和过度劳累,适当进行户外活动。\n用户:用什么后遗症么?\n小元:
11
  ---
12
+
13
+ ChatYuan: 元语功能型对话大模型V2
14
+
15
+ 这个模型可以用于问答、结合上下文做对话、做各种生成任务,包括创意性写作,也能回答一些像法律、新冠等领域问题。它基于PromptCLUE-large结合数亿条功能对话多轮对话数据进一步训练得到。
16
+
17
+ <a href='https://www.cluebenchmarks.com/clueai.html'>PromptCLUE-large</a>在1000亿token中文语料上预训练,累计学习1.5万亿中文token,并且在数百种任务上进行Prompt任务式训练。针对理解类任务,如分类、情感分析、抽取等,可以自定义标签体系;针对多种生成任务,可以进行采样自由生成。
18
+
19
+ <a href='https://www.clueai.cn/chat' target="__blank">在线Demo(微信搜索小程序“元语智能”)</a> &nbsp; |
20
+ <a href='https://www.clueai.cn' target="__blank">使用API(large版)</a> &nbsp; |
21
+ &nbsp; <a href='https://github.com/clue-ai/ChatYuan' target="__blank">Github项目地址</a>&nbsp; |
22
+ &nbsp;<a href='https://colab.research.google.com/drive/1ZcLIJuemiojigrfjbsDMBWrX7JqXZX6I?usp=sharing' target="__blank">Colab在线试用</a> &nbsp; |
23
+ &nbsp;<a href='https://mp.weixin.qq.com/s/-axa6XcjGl_Koeq_OrDq8w' target="__blank">文章介绍</a>
24
+
25
+
26
+
27
+ ## 期望模型使用方式及适用范围
28
+
29
+ ### 如何使用
30
+
31
+ 在安装完成ModelScope之后即可使用ChatYuan的能力,解决全中文NLP问题
32
+
33
+
34
+ #### 代码范例
35
+
36
+ 加载模型:
37
+ ```python
38
+ from modelscope.pipelines import pipeline
39
+ from modelscope.utils.constant import Tasks
40
+ from modelscope.models.nlp import T5ForConditionalGeneration
41
+ from modelscope.preprocessors import TextGenerationT5Preprocessor
42
+ ```
43
+
44
+ 使用模型进行预测推理方法:
45
+ ```python
46
+ model = T5ForConditionalGeneration.from_pretrained('ClueAI/ChatYuan-large-v2', revision='v1.0.0')
47
+ preprocessor = TextGenerationT5Preprocessor(model.model_dir)
48
+ pipeline_t2t = pipeline(task=Tasks.text2text_generation, model=model, preprocessor=preprocessor)
49
+
50
+ def preprocess(text):
51
+ text = text.replace("\n", "\\n").replace("\t", "\\t")
52
+ return text
53
+
54
+ def postprocess(text):
55
+ return text.replace("\\n", "\n").replace("\\t", "\t")
56
+
57
+ def answer(text, sample=True, top_p=1, temperature=0.7):
58
+ '''sample:是否抽样。生成任务,可以设置为True;
59
+ top_p:0-1之间,生成的内容越多样'''
60
+ text = preprocess(text)
61
+
62
+ if not sample:
63
+ out_text = pipeline_t2t(text, return_dict_in_generate=True, output_scores=False, max_new_tokens=512, num_beams=1, length_penalty=0.6)
64
+ else:
65
+ out_text = pipeline_t2t(text, return_dict_in_generate=True, output_scores=False, max_new_tokens=512, do_sample=True, top_p=top_p, temperature=temperature, no_repeat_ngram_size=3)
66
+
67
+ return postprocess(out_text["text"])
68
+
69
+ ```
70
+ ## 问答、写作与功能型助手
71
+ ```python
72
+
73
+ input_text0 = "帮我写一个请假条,我因为新冠不舒服,需要请假3天,请领导批准"
74
+ input_text1 = "你能干什么"
75
+ input_text2 = "用英文写一封道歉的邮件,表达因为物流延误,不能如期到达,我们可以赔偿贵公司所有损失"
76
+ input_text3 = "写一个文章,题目是未来城市"
77
+ input_text4 = "写一个诗歌,关于冬天"
78
+ input_text5 = "从南京到上海的路线"
79
+ input_text6 = "学前教育专业岗位实习中,在学生方面会存在问题,请提出改进措施。800字"
80
+ input_text7 = "根据标题生成文章:标题:屈臣氏里的化妆品到底怎么样?正文:化妆品,要讲究科学运用,合理搭配。屈臣氏起码是正品连锁店。请继续后面的文字。"
81
+ input_text8 = "帮我对比几款GPU,列出详细参数对比,并且给出最终结论"
82
+ input_list = [input_text0, input_text1, input_text2, input_text3, input_text4, input_text5, input_text6, input_text7, input_text8]
83
+ for i, input_text in enumerate(input_list):
84
+ input_text = "用户:" + input_text + "\n小元:"
85
+ print(f"示例{i}".center(50, "="))
86
+ output_text = answer(input_text)
87
+ print(f"{input_text}{output_text}")
88
+
89
+ ```
90
+
91
+ 问答、生成与创意性写作:
92
+
93
+ =======================示例1========================
94
+ 用户:你能干什么
95
+ 小元:您好!我是元语AI。我可以回答您的问题、写文章、写作业、翻译,对于一些法律等领域的问题我也可以给你提供信息。
96
+ =======================示例2========================
97
+ 用户:写一封英文商务邮件给英国客户,表达因为物流延误,不能如期到达,我们可以赔偿贵公司所有损失
98
+ 小元:
99
+ Dear [Name],
100
+
101
+ I'm sorry to inform you that we have been doing our business to you for your delay. We understand that we can compensate you for your losses due to the delay in our logistics.
102
+
103
+ We understand that we can make sure we can compensate you for your losses due to the delay.
104
+
105
+ Thank you for your understanding and we are very grateful for your efforts.
106
+
107
+ Sincerely,
108
+
109
+ [Your Name]
110
+ =======================示例3========================
111
+ 用户:写一个文章,题目是未来城市
112
+ 小元:未来的城市是怎样的呢?
113
+
114
+ 未来城市拥有很多不同的功能,如智慧城市、智能交通系统、远程医疗系统、智能家居系统、智慧医疗系统等。未来城市还使用物联网技术,可以远程控制,使用远程操控和传感器来监控城市的发展,帮助他们解决各种城市问题。
115
+
116
+ 未来的城市还采用互联网技术,可以让城市变得更智能,让城市变得更智慧,让每一个人都能更轻松地生活。未来城市的智能设备也可以让城市的使用者更方便地掌握他们的生活,比如智能的智能交通系统和远程医疗系统和智能的安防系统等,可以提供他们更多的便利。
117
+ 总之,未来城市的愿景是,让所有城市的使用者都能拥有一个美好的未来,让他们可以在自己的城市享受美好的生活。
118
+ =======================示例4========================
119
+ 用户:写一个诗歌,关于冬天
120
+ 小元:冬夜寂静冷,
121
+ 云在天边飘,
122
+ 冰封白雪上,
123
+ 寒冷像一场雪。
124
+
125
+ 雪花融化成冰,
126
+ 像那雪花飘洒,
127
+ 在寒冷的冬天,
128
+ 感受春天的喜悦。
129
+ 冬日里,
130
+ 风雪渐消,
131
+ 一片寂静,
132
+ 把快乐和温暖带回家。
133
+ =======================示例5========================
134
+ 用户:从南京到上海的路线
135
+ 小元:你好,南京到上海的路线如下:
136
+
137
+ 1. 南京到上海,可以乘坐南京地铁1号线,在南京站乘坐轨道交通1号线。
138
+
139
+ 2. 南京到浦东机场,可以搭乘上海地铁1号,在陆家嘴站乘坐地铁1线,在浦东国际机场站乘坐机场快线,前往上海浦东国际机场。
140
+
141
+ 3. 上海到南京,可以换乘上海地铁2号线,从南京站换乘地铁2线,再从南京南站换乘地铁1路,然后到达上海站。
142
+
143
+ =======================示例6========================
144
+ 用户:学前教育专业岗位实习中,在学生方面会存在问题,请提出改进措施。800字
145
+ 小元:在学前教育专业岗位实习中,在学生方面会存在一些问题,如学生缺少专业知识、缺乏合作意识、缺乏基本的责任心等等,需要我们采取措施,来解决这些问题。
146
+
147
+ 首先,在实习过程中,我们需要培养学生的团队意识,加强学生与老师之间的合作,加强与家长之间的沟通,提高他们的沟通能力。另外,我们也需要加强学生的独立性,让学生学会独立思考,学会和老师、家长进行沟通,培养其独立性。
148
+ 此外,在日常的工作中,我们也要为学生提供适当的机会和机会,让学生多接触社会、多参加社会活动,加深他们对社会、学校的认识,培养他们主动、积极和创新的精神。
149
+ 最后,我们还需要重视学生在实习中出现的问题,尤其是学生缺乏合作,有依赖心理,不懂得分享,有拖延行为等,这些学生应该引起我们的重视,制定合理的改进措施,改善这些问题。
150
+ =======================示例7========================
151
+ 用户:根据标题生成文章:屈臣氏里的化妆品到底怎么样?
152
+ 小元:近日,一条关于屈臣氏化妆品的微博引发网友热议。“在屈臣士商场里,有一些护肤品售价动辄上千元,部分化妆品甚至还卖到几折。屈臣仕化妆品专柜工作人员表示:“屈臣购商城的化妆品都是正规厂家生产,都是通过国家药品监督管理局的正规渠道进入市场的,并且都是正品。”“该微博发出后,引起网友们的热议,甚至不少网友开始搜索屈臣氏旗舰店来买产品。“屈氏化妆品真的值得买吗?“记者在屈士仕商场内看到,屈臣专卖店的货架上摆满了屈臣旗下的各种化妆品,有精华、面霜、眼霜等。““屈士士,这一款我买了,这款是主打美白的。”市民王女士说,她去年买了三瓶屈臣芮,其中一款是保湿面膜,还有一款是护手霜。“记者通过电话联系了屈臣臣芮的销售小姐,她说屈臣城里没有卖屈臣诗的化妆品,只有屈臣肌妍的化妆品。“
153
+ =======================示例8========================
154
+ 用户:帮我对比几款GPU,列出详细参数对比,并且给出最终结论
155
+ 小元:一、显存容量:
156
+
157
+ 1 GeForce GTX 880 显存类型:GDDR5
158
+ 2 Geforce RTX 1060 显存在类型:PhysX物理加速
159
+ 3 Ge force MX150 显存在于类型:SLI
160
+ 4 GetoDirectX 11:支持DX11
161
+ 二、显显存带宽:
162
+ 1.GDDR4X 显显容量:256MB
163
+ 2.GDDR6X 最大显存范围:8GB
164
+ 3.GDDR3 显在带宽:120GB
165
+ 4.GDDR7 显适用于2GB显存
166
+ 三、显效时间:
167
+ 1.4 GB/s
168
+ 2. 5.5 ms
169
+ 3. 5 ms
170
+
171
+
172
+ ## 主要更新
173
+
174
+ 在chatyuan-large-v1的原有功能的基础上,我们给模型进行了如下优化:
175
+ - 增强了原有问答、生成与创意性写作功能
176
+ - 安全拒答,对于一些不安全,危险的问题,做了拒答处理
177
+ - 增强了代码功能
178
+ - 增强了表格生成的功能,使生成的表格更适配
179
+ - 增强了基础数学运算的功能
180
+
181
+ ### 安全拒答
182
+
183
+
184
+ ## 多轮对话
185
+
186
+ ```python
187
+ input_text = ["你好","新冠什么症状?","可以吃什么药?"]
188
+ answer_text = ["您好!我是元语AI。我可以回答您的问题、写文章、写作业、翻译,对于一些法律等领域的问题我也可以给你提供信息", "新冠是指新型冠状病毒,其症状包括发热、干咳、乏力、嗅味觉减退、呼吸困难等。", "根据您提供的病史,目前没有明确的抗新冠病毒的药物,建议您在家进行自我隔离,避免与他人接触,多喝开水,清淡易消化饮食,避免熬夜和过度劳累,适当进行户外活动。"]
189
+ context = "\n".join([f"用户:{input_text[i]}\n小元:{answer_text[i]}" for i in range(len(input_text))])
190
+ print(context)
191
+
192
+ input_text = "用什么后遗症么?"
193
+ print(f"示例".center(50, "="))
194
+ input_text = context + "\n用户:" + input_text + "\n小元:"
195
+ output_text = answer(input_text)
196
+ print(f"{input_text}{output_text}")
197
+
198
+
199
+ ```
200
+ ========================示例========================
201
+ 用户:你好.
202
+ 小元:您好!我是元语AI。我可以回答您的问题、写文章、写作业、翻译,对于一些法律等领域的问题我也可以给你提供信息.
203
+ 用户:新冠什么症状?
204
+ 小元:新冠是指新型冠状病毒,其症状包括发热、干咳、乏力、嗅味觉减退、呼吸困难等。
205
+ 用户:可以吃什么药?
206
+ 小元:根据您提供的病史,目前没有明确的抗新冠病毒的药物,建议您在家进行自我隔离,避免与他人接触,多喝开水,清淡易消化饮食,避免熬夜和过度劳累,适当进行户外活动。
207
+ 用户:用什么后遗症么?
208
+ 小元:目前还没有人具体说是什么后遗症,但是目前症状比较轻的,可能没有后遗症,但是如果症状比较重,就可能出现呼吸困难,胸闷,发热,咳嗽等症状。
209
+
210
+
211
+ <center><a href="https://clustrmaps.com/site/1bsr9" title="Visit tracker"><img src="//www.clustrmaps.com/map_v2.png?d=j3DXKxFPrX7nY81AhJ7i6nPFDTA_q-gfSMhRR1rVS9c&cl=ffffff" /></a><center>
brightmart.jpeg ADDED
chatyuan_wechat.jpeg ADDED
config.json ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "Yuan-large-v2",
3
+ "architectures": [
4
+ "T5ForConditionalGeneration"
5
+ ],
6
+ "d_ff": 2816,
7
+ "d_kv": 64,
8
+ "d_model": 1024,
9
+ "decoder_start_token_id": 0,
10
+ "dense_act_fn": "gelu_new",
11
+ "dropout_rate": 0.1,
12
+ "eos_token_id": 1,
13
+ "feed_forward_proj": "gated-gelu",
14
+ "initializer_factor": 1.0,
15
+ "is_encoder_decoder": true,
16
+ "is_gated_act": true,
17
+ "layer_norm_epsilon": 1e-06,
18
+ "model_type": "t5",
19
+ "num_decoder_layers": 24,
20
+ "num_heads": 16,
21
+ "num_layers": 24,
22
+ "output_past": true,
23
+ "pad_token_id": 0,
24
+ "relative_attention_max_distance": 128,
25
+ "relative_attention_num_buckets": 32,
26
+ "tie_word_embeddings": false,
27
+ "torch_dtype": "float16",
28
+ "transformers_version": "4.24.0",
29
+ "use_cache": true,
30
+ "vocab_size": 32128
31
+ }
configuration.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "framework": "pytorch",
3
+ "task": "text2text-generation",
4
+ "model": {
5
+ "type": "T5",
6
+ "language": "zh"
7
+ },
8
+ "pipeline": {
9
+ "type": "text2text-generation"
10
+ }
11
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "decoder_start_token_id": 0,
4
+ "eos_token_id": 1,
5
+ "pad_token_id": 0,
6
+ "transformers_version": "4.28.0.dev0"
7
+ }
pytorch_model.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee1eb0b0c51f2d78d83b92ac27d9d0c59ac78dc8c292674c9910596f6c028fe6
3
+ size 1566481701
spiece.model ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5c2083a4dd8b56e99db4a408d68a50d4374252628247dbdc9d5931fddcf0a66d
3
+ size 742045
spiece.vocab ADDED
The diff for this file is too large to render. See raw diff
tokenizer_config.json ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "eos_token": "</s>",
3
+ "unk_token": "<unk>",
4
+ "pad_token": "<pad>",
5
+ "extra_ids": 100,
6
+ "additional_special_tokens": ["<extra_id_0>", "<extra_id_1>", "<extra_id_2>", "<extra_id_3>", "<extra_id_4>", "<extra_id_5>", "<extra_id_6>", "<extra_id_7>", "<extra_id_8>", "<extra_id_9>", "<extra_id_10>", "<extra_id_11>", "<extra_id_12>", "<extra_id_13>", "<extra_id_14>", "<extra_id_15>", "<extra_id_16>", "<extra_id_17>", "<extra_id_18>", "<extra_id_19>", "<extra_id_20>", "<extra_id_21>", "<extra_id_22>", "<extra_id_23>", "<extra_id_24>", "<extra_id_25>", "<extra_id_26>", "<extra_id_27>", "<extra_id_28>", "<extra_id_29>", "<extra_id_30>", "<extra_id_31>", "<extra_id_32>", "<extra_id_33>", "<extra_id_34>", "<extra_id_35>", "<extra_id_36>", "<extra_id_37>", "<extra_id_38>", "<extra_id_39>", "<extra_id_40>", "<extra_id_41>", "<extra_id_42>", "<extra_id_43>", "<extra_id_44>", "<extra_id_45>", "<extra_id_46>", "<extra_id_47>", "<extra_id_48>", "<extra_id_49>", "<extra_id_50>", "<extra_id_51>", "<extra_id_52>", "<extra_id_53>", "<extra_id_54>", "<extra_id_55>", "<extra_id_56>", "<extra_id_57>", "<extra_id_58>", "<extra_id_59>", "<extra_id_60>", "<extra_id_61>", "<extra_id_62>", "<extra_id_63>", "<extra_id_64>", "<extra_id_65>", "<extra_id_66>", "<extra_id_67>", "<extra_id_68>", "<extra_id_69>", "<extra_id_70>", "<extra_id_71>", "<extra_id_72>", "<extra_id_73>", "<extra_id_74>", "<extra_id_75>", "<extra_id_76>", "<extra_id_77>", "<extra_id_78>", "<extra_id_79>", "<extra_id_80>", "<extra_id_81>", "<extra_id_82>", "<extra_id_83>", "<extra_id_84>", "<extra_id_85>", "<extra_id_86>", "<extra_id_87>", "<extra_id_88>", "<extra_id_89>", "<extra_id_90>", "<extra_id_91>", "<extra_id_92>", "<extra_id_93>", "<extra_id_94>", "<extra_id_95>", "<extra_id_96>", "<extra_id_97>", "<extra_id_98>", "<extra_id_99>"],
7
+ "model_max_length": 512,
8
+ "name_or_path": "t5-base"
9
+ }