Safetensors
qwen2
TomPei commited on
Commit
abf827b
·
verified ·
1 Parent(s): 10195dd

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +172 -0
README.md ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - Jiayi-Pan/Countdown-Tasks-3to4
5
+ base_model:
6
+ - Qwen/Qwen2.5-7B-Instruct
7
+ ---
8
+ # **OpenCSG-R1-Qwen2.5-Math-7B-V1** [[中文]](#chinese) [[English]](#english)
9
+
10
+ <a id="english"></a>
11
+
12
+ <p align="center">
13
+ <img width="300px" alt="OpenCSG" src="https://cdn-uploads.huggingface.co/production/uploads/64c71b27d43e4dee51a8b31a/GwYXPKuEoGCGcMICeW-sb.jpeg">
14
+ </p>
15
+
16
+ <p align="center"><a href="https://portal.opencsg.com/models">[OpenCSG Community]</a> <a href="https://github.com/opencsgs">[github]</a> <a href="https://cdn-uploads.huggingface.co/production/uploads/64c71b27d43e4dee51a8b31a/HU6vz21qKTEmUBCWqCFh9.jpeg">[wechat]</a> <a href="https://twitter.com/OpenCsg">[Twitter]</a> </p>
17
+
18
+
19
+ </div>
20
+ OpenCSG stands for Converged resources, Software refinement, and Generative LM. The 'C' represents Converged resources, indicating the integration and full utilization of hybrid resources. The 'S' stands for Software refinement, signifying software that is refined by large models. The 'G' represents Generative LM, which denotes widespread, inclusive, and democratized generative large models.
21
+
22
+ The vision of OpenCSG is to empower every industry, every company, and every individual to own their models. We adhere to the principles of openness and open source, making the large model software stack of OpenCSG available to the community. We welcome everyone to use, send feedback, and contribute collaboratively.
23
+
24
+
25
+
26
+
27
+
28
+ # Model Usage
29
+
30
+
31
+ ```python
32
+ from transformers import AutoTokenizer
33
+ import transformers
34
+ import torch
35
+
36
+ model_name = "opencsg/OpenCSG-R1-Qwen2.5-Math-7B-V1"
37
+ model = AutoModelForCausalLM.from_pretrained(
38
+ model_name,
39
+ torch_dtype="auto",
40
+ device_map="auto"
41
+ )
42
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
43
+
44
+ messages = [
45
+ {
46
+ "role": "user",
47
+ "content": f"请你帮我用因式分解拆解123958102这个数字。在 <think> </think> 标签中输出思考过程,并在 <answer> </answer> 标签中返回最终结果,例如 <answer> (1 + 2) / 3 </answer>。在 <think> 标签中逐步思考。",
48
+ },
49
+ {
50
+ "role": "assistant",
51
+ "content": "让我们逐步解决这个问题。\n<think>",
52
+ },
53
+ ]
54
+ text = tokenizer.apply_chat_template(
55
+ messages,
56
+ tokenize=False,
57
+ continue_final_message=True,
58
+ # add_generation_prompt=True
59
+ )
60
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
61
+
62
+ generated_ids = model.generate(
63
+ **model_inputs,
64
+ max_new_tokens=512,
65
+ temperature=0.6
66
+ )
67
+ generated_ids = [
68
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
69
+ ]
70
+
71
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
72
+ ```
73
+
74
+
75
+ # Training
76
+
77
+ ## Hardware
78
+
79
+ - **GPUs:** 8 Tesla A800
80
+ - **Training time:** 7 hours
81
+
82
+ ## Software
83
+
84
+ - **Orchestration:** [Deepspeed](https://github.com/OpenCSGs)
85
+ - **Neural networks:** [PyTorch](https://github.com/pytorch/pytorch)
86
+ - **BP16 if applicable:** [apex](https://github.com/NVIDIA/apex)
87
+
88
+
89
+ <a id="chinese"></a>
90
+
91
+ <p>
92
+
93
+ </p>
94
+
95
+ # OpenCSG介绍
96
+
97
+
98
+ <p align="center">
99
+ <img width="300px" alt="OpenCSG" src="https://cdn-uploads.huggingface.co/production/uploads/64c71b27d43e4dee51a8b31a/GwYXPKuEoGCGcMICeW-sb.jpeg">
100
+ </p>
101
+
102
+ <p align="center"><a href="https://opencsg.com/models">[OpenCSG 社区]</a> <a href="https://github.com/opencsgs">[github]</a> <a href="https://cdn-uploads.huggingface.co/production/uploads/64c71b27d43e4dee51a8b31a/HU6vz21qKTEmUBCWqCFh9.jpeg">[微信]</a> <a href="https://twitter.com/OpenCsg">[推特]</a> </p>
103
+
104
+
105
+
106
+ </div>
107
+ OpenCSG中 Open是开源开放;C 代表 Converged resources,整合和充分利用的混合异构资源优势,算力降本增效;S 代表 Software refined,重新定义软件的交付方式,通过大模型驱动软件开发,人力降本增效;G 代表 Generative LM,大众化、普惠化和民主化的可商用的开源生成式大模型。
108
+
109
+ OpenCSG的愿景是让每个行业、每个公司、每个人都拥有自己的模型。 我们坚持开源开放的原则,将OpenCSG的大模型软件栈开源到社区,欢迎使用、反馈和参与共建,欢迎关注。
110
+
111
+
112
+
113
+
114
+ # 模型使用
115
+
116
+
117
+ ```python
118
+ from transformers import AutoTokenizer
119
+ import transformers
120
+ import torch
121
+
122
+ model_name = "opencsg/OpenCSG-R1-Qwen2.5-Math-7B-V1"
123
+ model = AutoModelForCausalLM.from_pretrained(
124
+ model_name,
125
+ torch_dtype="auto",
126
+ device_map="auto"
127
+ )
128
+ tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
129
+
130
+ messages = [
131
+ {
132
+ "role": "user",
133
+ "content": f"请你帮我用因式分解拆解123958102这个数字。在 <think> </think> 标签中输出思考过程,并在 <answer> </answer> 标签中返回最终结果,例如 <answer> (1 + 2) / 3 </answer>。在 <think> 标签中逐步思考。",
134
+ },
135
+ {
136
+ "role": "assistant",
137
+ "content": "让我们逐步解决这个问题。\n<think>",
138
+ },
139
+ ]
140
+ text = tokenizer.apply_chat_template(
141
+ messages,
142
+ tokenize=False,
143
+ continue_final_message=True,
144
+ # add_generation_prompt=True
145
+ )
146
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
147
+
148
+ generated_ids = model.generate(
149
+ **model_inputs,
150
+ max_new_tokens=512,
151
+ temperature=0.6
152
+ )
153
+ generated_ids = [
154
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
155
+ ]
156
+
157
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
158
+ ```
159
+
160
+
161
+ # 训练
162
+
163
+ ## 硬件资源
164
+
165
+ - **GPU数量:** 8 Tesla A800
166
+ - **训练时间:** 12 小时
167
+
168
+ ## 软件使用
169
+
170
+ - **微调训练框架:** [Deepspeed](https://github.com/OpenCSGs)
171
+ - **深度学习框架:** [PyTorch](https://github.com/pytorch/pytorch)
172
+ - **BP16:** [apex](https://github.com/NVIDIA/apex)