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|
|
|
1 |
+
---
|
2 |
+
license: bigcode-openrail-m
|
3 |
+
datasets:
|
4 |
+
- bigcode/starcoderdata
|
5 |
+
- bigcode/the-stack-dedup
|
6 |
+
metrics:
|
7 |
+
- code_eval
|
8 |
+
library_name: transformers
|
9 |
+
pipeline_tag: text-generation
|
10 |
+
tags:
|
11 |
+
- code
|
12 |
+
---
|
13 |
+
|
14 |
+
# **Opencsg-starcoder2-15b-v0.1** [[中文]](#chinese) [[English]](#english)
|
15 |
+
|
16 |
+
<a id="english"></a>
|
17 |
+
|
18 |
+
<p align="center">
|
19 |
+
<img width="300px" alt="OpenCSG" src="https://cdn-uploads.huggingface.co/production/uploads/64c71b27d43e4dee51a8b31a/GwYXPKuEoGCGcMICeW-sb.jpeg">
|
20 |
+
</p>
|
21 |
+
|
22 |
+
<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>
|
23 |
+
|
24 |
+
|
25 |
+
</div>
|
26 |
+
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.
|
27 |
+
|
28 |
+
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.
|
29 |
+
|
30 |
+
|
31 |
+
|
32 |
+
## Model Description
|
33 |
+
|
34 |
+
The [StarCoder](https://huggingface.co/bigcode/starcoder) models are 15.5B parameter models trained on 80+ programming languages from [The Stack (v1.2)](https://huggingface.co/datasets/bigcode/the-stack), with opt-out requests excluded.
|
35 |
+
Based on StarCoder2, opencsg-starcoder2-15b-v0.1 was fintuned by OpenCSG LLM Research Team througth full-paramters fine-tuning method.
|
36 |
+
<br>
|
37 |
+
|
38 |
+
|
39 |
+
## Model Eval
|
40 |
+
|
41 |
+
HumanEval is the most common code generation benchmark for evaluating model performance, especially on the compeltion of code exercise cases.
|
42 |
+
Model evaluation is, to some extent, a metaphysics. Different models have different sensitivities to decoding methods, parameters and instructions.
|
43 |
+
It is impratical for us to manually set specific configurations for each fine-tuned model, because a real LLM should master general capabilities despite the parameters being manipulated by users.
|
44 |
+
|
45 |
+
Therefore, OpenCSG racked their brains to provide a relatively fair method to compare the fine-tuned models on the HumanEval benchmark.
|
46 |
+
To simplify the comparison, we chosed the Pass@1 metric for the Python language, but our fine-tuning dataset includes samples in multiple languages.
|
47 |
+
|
48 |
+
**For fairness, we evaluated the original and fine-tuned StarCoder models based only on the prompts from the original cases, without including any other instructions.**
|
49 |
+
|
50 |
+
**Otherwise, we use the greedy decoding method for each model during evaluation.**
|
51 |
+
|
52 |
+
| Model | HumanEval python pass@1 |
|
53 |
+
| --- |----------------------------------------------------------------------------- |
|
54 |
+
| starcoder | 35.98%|
|
55 |
+
| opencsg-starcoder-v0.1| **42.68%** |
|
56 |
+
| opencsg-starcoder2-3b-v0.1| **45.12%** |
|
57 |
+
| opencsg-starcoder2-7b-v0.1| **51.22%** |
|
58 |
+
| opencsg-starcoder2-15b-v0.1| **59.15%** |
|
59 |
+
|
60 |
+
**TODO**
|
61 |
+
- We will provide more benchmark scores on fine-tuned models in the future.
|
62 |
+
- We will provide different practical problems to evaluate the performance of fine-tuned models in the field of software engineering.
|
63 |
+
|
64 |
+
|
65 |
+
|
66 |
+
# Model Usage
|
67 |
+
|
68 |
+
|
69 |
+
```python
|
70 |
+
from transformers import AutoTokenizer
|
71 |
+
import transformers
|
72 |
+
import torch
|
73 |
+
|
74 |
+
model = "opencsg/opencsg-starcoder2-15b-v0.1"
|
75 |
+
|
76 |
+
tokenizer = AutoTokenizer.from_pretrained(model, trust_remote_code=True)
|
77 |
+
pipeline = transformers.pipeline(
|
78 |
+
"text-generation",
|
79 |
+
model=model,
|
80 |
+
torch_dtype=torch.float16,
|
81 |
+
device_map="auto",
|
82 |
+
)
|
83 |
+
input_text = """#Generate one test case for the following code.
|
84 |
+
def quick_sort(arr):
|
85 |
+
if len(arr) < 2:
|
86 |
+
return arr
|
87 |
+
else:
|
88 |
+
pivot = arr[0]
|
89 |
+
less = [i for i in arr[1:] if i <= pivot]
|
90 |
+
greater = [i for i in arr[1:] if i > pivot]
|
91 |
+
return quick_sort(less) + [pivot] + quick_sort(greater)
|
92 |
+
"""
|
93 |
+
sequences = pipeline(
|
94 |
+
input_text,
|
95 |
+
do_sample=False,
|
96 |
+
top_k=10,
|
97 |
+
temperature=0.1,
|
98 |
+
top_p=0.95,
|
99 |
+
num_return_sequences=1,
|
100 |
+
eos_token_id=tokenizer.eos_token_id,
|
101 |
+
max_length=256,
|
102 |
+
)
|
103 |
+
for seq in sequences:
|
104 |
+
print(seq['generated_text'][len(input_text):])
|
105 |
+
```
|
106 |
+
|
107 |
+
**generate output**
|
108 |
+
|
109 |
+
```python
|
110 |
+
# Test case
|
111 |
+
arr = [5, 2, 9, 1, 7]
|
112 |
+
print(quick_sort(arr))
|
113 |
+
|
114 |
+
```
|
115 |
+
|
116 |
+
# Training
|
117 |
+
|
118 |
+
## Hardware
|
119 |
+
|
120 |
+
- **GPUs:** 8 Tesla A800
|
121 |
+
- **Training time:** 7 hours
|
122 |
+
|
123 |
+
## Software
|
124 |
+
|
125 |
+
- **Orchestration:** [Deepspeed](https://github.com/OpenCSGs)
|
126 |
+
- **Neural networks:** [PyTorch](https://github.com/pytorch/pytorch)
|
127 |
+
- **BP16 if applicable:** [apex](https://github.com/NVIDIA/apex)
|
128 |
+
|
129 |
+
|
130 |
+
<a id="chinese"></a>
|
131 |
+
|
132 |
+
<p>
|
133 |
+
|
134 |
+
</p>
|
135 |
+
|
136 |
+
# OpenCSG介绍
|
137 |
+
|
138 |
+
|
139 |
+
<p align="center">
|
140 |
+
<img width="300px" alt="OpenCSG" src="https://cdn-uploads.huggingface.co/production/uploads/64c71b27d43e4dee51a8b31a/GwYXPKuEoGCGcMICeW-sb.jpeg">
|
141 |
+
</p>
|
142 |
+
|
143 |
+
<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>
|
144 |
+
|
145 |
+
|
146 |
+
|
147 |
+
</div>
|
148 |
+
OpenCSG 致力于资源融合、软件求精和生成式 LM。其中,“C”代表资源融合(Converged resources),表示多种混合资源的整合和充分利用。 “S”代表软件求精(Software refinement),表示通过大模型精炼过的软件。 “G”代表生成型语言模型(Generative LM),它表示广泛使用的、包容性的、经过民主化的生成式大模型。
|
149 |
+
|
150 |
+
OpenCSG 的愿景是让每个行业、每个公司、每个人都拥有自己的模型。 我们坚持开放开源的原则,将OpenCSG的大模型栈提供给社区。 欢迎大家积极使用、反馈想法和贡献内容。
|
151 |
+
|
152 |
+
|
153 |
+
|
154 |
+
## 模型介绍
|
155 |
+
[StarCoder](https://huggingface.co/bigcode/starcoder) 模型是在 [The Stack (v1.2)](https://huggingface.co/datasets/bigcode/the-stack) 中的 80 多种编程语言上训练的 155 亿参数模型,不包括用户请求排除在训练数据之外的部分。
|
156 |
+
opencsg-starcoder2-15b-v0.1是 OpenCSG 大模型研究团队基于 StarCoder2,通过全参数微调的方法进行调优的。
|
157 |
+
|
158 |
+
## 模型评估
|
159 |
+
|
160 |
+
HumanEval 是评估模型在代码生成方面性能的最常见的基准,尤其是在代码习题的补全方面。
|
161 |
+
模型评估在某种程度上是一种玄学。不同的模型对解码方法、参数和指令的敏感度不同,
|
162 |
+
优秀的大模型是具备通用能力的,而不会因为解码参数的调整使得模型的生成表现有很大的差异。
|
163 |
+
|
164 |
+
因此,OpenCSG 提供了一个相对公平的方法来在 HumanEval 基准上比较各微调模型。
|
165 |
+
方便起见,我们选择了Python语言Pass@1指标,但要注意的是,我们的微调数据集是包含多种编程语言。
|
166 |
+
|
167 |
+
**为了公平起见,我们仅根据原始问题的提示来评估原始和微调过的 StarCoder 模型,不包含任何其他说明。**
|
168 |
+
|
169 |
+
**除此之外,我们在评估过程中对每个模型都使用贪婪解码方法。**
|
170 |
+
|
171 |
+
| 模型 | HumanEval python pass@1 |
|
172 |
+
| --- |----------------------------------------------------------------------------- |
|
173 |
+
| starcoder | 35.98%|
|
174 |
+
| opencsg-starcoder-v0.1| **42.68%** |
|
175 |
+
| opencsg-starcoder2-3b-v0.1| **45.12%** |
|
176 |
+
| opencsg-starcoder2-7b-v0.1| **51.22%** |
|
177 |
+
| opencsg-starcoder2-15b-v0.1| **59.15%** |
|
178 |
+
|
179 |
+
**TODO**
|
180 |
+
- 未来我们将提供更多微调模型的在各基准上的分数。
|
181 |
+
- 我们将提供不同的实际问题来评估微调模型在软件工程领域的性能。
|
182 |
+
|
183 |
+
|
184 |
+
|
185 |
+
# 模型使用
|
186 |
+
|
187 |
+
|
188 |
+
```python
|
189 |
+
from transformers import AutoTokenizer
|
190 |
+
import transformers
|
191 |
+
import torch
|
192 |
+
|
193 |
+
model = "opencsg/opencsg-starcoder2-15b-v0.1"
|
194 |
+
|
195 |
+
tokenizer = AutoTokenizer.from_pretrained(model, trust_remote_code=True)
|
196 |
+
pipeline = transformers.pipeline(
|
197 |
+
"text-generation",
|
198 |
+
model=model,
|
199 |
+
torch_dtype=torch.float16,
|
200 |
+
device_map="auto",
|
201 |
+
)
|
202 |
+
input_text = """#Generate one test case for the following code.
|
203 |
+
def quick_sort(arr):
|
204 |
+
if len(arr) < 2:
|
205 |
+
return arr
|
206 |
+
else:
|
207 |
+
pivot = arr[0]
|
208 |
+
less = [i for i in arr[1:] if i <= pivot]
|
209 |
+
greater = [i for i in arr[1:] if i > pivot]
|
210 |
+
return quick_sort(less) + [pivot] + quick_sort(greater)
|
211 |
+
"""
|
212 |
+
sequences = pipeline(
|
213 |
+
input_text,
|
214 |
+
do_sample=False,
|
215 |
+
top_k=10,
|
216 |
+
temperature=0.1,
|
217 |
+
top_p=0.95,
|
218 |
+
num_return_sequences=1,
|
219 |
+
eos_token_id=tokenizer.eos_token_id,
|
220 |
+
max_length=256,
|
221 |
+
)
|
222 |
+
for seq in sequences:
|
223 |
+
print(seq['generated_text'][len(input_text):])
|
224 |
+
```
|
225 |
+
|
226 |
+
**generate output**
|
227 |
+
|
228 |
+
```python
|
229 |
+
# Test case
|
230 |
+
arr = [5, 2, 9, 1, 7]
|
231 |
+
print(quick_sort(arr))
|
232 |
+
|
233 |
+
```
|
234 |
+
|
235 |
+
|
236 |
+
# 训练
|
237 |
+
|
238 |
+
## 硬件资源
|
239 |
+
|
240 |
+
- **GPU数量:** 8 Tesla A800
|
241 |
+
- **训练时间:** 7 小时
|
242 |
+
|
243 |
+
## 软件使用
|
244 |
+
|
245 |
+
- **微调训练框架:** [Deepspeed](https://github.com/OpenCSGs)
|
246 |
+
- **深度学习框架:** [PyTorch](https://github.com/pytorch/pytorch)
|
247 |
+
- **BP16:** [apex](https://github.com/NVIDIA/apex)
|