Jintao Huang commited on
Commit
3495545
1 Parent(s): 6021650

first commit

Browse files
.gitattributes CHANGED
@@ -1,35 +1,34 @@
1
  *.7z filter=lfs diff=lfs merge=lfs -text
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
 
4
  *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
  *.ftz filter=lfs diff=lfs merge=lfs -text
7
  *.gz filter=lfs diff=lfs merge=lfs -text
8
  *.h5 filter=lfs diff=lfs merge=lfs -text
9
  *.joblib filter=lfs diff=lfs merge=lfs -text
10
  *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
  *.model filter=lfs diff=lfs merge=lfs -text
13
  *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
  *.onnx filter=lfs diff=lfs merge=lfs -text
17
  *.ot filter=lfs diff=lfs merge=lfs -text
18
  *.parquet filter=lfs diff=lfs merge=lfs -text
19
  *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
  *.pt filter=lfs diff=lfs merge=lfs -text
23
  *.pth filter=lfs diff=lfs merge=lfs -text
24
  *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
  *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
  *.tflite filter=lfs diff=lfs merge=lfs -text
30
  *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
  *.xz filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
1
  *.7z filter=lfs diff=lfs merge=lfs -text
2
  *.arrow filter=lfs diff=lfs merge=lfs -text
3
  *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bin.* filter=lfs diff=lfs merge=lfs -text
5
  *.bz2 filter=lfs diff=lfs merge=lfs -text
 
6
  *.ftz filter=lfs diff=lfs merge=lfs -text
7
  *.gz filter=lfs diff=lfs merge=lfs -text
8
  *.h5 filter=lfs diff=lfs merge=lfs -text
9
  *.joblib filter=lfs diff=lfs merge=lfs -text
10
  *.lfs.* filter=lfs diff=lfs merge=lfs -text
 
11
  *.model filter=lfs diff=lfs merge=lfs -text
12
  *.msgpack filter=lfs diff=lfs merge=lfs -text
 
 
13
  *.onnx filter=lfs diff=lfs merge=lfs -text
14
  *.ot filter=lfs diff=lfs merge=lfs -text
15
  *.parquet filter=lfs diff=lfs merge=lfs -text
16
  *.pb filter=lfs diff=lfs merge=lfs -text
 
 
17
  *.pt filter=lfs diff=lfs merge=lfs -text
18
  *.pth filter=lfs diff=lfs merge=lfs -text
19
  *.rar filter=lfs diff=lfs merge=lfs -text
 
20
  saved_model/**/* filter=lfs diff=lfs merge=lfs -text
21
  *.tar.* filter=lfs diff=lfs merge=lfs -text
 
22
  *.tflite filter=lfs diff=lfs merge=lfs -text
23
  *.tgz filter=lfs diff=lfs merge=lfs -text
 
24
  *.xz filter=lfs diff=lfs merge=lfs -text
25
  *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *.tfevents* filter=lfs diff=lfs merge=lfs -text
