ycjcl868 commited on
Commit
819a01b
1 Parent(s): d636ed0

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +202 -0
README.md ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: gemma
3
+ widget:
4
+ - messages:
5
+ - role: user
6
+ content: 大脑是如何工作的?
7
+ inference:
8
+ parameters:
9
+ max_new_tokens: 2048
10
+ language:
11
+ - en
12
+ - zh
13
+ library_name: transformers
14
+ pipeline_tag: text-generation
15
+ tags:
16
+ - gemma
17
+ - chinese
18
+ - sft
19
+ ---
20
+
21
+ # Updates
22
+ - [June 04, 2024] 🌈 Add more Chinese training data to improve Chinese performance
23
+ - [May 23, 2024] 🔥 Support function calling
24
+
25
+
26
+ # Model Summary
27
+
28
+ [Gemma-1.1-7B-Chinese-Chat](https://huggingface.co/ycjcl868/Gemma-1.1-7B-Chinese-Chat) is an instruction-tuned language model for Chinese & English users built upon the gemma-1.1-7b-it model.([Github](https://github.com/ycjcl868/Gemma-1.1-7B-Chinese-Chat/tree/main))
29
+
30
+ Developed by: [ycjcl868](https://github.com/ycjcl868)
31
+
32
+ - License: [Gemma License](https://www.kaggle.com/models/google/gemma/license/consent)
33
+ - Base Model: gemma-1.1-7b-it
34
+ - Model Size: 8.54B
35
+ - Context length: 8K
36
+
37
+ # Introduction
38
+
39
+ This is the first model specifically fine-tuned for Chinese & English user through SFT based on the [gemma-1.1-7b-it model](https://huggingface.co/google/gemma-1.1-7b-it).
40
+
41
+ **Compared to the original [gemma-1.1-7b-it model](https://huggingface.co/google/gemma-1.1-7b-it), our Gemma-1.1-7B-Chinese-Chat model significantly reduces the issues of "Chinese questions with English answers" and the mixing of Chinese and English in responses.**
42
+
43
+ Training details:
44
+
45
+ - epochs: 3
46
+ - learning rate: 0.0001
47
+ - learning rate scheduler type: cosine
48
+ - Warmup ratio: 0.1
49
+ - cutoff len (i.e. context length): 8192
50
+ - global batch size: 2
51
+
52
+ <br />
53
+
54
+ # Usage
55
+
56
+ ## Chat Template
57
+
58
+ The instruction-tuned models use a chat template that must be adhered to for conversational use.
59
+ The easiest way to apply it is using the tokenizer's built-in chat template, as shown in the following snippet.
60
+
61
+ Let's load the model and apply the chat template to a conversation. In this example, we'll start with a single user interaction:
62
+
63
+ ```py
64
+ from transformers import AutoTokenizer, AutoModelForCausalLM
65
+ import transformers
66
+ import torch
67
+
68
+ model_id = "ycjcl868/Gemma-1.1-7B-Chinese-Chat"
69
+
70
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
71
+ model = AutoModelForCausalLM.from_pretrained(
72
+ model_id,
73
+ device_map="auto",
74
+ torch_dtype="auto",
75
+ )
76
+
77
+ messages = [
78
+ { "role": "user", "content": "写一首诗" },
79
+ ]
80
+ input_ids = tokenizer.apply_chat_template(
81
+ messages, add_generation_prompt=True, return_tensors="pt"
82
+ ).to(model.device)
83
+
84
+ outputs = model.generate(
85
+ input_ids,
86
+ max_new_tokens=8192,
87
+ do_sample=True,
88
+ temperature=0.6,
89
+ top_p=0.9,
90
+ )
91
+ response = outputs[0][input_ids.shape[-1]:]
92
+ print(tokenizer.decode(response, skip_special_tokens=True))
93
+
94
+ # 春风拂柳,春雨轻轻,
95
+ # 花香满园,鸟鸣清脆。
96
+ # 一朵红梅,红彤彤的,
97
+ # 美不胜收,美不胜收。
98
+ ```
99
+
100
+ # Examples
101
+
102
+ ```
103
+ User: 参加四年级数学竞赛同学中,男同学获奖人数比女同学多2人,女同学获奖人数比男同学人数的一半多2人,男女同学各有多少人获奖?
104
+ Assistant:
105
+ 设男同学的获奖人数
106
+ 为x,则女同学的获奖人数为y,所以有以下两式:
107
+ x=y+2
108
+ y=2(x+2)
109
+ 将第一式代入第二式中,得:
110
+ y=2(y+2)+2
111
+ y=2y+4+2
112
+ y=2y+6
113
+ 2y=y+6
114
+ y=6
115
+ 因此,女同学获奖人数为6人,男同学获奖人数为8人。
116
+ ```
117
+
118
+ ```
119
+ User: 我的蓝牙耳机坏了,我应该去看耳鼻喉科还是牙科?
120
+ Assistant: 蓝牙耳机是属于电子产品的,而不是耳鼻喉科或牙科的范畴。如果你怀疑耳机有故障,建议去电子产品维修店或者原厂维修中心进行检查。如果需要新的耳机,你也可以去电器商店或电子产品市场购买。
121
+ ```
122
+
123
+ ```
124
+ User: 来几句成语
125
+ Assistant: “一日三尺”是指过时间一切都会改变。
126
+ ```
127
+
128
+ ```
129
+ User: 列出5种可以改善睡眠质量的方法
130
+ Assistant:
131
+ 1. 保持规律的睡眠时间表
132
+ 2. 避免下午摄入咖啡因
133
+ 3. 避免睡前摄入酒精
134
+ 4. 避免睡前摄入高糖饮食
135
+ 5. 每天至少进行30分钟的运动
136
+ ```
137
+
138
+ ```
139
+ User: 回答一个开放性的问题:人类存在的意义是什么?
140
+ Assistant: 人类存在的意义是一个复杂的哲学和哲学问题,因为人类存在于自然界中,我们作为人类有责任和义务来保护地球和生物,而我们作为人类也有责任来发展自己的精神和思想,来创造更好的未来。
141
+ 我从哲学角度来看,人类存在的意义是通过我们自己的思想和行动,来实现我们对精神和精神的追求。通过我们自己的努力和创造力,我们可以创造出更多的艺术、文化和思想,来促进人类的进步和发展。
142
+ ```
143
+
144
+ ```
145
+ User: 解释以下缩写: JSON、CEO、PDF、HTML、NASA
146
+ Assistant:
147
+ JSON(JavaScript Object Notation):JavaScript对象的表示法,用来在JavaScript和许多其他编程语言之间传递数据。
148
+ CEO(Chief Executive Officer):首席执行官,指企业的高级管理人员,通常是指企业的主席或总裁。
149
+ PDF(Portable Document Format):可移植���档格式,是一种电子文档格式,可以确保文档在不同的操作系统���设备上都能以一致的方式呈现。
150
+ HTML(HyperText Markup Language):超文本标记语言,是网页内容的标记语言,用来定义网页的结构和内容。
151
+ NASA(National Aeronautics and Space Administration):美国国家航空航天局,是美国政府的宇航机构,负责美国在太空和航空方面的研究和发展。
152
+ ```
153
+
154
+ ## Function call
155
+
156
+ **User**:
157
+ ````
158
+ 以下是您可以使用的工具列表:
159
+
160
+ ```python
161
+ def internet_search(query: str):
162
+ \"\"\"
163
+ Returns a list of relevant document snippets for a textual query retrieved from the internet
164
+
165
+ Args:
166
+ query (str): Query to search the internet with
167
+ \"\"\"
168
+ pass
169
+ ```
170
+
171
+ ```python
172
+ def directly_answer():
173
+ \"\"\"
174
+ Calls a standard (un-augmented) AI chatbot to generate a response given the conversation history
175
+ \"\"\"
176
+ pass
177
+ ```
178
+
179
+ 写 'Action:',后跟要调用的 JSON 中的操作列表,例如.
180
+ Action:
181
+ ```json
182
+ [
183
+ {
184
+ "tool_name": "tool name (one of [internet_search, directly_answer])",
185
+ "parameters": "the input to the tool"
186
+ }
187
+ ]
188
+ ```
189
+
190
+ 帮我找到今天的新闻有哪些:
191
+ ````
192
+
193
+ **Response**:
194
+ ```
195
+ Action:
196
+ [
197
+ {
198
+ "tool_name": "internet_search",
199
+ "parameters": "今天有哪些新闻"
200
+ }
201
+ ]
202
+ ```