28
+ *.db* filter=lfs diff=lfs merge=lfs -text
29
+ *.ark* filter=lfs diff=lfs merge=lfs -text
30
+ **/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
31
+ **/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
32
+ **/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
33
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
34
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
LOGO.png ADDED
MODEL_LICENSE.md ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # CodeFuse COMMUNITY LICENSE AGREEMENT
2
+ CodeFuse Release Date: September 8, 2023
3
+
4
+ By clicking to agree or by using or distributing any portion or element of the Materials, you will be deemed to have recognized and accepted the content of this Agreement, which is effective immediately.
5
+
6
+ 1. Definitions.
7
+ a. This CodeFuse COMMUNITY LICENSE AGREEMENT (this "Agreement") shall mean the terms and conditions for use, reproduction, distribution and modification of the Materials as defined by this Agreement.
8
+ b. "Ant" or "We" (or "Us") shall mean Ant Group.
9
+ c. "CodeFuse" shall mean the large language models (including CodeFuse-13B and CodeFuse-CodeLlaMa-34B), and software and algorithms, consisting of trained model weights, parameters (including optimizer states), machine-learning model code, and other elements of the foregoing distributed by Us.
10
+ d. "Documentation" shall mean the specifications, manuals and documentation accompanying CodeFuse distributed by Us.
11
+ e. "Materials" shall mean, collectively, Ant's proprietary CodeFuse and Documentation (and any portion thereof) made available under this Agreement.
12
+ f. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
13
+ g. "Source" form shall mean the preferred form for making modifications, including but not limited to model source code, documentation source, and configuration files.
14
+ h. "Third Parties" (or "Third Party") shall mean individuals or legal entities that are not controlling, controlled by Us or You, or under common control with Us or You.
15
+ i. "You" (or "Your") shall mean a natural person or legal entity exercising the rights granted by this Agreement and/or using the Materials for any purpose and in any field of use.
16
+
17
+ 2. Grant of Rights.
18
+ You are granted a non-exclusive, worldwide, non-transferable and royalty-free limited license under Ant's intellectual property or other rights owned by Ant embodied in the Materials to use, reproduce, distribute, copy, create derivative works of, and make modifications to the Materials.
19
+
20
+ 3. Redistribution.
21
+ You may distribute or make the Materials or derivative works thereof available to a Third Party in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
22
+ a. You shall provide a copy of this Agreement to such Third Party;
23
+ b. if You modify the CodeFuse model, You shall provide a prominent notice, stating how You have modified the CodeFuse model, to such Third Party; and
24
+ c. You shall retain in all copies of the Materials that You distribute the following attribution notices within a "Notice" text file distributed as a part of such copies: "CodeFuse is licensed under the CodeFuse COMMUNITY LICENSE AGREEMENT, Copyright (c) Ant Group. All Rights Reserved."
25
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such derivative works as a whole, provided Your use, reproduction, and distribution of the work otherwise complies with the terms and conditions of this Agreement.
26
+
27
+ 4. Rules of Use.
28
+ You shall comply with applicable laws and regulations (including without limitation export controls or restrictions) in Your use of the Materials.
29
+
30
+ 5. Intellectual Property.
31
+ a. Ant retains ownership of all intellectual property rights in and to the Materials and derivatives made by or for Ant. Conditioned upon compliance with the terms and conditions of this Agreement, with respect to any derivative works and modifications of the Materials that are made by You, You are and will be the owner of such derivative works and modifications.
32
+ b. No trademark license is granted to use the trade names, trademarks, service marks, or product names of Ant, except as required to fulfill notice requirements under this Agreement or as required for reasonable and customary use in describing and redistributing the Materials.
33
+ c. If You commence a lawsuit or other proceedings (including a cross-claim or counterclaim in a lawsuit) against Ant or any entity alleging that the Materials or any output therefrom, or any part of the foregoing, infringe any intellectual property or other right owned or licensable by You, then all licences granted to You under this Agreement shall terminate as of the date such lawsuit or other proceeding is commenced or brought.
34
+
35
+ 6. Disclaimer of Warranty and Limitation of Liability.
36
+ a. Ant is not obligated to support, update, provide training for, or develop any further version of the Materials or to grant any license thereto.
37
+ b. THE MATERIALS ARE PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTY OF ANY KIND INCLUDING WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, OR FITNESS FOR A PARTICULAR PURPOSE. WE MAKE NO WARRANTY AND ASSUME NO RESPONSIBILITY FOR THE SAFETY OR STABILITY OF THE MATERIALS AND ANY OUTPUT THEREFROM.
38
+ c. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING OR REDISTRIBUTING THE MATERIALS AND ASSUME ANY RISKS ASSOCIATED WITH YOUR USE OF THE MATERIALS AND ANY OUTPUT AND RESULTS. IN NO EVENT SHALL WE BE LIABLE TO YOU FOR ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, TORT, NEGLIGENCE, PRODUCTS LIABILITY, OR OTHERWISE, ARISING OUT OF THIS AGREEMENT OR ARISING FROM YOUR USE OR INABILITY TO USE THE MATERIALS OR ANY OUTPUT OF IT, FOR ANY DIRECT, OR INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL, EXEMPLARY OR PUNITIVE DAMAGES, NO MATTER HOW IT'S CAUSED OR EVEN IF ANT OR ITS AFFILIATES HAVE BEEN ADVISED OF THE POSSIBILITY OF ANY OF THE FOREGOING.
39
+ d. You will defend, indemnify and hold harmless Ant from and against any claim by any Third Party arising out of or related to Your use or distribution of the Materials.
40
+
41
+ 7. Survival and Termination.
42
+ a. The term of this Agreement shall commence upon Your acceptance of this Agreement or access to the Materials and will continue in full force and effect until terminated in accordance with the terms and conditions herein.
43
+ b. We may terminate this Agreement if You breach any of the terms or conditions of this Agreement. Upon termination of this Agreement, You must delete and cease use of the Materials. Sections 6 and 8 shall survive the termination of this Agreement.
44
+
45
+ 8. Governing Law and Jurisdiction.
46
+ a. This Agreement and any dispute arising out of or relating to it, whether in contract, tort, negligence, products liability, or otherwise, will be governed by the laws of China, without regard to conflict of law principles, and the UN Convention on Contracts for the International Sale of Goods does not apply to this Agreement.
47
+ b. The People's Courts in Hangzhou City shall have exclusive jurisdiction over any dispute arising out of this Agreement.
README.md ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ frameworks:
3
+ - Pytorch
4
+ license: other
5
+ tasks:
6
+ - text-generation
7
+ ---
8
+
9
+ # Model Card for CodeFuse-StarCoder-15B
10
+ ![logo](LOGO.png)
11
+
12
+ [[中文]](#chinese) [[English]](#english)
13
+
14
+
15
+
16
+ <a id="english"></a>
17
+
18
+ ## Model Description
19
+
20
+ CodeFuse-StarCoder-15B is a 15B Code-LLM finetuned by QLoRA of multiple code tasks(600k instrunctions/answers)on the base model StarCoder. CodeFuse-StarCoder-15B is a smaller Code-LLM than our [CodeFuse-CodeLlama-34B](https://modelscope.cn/models/codefuse-ai/CodeFuse-CodeLlama-34B/summary) and using MQA, thus faster on inference.
21
+ The context length of finetuning is 4K.
22
+
23
+ <br>
24
+
25
+ ## News and Updates
26
+
27
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 🔥 2023-09-27 CodeFuse-StarCoder-15B has been released, achieving a pass@1 (greedy decoding) score of 54.9% on HumanEval.
28
+
29
+ 🔥🔥🔥 2023-09-26 We are pleased to announce the release of the [4-bit quantized version](https://modelscope.cn/models/codefuse-ai/CodeFuse-CodeLlama-34B-4bits/summary) of [CodeFuse-CodeLlama-34B](https://modelscope.cn/models/codefuse-ai/CodeFuse-CodeLlama-34B/summary). Despite the quantization process, the model still achieves a remarkable 73.8% accuracy (greedy decoding) on the HumanEval pass@1 metric.
30
+
31
+ 🔥🔥🔥 2023-09-11 [CodeFuse-CodeLlama34B](https://modelscope.cn/models/codefuse-ai/CodeFuse-CodeLlama-34B/summary) has achived 74.4% of pass@1 (greedy decoding) on HumanEval, which is SOTA results for openspurced LLMs at present.
32
+
33
+ <br>
34
+
35
+ ## Code Community
36
+
37
+ **Homepage**: 🏡 https://github.com/codefuse-ai (**Please give us your support with a Star🌟 + Fork🚀 + Watch👀**)
38
+
39
+ + If you wish to fine-tune the model yourself, you can visit ✨[MFTCoder](https://github.com/codefuse-ai/MFTCoder)✨✨
40
+
41
+ + If you wish to deploy the model yourself, you can visit ✨[FasterTransformer4CodeFuse](https://github.com/codefuse-ai/FasterTransformer4CodeFuse)✨✨
42
+
43
+ + If you wish to see a demo of the model, you can visit ✨[CodeFuse Demo](https://github.com/codefuse-ai/codefuse)✨✨
44
+
45
+ <br>
46
+
47
+ ## Performance
48
+
49
+
50
+ | Model | HumanEval(pass@1) | Date |
51
+ |:----------------------------|:-----------------:|:-------:|
52
+ | **CodeFuse-CodeLlama-34B** | **74.4%** | 2023.9 |
53
+ |**CodeFuse-CodeLlama-34B-4bits** | **73.8%** | 2023.9 |
54
+ | WizardCoder-Python-34B-V1.0 | 73.2% | 2023.8 |
55
+ | GPT-4(zero-shot) | 67.0% | 2023.3 |
56
+ | PanGu-Coder2 15B | 61.6% | 2023.8 |
57
+ | CodeLlama-34b-Python | 53.7% | 2023.8 |
58
+ | CodeLlama-34b | 48.8% | 2023.8 |
59
+ | GPT-3.5(zero-shot) | 48.1% | 2022.11 |
60
+ | OctoCoder | 46.2% | 2023.8 |
61
+ | StarCoder-15B | 33.6% | 2023.5 |
62
+ | **CodeFuse-StarCoder-15B** | **54.9%** | 2023.8 |
63
+
64
+ <br>
65
+
66
+ ## Requirements
67
+
68
+ * python>=3.8
69
+ * pytorch>=2.0.0
70
+ * transformers==4.32.0
71
+ * Sentencepiece
72
+ * CUDA 11.4
73
+ <br>
74
+
75
+ ## Inference String Format
76
+
77
+ The inference string is a concatenated string formed by combining conversation data(system, human and bot contents) in the training data format. It is used as input during the inference process.
78
+ Here is an example format of the concatenated string:
79
+
80
+ ```python
81
+ """
82
+ <|role_start|>system<|role_end|>System instruction
83
+ <|role_start|>human<|role_end|>Human 1st round input
84
+ <|role_start|>bot<|role_end|>Bot 1st round output</s>
85
+ <|role_start|>human<|role_end|>Human 2nd round input
86
+ <|role_start|>bot<|role_end|>Bot 2nd round output</s>
87
+ ...
88
+ ...
89
+ ...
90
+ <|role_start|>human<|role_end|>Human nth round input
91
+ <|role_start|>bot<|role_end|>{Bot output to be genreated}</s>
92
+ """
93
+ ```
94
+
95
+ When applying inference, you always make your input string end with "<|role_start|>bot<|role_end|>" to ask the model generating answers.
96
+
97
+ ## Quickstart
98
+
99
+ ```bash
100
+ git clone https://www.modelscope.cn/codefuse-ai/CodeFuse-StarCoder-15B.git
101
+ ```
102
+
103
+ ```bash
104
+ pip install -r requirements.txt
105
+ ```
106
+
107
+ ```python
108
+ import torch
109
+ from modelscope import (
110
+ AutoTokenizer,
111
+ AutoModelForCausalLM,
112
+ snapshot_download
113
+ )
114
+ model_dir = snapshot_download('codefuse-ai/CodeFuse-StarCoder-15B',revision = 'v1.0.0')
115
+ tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True, use_fast=False, legacy=False)
116
+ tokenizer.padding_side = "left"
117
+ tokenizer.pad_token_id = tokenizer.convert_tokens_to_ids("<fim_pad>")
118
+ tokenizer.eos_token_id = tokenizer.convert_tokens_to_ids("<|endoftext|>")
119
+ tokenizer.pad_token = "<fim_pad>"
120
+ tokenizer.eos_token = "<|endoftext|>"
121
+ # try 4bit loading if cuda memory not enough
122
+ model = AutoModelForCausalLM.from_pretrained(model_dir,
123
+ trust_remote_code=True,
124
+ load_in_4bit=False,
125
+ device_map="auto",
126
+ torch_dtype=torch.bfloat16)
127
+ model.eval()
128
+
129
+ HUMAN_ROLE_START_TAG = "<|role_start|>human<|role_end|>"
130
+ BOT_ROLE_START_TAG = "<|role_start|>bot<|role_end|>"
131
+
132
+ text = f"{HUMAN_ROLE_START_TAG}write a python function of quick sort.{BOT_ROLE_START_TAG}"
133
+ inputs = tokenizer(text, return_tensors='pt', padding=True, add_special_tokens=False).to("cuda")
134
+ outputs = model.generate(
135
+ inputs=inputs["input_ids"],
136
+ attention_mask=inputs["attention_mask"],
137
+ max_new_tokens=512,
138
+ top_p=0.95,
139
+ temperature=0.1,
140
+ do_sample=True,
141
+ eos_token_id=tokenizer.eos_token_id,
142
+ pad_token_id=tokenizer.pad_token_id
143
+ )
144
+ gen_text = tokenizer.batch_decode(outputs[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)
145
+ print(gen_text)
146
+ ```
147
+
148
+ ## MD5
149
+ We notice that the file may be corrupted during transfer process. Please check MD5 value before use.
150
+
151
+ | Model File | MD5 Value |
152
+ | :------------------------------- | :------------------------------: |
153
+ | pytorch_model-00001-of-00004.bin | d351e83d22dff5a10df61b93fa4bc072 |
154
+ | pytorch_model-00002-of-00004.bin | ba062cb505f688c3a8e18961d60a7aeb |
155
+ | pytorch_model-00003-of-00004.bin | 268abd618aac1b609a775697b330d799 |
156
+ | pytorch_model-00004-of-00004.bin | 65ab529c6fb6d4a11923820bb3c43cce |
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+ <a id="chinese"></a>
168
+
169
+ ## 模型简介
170
+
171
+ CodeFuse-StarCoder-15B 是一个通过QLoRA对基座模型StarCoder进行多代码任务微调的代码大模型。模型微调采用了4k上下文。该模型相比于我们近期开源的 [CodeFuse-CodeLlama-34B](https://modelscope.cn/models/codefuse-ai/CodeFuse-CodeLlama-34B/summary) ,模型小一些,并采用了MQA技术,推理速度比较快。
172
+ <br>
173
+
174
+ ## 新闻
175
+
176
+ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 🔥 2023-09-27开源了CodeFuse-StarCoder-15B模型,在HumanEval pass@1(greedy decoding)上可以达到54.9%
177
+
178
+ 🔥🔥🔥 2023-09-26 [CodeFuse-CodeLlama-34B 4bits](https://modelscope.cn/models/codefuse-ai/CodeFuse-CodeLlama-34B-4bits/summary)量化版本发布,量化后模型在HumanEval pass@1指标为73.8% (贪婪解码)。
179
+
180
+ 🔥🔥🔥 2023-09-11 [CodeFuse-CodeLlama-34B](https://modelscope.cn/models/codefuse-ai/CodeFuse-CodeLlama-34B/summary)发布,HumanEval pass@1指标达到74.4% (贪婪解码), 为当前开源SOTA。
181
+
182
+ <br>
183
+
184
+ ## 代码社区
185
+ **大本营**: 🏡 https://github.com/codefuse-ai (**请支持我们的项目Star🌟 + Fork🚀 + Watch👀**)
186
+
187
+ + 如果您想自己微调该模型,可以访问 ✨[MFTCoder](https://github.com/codefuse-ai/MFTCoder)✨✨
188
+
189
+ + 如果您想自己部署该模型,可以访问 ✨[FasterTransformer4CodeFuse](https://github.com/codefuse-ai/FasterTransformer4CodeFuse)✨✨
190
+
191
+ + 如果您想观看该模型示例,可以访问 ✨[CodeFuse Demo](https://github.com/codefuse-ai/codefuse)✨✨
192
+
193
+ <br>
194
+
195
+
196
+ ## 评测表现(代码)
197
+
198
+
199
+ | 模型 | HumanEval(pass@1) | 日期 |
200
+ |:----------------------------|:-----------------:|:-------:|
201
+ | **CodeFuse-CodeLlama-34B** | **74.4%** | 2023.9 |
202
+ |**CodeFuse-CodeLlama-34B-4bits** | **73.8%** | 2023.9 |
203
+ | WizardCoder-Python-34B-V1.0 | 73.2% | 2023.8 |
204
+ | GPT-4(zero-shot) | 67.0% | 2023.3 |
205
+ | PanGu-Coder2 15B | 61.6% | 2023.8 |
206
+ | CodeLlama-34b-Python | 53.7% | 2023.8 |
207
+ | CodeLlama-34b | 48.8% | 2023.8 |
208
+ | GPT-3.5(zero-shot) | 48.1% | 2022.11 |
209
+ | OctoCoder | 46.2% | 2023.8 |
210
+ | StarCoder-15B | 33.6% | 2023.5 |
211
+ | **CodeFuse-StarCoder-15B** | **54.9%** | 2023.8 |
212
+ <br>
213
+
214
+ ## Requirements
215
+
216
+ * python>=3.8
217
+ * pytorch>=2.0.0
218
+ * transformers==4.32.0
219
+ * Sentencepiece
220
+ * CUDA 11.4
221
+ <br>
222
+
223
+ ## 推理数据格式
224
+
225
+ 推理数据为模型在训练数据格式下拼接的字符串形式,它也是推理时输入prompt拼接的方式:
226
+
227
+ ```python
228
+ """
229
+ <|role_start|>system<|role_end|>这是System指令
230
+ <|role_start|>human<|role_end|>这是第1轮用户输入的问题
231
+ <|role_start|>bot<|role_end|>这是第1轮模型生成的内容</s>
232
+ <|role_start|>human<|role_end|>这是第2轮用户输入的问题
233
+ <|role_start|>bot<|role_end|>这是第2轮模型生成的内容</s>
234
+ ...
235
+ ...
236
+ ...
237
+ <|role_start|>human<|role_end|>这是第n轮用户输入的问题
238
+ <|role_start|>bot<|role_end|>{模型现在要生成的内容}</s>
239
+ """
240
+ ```
241
+
242
+ 推理时,请确保拼接的prompt字符串以"<|role_start|>bot<|role_end|>"结尾,引导模型生成回答。
243
+
244
+ ## 快速使用
245
+
246
+ ```bash
247
+ git clone https://www.modelscope.cn/codefuse-ai/CodeFuse-StarCoder-15B.git
248
+ ```
249
+
250
+ ```bash
251
+ pip install -r requirements.txt
252
+ ```
253
+
254
+ ```python
255
+ import torch
256
+ from modelscope import (
257
+ AutoTokenizer,
258
+ AutoModelForCausalLM,
259
+ snapshot_download
260
+ )
261
+ model_dir = snapshot_download('codefuse-ai/CodeFuse-StarCoder-15B',revision = 'v1.0.0')
262
+ tokenizer = AutoTokenizer.from_pretrained(model_dir, trust_remote_code=True, use_fast=False, legacy=False)
263
+ tokenizer.padding_side = "left"
264
+ tokenizer.pad_token_id = tokenizer.convert_tokens_to_ids("<fim_pad>")
265
+ tokenizer.eos_token_id = tokenizer.convert_tokens_to_ids("<|endoftext|>")
266
+ tokenizer.pad_token = "<fim_pad>"
267
+ tokenizer.eos_token = "<|endoftext|>"
268
+ # try 4bit loading if cuda memory not enough
269
+ model = AutoModelForCausalLM.from_pretrained(model_dir,
270
+ trust_remote_code=True,
271
+ load_in_4bit=False,
272
+ device_map="auto",
273
+ torch_dtype=torch.bfloat16)
274
+ model.eval()
275
+
276
+ HUMAN_ROLE_START_TAG = "<|role_start|>human<|role_end|>"
277
+ BOT_ROLE_START_TAG = "<|role_start|>bot<|role_end|>"
278
+
279
+ text = f"{HUMAN_ROLE_START_TAG}write a python function of quick sort.{BOT_ROLE_START_TAG}"
280
+ inputs = tokenizer(text, return_tensors='pt', padding=True, add_special_tokens=False).to("cuda")
281
+ outputs = model.generate(
282
+ inputs=inputs["input_ids"],
283
+ attention_mask=inputs["attention_mask"],
284
+ max_new_tokens=512,
285
+ top_p=0.95,
286
+ temperature=0.1,
287
+ do_sample=True,
288
+ eos_token_id=tokenizer.eos_token_id,
289
+ pad_token_id=tokenizer.pad_token_id
290
+ )
291
+ gen_text = tokenizer.batch_decode(outputs[:, inputs["input_ids"].shape[1]:], skip_special_tokens=True)
292
+ print(gen_text)
293
+ ```
294
+
295
+ ## MD5
296
+ 我们发现模型文件可能会在传输过程中损坏,使用前请检查文件MD5值。
297
+
298
+ | 模型文件 | MD5值 |
299
+ |:---------------------------------|:--------------------------------:|
300
+ | pytorch_model-00001-of-00004.bin | d351e83d22dff5a10df61b93fa4bc072 |
301
+ | pytorch_model-00002-of-00004.bin | ba062cb505f688c3a8e18961d60a7aeb |
302
+ | pytorch_model-00003-of-00004.bin | 268abd618aac1b609a775697b330d799 |
303
+ | pytorch_model-00004-of-00004.bin | 65ab529c6fb6d4a11923820bb3c43cce |
config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/mnt/user/qumu/download_models/starcoder",
3
+ "activation_function": "gelu",
4
+ "architectures": [
5
+ "GPTBigCodeForCausalLM"
6
+ ],
7
+ "attention_softmax_in_fp32": true,
8
+ "attn_pdrop": 0.1,
9
+ "bos_token_id": 0,
10
+ "embd_pdrop": 0.1,
11
+ "eos_token": "<|endoftext|>",
12
+ "eos_token_id": 0,
13
+ "inference_runner": 0,
14
+ "initializer_range": 0.02,
15
+ "layer_norm_epsilon": 1e-05,
16
+ "max_batch_size": null,
17
+ "max_sequence_length": null,
18
+ "model_type": "gpt_bigcode",
19
+ "multi_query": true,
20
+ "n_embd": 6144,
21
+ "n_head": 48,
22
+ "n_inner": 24576,
23
+ "n_layer": 40,
24
+ "n_positions": 8192,
25
+ "pad_key_length": true,
26
+ "pad_token": "<fim_pad>",
27
+ "pad_token_id": 4,
28
+ "pre_allocate_kv_cache": false,
29
+ "resid_pdrop": 0.1,
30
+ "scale_attention_softmax_in_fp32": true,
31
+ "scale_attn_weights": true,
32
+ "summary_activation": null,
33
+ "summary_first_dropout": 0.1,
34
+ "summary_proj_to_labels": true,
35
+ "summary_type": "cls_index",
36
+ "summary_use_proj": true,
37
+ "torch_dtype": "bfloat16",
38
+ "transformers_version": "4.33.2",
39
+ "use_cache": true,
40
+ "validate_runner_input": true,
41
+ "vocab_size": 49152
42
+ }
configuration.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"framework":"Pytorch","task":"text-generation"}
generation_config.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 0,
4
+ "eos_token_id": 0,
5
+ "transformers_version": "4.33.2"
6
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
pytorch_model-00001-of-00004.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26bb03db5f233036d82570ca3beeb45f1e0aa0e64ee3cf8bb4b964d9019e476d
3
+ size 9957985141
pytorch_model-00002-of-00004.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b7cb56964763b7ae50780de06b440f279b7defd0cd8faf550141c6fc702241fe
3
+ size 9857383847
pytorch_model-00003-of-00004.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:656be1f54636dde30526875ab53e5f8606d6c9612124b72ebfcb12ea36d04692
3
+ size 9857383847
pytorch_model-00004-of-00004.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:43c7c1b0df814c90aec92bb31acd75560ec6a86657b3dd4d230c736850d2e3ee
3
+ size 1362328147
pytorch_model.bin.index.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:58b7ac20c1c5ccf28eda8011d758ad66d56468b2fc320580be957fc35f472bab
3
+ size 36278
special_tokens_map.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|endoftext|>",
4
+ "<fim_prefix>",
5
+ "<fim_middle>",
6
+ "<fim_suffix>",
7
+ "<fim_pad>",
8
+ "<filename>",
9
+ "<gh_stars>",
10
+ "<issue_start>",
11
+ "<issue_comment>",
12
+ "<issue_closed>",
13
+ "<jupyter_start>",
14
+ "<jupyter_text>",
15
+ "<jupyter_code>",
16
+ "<jupyter_output>",
17
+ "<empty_output>",
18
+ "<commit_before>",
19
+ "<commit_msg>",
20
+ "<commit_after>",
21
+ "<reponame>"
22
+ ],
23
+ "bos_token": "<|endoftext|>",
24
+ "eos_token": "<|endoftext|>",
25
+ "unk_token": "<|endoftext|>"
26
+ }
tokenizer_config.json ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_bos_token": false,
3
+ "add_prefix_space": false,
4
+ "additional_special_tokens": [
5
+ "<|endoftext|>",
6
+ "<fim_prefix>",
7
+ "<fim_middle>",
8
+ "<fim_suffix>",
9
+ "<fim_pad>",
10
+ "<filename>",
11
+ "<gh_stars>",
12
+ "<issue_start>",
13
+ "<issue_comment>",
14
+ "<issue_closed>",
15
+ "<jupyter_start>",
16
+ "<jupyter_text>",
17
+ "<jupyter_code>",
18
+ "<jupyter_output>",
19
+ "<empty_output>",
20
+ "<commit_before>",
21
+ "<commit_msg>",
22
+ "<commit_after>",
23
+ "<reponame>"
24
+ ],
25
+ "bos_token": {
26
+ "__type": "AddedToken",
27
+ "content": "<|endoftext|>",
28
+ "lstrip": false,
29
+ "normalized": true,
30
+ "rstrip": false,
31
+ "single_word": false
32
+ },
33
+ "clean_up_tokenization_spaces": true,
34
+ "eos_token": {
35
+ "__type": "AddedToken",
36
+ "content": "<|endoftext|>",
37
+ "lstrip": false,
38
+ "normalized": true,
39
+ "rstrip": false,
40
+ "single_word": false
41
+ },
42
+ "errors": "replace",
43
+ "legacy": false,
44
+ "model_max_length": 1000000000000000019884624838656,
45
+ "pad_token": null,
46
+ "tokenizer_class": "GPT2Tokenizer",
47
+ "unk_token": {
48
+ "__type": "AddedToken",
49
+ "content": "<|endoftext|>",
50
+ "lstrip": false,
51
+ "normalized": true,
52
+ "rstrip": false,
53
+ "single_word": false
54
+ },
55
+ "vocab_size": 49152
56
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff