RichardErkhov commited on
Commit
ee549e0
1 Parent(s): d3a2ef8

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +235 -0
README.md ADDED
@@ -0,0 +1,235 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ starcoder2-7b - bnb 4bits
11
+ - Model creator: https://huggingface.co/bigcode/
12
+ - Original model: https://huggingface.co/bigcode/starcoder2-7b/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ pipeline_tag: text-generation
20
+ inference:
21
+ parameters:
22
+ temperature: 0.2
23
+ top_p: 0.95
24
+ widget:
25
+ - text: 'def print_hello_world():'
26
+ example_title: Hello world
27
+ group: Python
28
+ datasets:
29
+ - bigcode/the-stack-v2-train
30
+ license: bigcode-openrail-m
31
+ library_name: transformers
32
+ tags:
33
+ - code
34
+ model-index:
35
+ - name: starcoder2-7b
36
+ results:
37
+ - task:
38
+ type: text-generation
39
+ dataset:
40
+ name: CruxEval-I
41
+ type: cruxeval-i
42
+ metrics:
43
+ - type: pass@1
44
+ value: 34.6
45
+ - task:
46
+ type: text-generation
47
+ dataset:
48
+ name: DS-1000
49
+ type: ds-1000
50
+ metrics:
51
+ - type: pass@1
52
+ value: 27.8
53
+ - task:
54
+ type: text-generation
55
+ dataset:
56
+ name: GSM8K (PAL)
57
+ type: gsm8k-pal
58
+ metrics:
59
+ - type: accuracy
60
+ value: 40.4
61
+ - task:
62
+ type: text-generation
63
+ dataset:
64
+ name: HumanEval+
65
+ type: humanevalplus
66
+ metrics:
67
+ - type: pass@1
68
+ value: 29.9
69
+ - task:
70
+ type: text-generation
71
+ dataset:
72
+ name: HumanEval
73
+ type: humaneval
74
+ metrics:
75
+ - type: pass@1
76
+ value: 35.4
77
+ - task:
78
+ type: text-generation
79
+ dataset:
80
+ name: RepoBench-v1.1
81
+ type: repobench-v1.1
82
+ metrics:
83
+ - type: edit-smiliarity
84
+ value: 72.07
85
+ ---
86
+
87
+ # StarCoder2
88
+
89
+ <center>
90
+ <img src="https://huggingface.co/datasets/bigcode/admin_private/resolve/main/starcoder2_banner.png" alt="SC2" width="900" height="600">
91
+ </center>
92
+
93
+ ## Table of Contents
94
+
95
+ 1. [Model Summary](##model-summary)
96
+ 2. [Use](##use)
97
+ 3. [Limitations](##limitations)
98
+ 4. [Training](##training)
99
+ 5. [License](##license)
100
+ 6. [Citation](##citation)
101
+
102
+ ## Model Summary
103
+
104
+ StarCoder2-7B model is a 7B parameter model trained on 17 programming languages from [The Stack v2](https://huggingface.co/datasets/bigcode/the-stack-v2-train), with opt-out requests excluded. The model uses [Grouped Query Attention](https://arxiv.org/abs/2305.13245), [a context window of 16,384 tokens](https://arxiv.org/abs/2205.14135) with [a sliding window attention of 4,096 tokens](https://arxiv.org/abs/2004.05150v2), and was trained using the [Fill-in-the-Middle objective](https://arxiv.org/abs/2207.14255) on 3.5+ trillion tokens.
105
+
106
+ - **Project Website:** [bigcode-project.org](https://www.bigcode-project.org)
107
+ - **Paper:** [Link](https://huggingface.co/papers/2402.19173)
108
+ - **Point of Contact:** [contact@bigcode-project.org](mailto:contact@bigcode-project.org)
109
+ - **Languages:** 17 Programming languages
110
+
111
+ ## Use
112
+
113
+ ### Intended use
114
+
115
+ The model was trained on GitHub code as well as additional selected data sources such as Arxiv and Wikipedia. As such it is _not_ an instruction model and commands like "Write a function that computes the square root." do not work well.
116
+
117
+ ### Generation
118
+ Here are some examples to get started with the model. You can find a script for fine-tuning in StarCoder2's [GitHub repository](https://github.com/bigcode-project/starcoder2).
119
+
120
+ First, make sure to install `transformers` from source:
121
+ ```bash
122
+ pip install git+https://github.com/huggingface/transformers.git
123
+ ```
124
+
125
+ #### Running the model on CPU/GPU/multi GPU
126
+ * _Using full precision_
127
+ ```python
128
+ # pip install git+https://github.com/huggingface/transformers.git # TODO: merge PR to main
129
+ from transformers import AutoModelForCausalLM, AutoTokenizer
130
+
131
+ checkpoint = "bigcode/starcoder2-7b"
132
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
133
+
134
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
135
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
136
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
137
+
138
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
139
+ outputs = model.generate(inputs)
140
+ print(tokenizer.decode(outputs[0]))
141
+ ```
142
+ ```bash
143
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
144
+ Memory footprint: 29232.57 MB
145
+ ```
146
+ * _Using `torch.bfloat16`_
147
+ ```python
148
+ # pip install accelerate
149
+ import torch
150
+ from transformers import AutoTokenizer, AutoModelForCausalLM
151
+
152
+ checkpoint = "bigcode/starcoder2-7b"
153
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
154
+
155
+ # for fp16 use `torch_dtype=torch.float16` instead
156
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
157
+
158
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
159
+ outputs = model.generate(inputs)
160
+ print(tokenizer.decode(outputs[0]))
161
+ ```
162
+ ```bash
163
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
164
+ Memory footprint: 14616.29 MB
165
+ ```
166
+
167
+ #### Quantized Versions through `bitsandbytes`
168
+ * _Using 8-bit precision (int8)_
169
+
170
+ ```python
171
+ # pip install bitsandbytes accelerate
172
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
173
+
174
+ # to use 4bit use `load_in_4bit=True` instead
175
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
176
+
177
+ checkpoint = "bigcode/starcoder2-7b"
178
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
179
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
180
+
181
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
182
+ outputs = model.generate(inputs)
183
+ print(tokenizer.decode(outputs[0]))
184
+ ```
185
+ ```bash
186
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
187
+ # load_in_8bit
188
+ Memory footprint: 7670.52 MB
189
+ # load_in_4bit
190
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
191
+ Memory footprint: 4197.64 MB
192
+ ```
193
+ ### Attribution & Other Requirements
194
+
195
+ The pretraining dataset of the model was filtered for permissive licenses and code with no license only. Nevertheless, the model can generate source code verbatim from the dataset. The code's license might require attribution and/or other specific requirements that must be respected. We provide a [search index](https://huggingface.co/spaces/bigcode/search-v2) that lets you search through the pretraining data to identify where the generated code came from and apply the proper attribution to your code.
196
+
197
+ # Limitations
198
+
199
+ The model has been trained on source code from 17 programming languages. The predominant language in source is English although other languages are also present. As such the model is capable of generating code snippets provided some context but the generated code is not guaranteed to work as intended. It can be inefficient and contain bugs or exploits. See [the paper](https://huggingface.co/papers/2402.19173) for an in-depth discussion of the model limitations.
200
+
201
+ # Training
202
+
203
+ ## Model
204
+
205
+ - **Architecture:** Transformer decoder with grouped-query and sliding window attention and Fill-in-the-Middle objective
206
+ - **Pretraining steps:** 1 million
207
+ - **Pretraining tokens:** 3.5+ trillion
208
+ - **Precision:** bfloat16
209
+
210
+ ## Hardware
211
+
212
+ - **GPUs:** 432 H100
213
+
214
+ ## Software
215
+
216
+ - **Framework:** [nanotron](https://github.com/huggingface/nanotron/)
217
+ - **Neural networks:** [PyTorch](https://github.com/pytorch/pytorch)
218
+
219
+ # License
220
+
221
+ The model is licensed under the BigCode OpenRAIL-M v1 license agreement. You can find the full agreement [here](https://huggingface.co/spaces/bigcode/bigcode-model-license-agreement).
222
+
223
+ # Citation
224
+
225
+ ```bash
226
+ @misc{lozhkov2024starcoder,
227
+ title={StarCoder 2 and The Stack v2: The Next Generation},
228
+ author={Anton Lozhkov and Raymond Li and Loubna Ben Allal and Federico Cassano and Joel Lamy-Poirier and Nouamane Tazi and Ao Tang and Dmytro Pykhtar and Jiawei Liu and Yuxiang Wei and Tianyang Liu and Max Tian and Denis Kocetkov and Arthur Zucker and Younes Belkada and Zijian Wang and Qian Liu and Dmitry Abulkhanov and Indraneil Paul and Zhuang Li and Wen-Ding Li and Megan Risdal and Jia Li and Jian Zhu and Terry Yue Zhuo and Evgenii Zheltonozhskii and Nii Osae Osae Dade and Wenhao Yu and Lucas Krauß and Naman Jain and Yixuan Su and Xuanli He and Manan Dey and Edoardo Abati and Yekun Chai and Niklas Muennighoff and Xiangru Tang and Muhtasham Oblokulov and Christopher Akiki and Marc Marone and Chenghao Mou and Mayank Mishra and Alex Gu and Binyuan Hui and Tri Dao and Armel Zebaze and Olivier Dehaene and Nicolas Patry and Canwen Xu and Julian McAuley and Han Hu and Torsten Scholak and Sebastien Paquet and Jennifer Robinson and Carolyn Jane Anderson and Nicolas Chapados and Mostofa Patwary and Nima Tajbakhsh and Yacine Jernite and Carlos Muñoz Ferrandis and Lingming Zhang and Sean Hughes and Thomas Wolf and Arjun Guha and Leandro von Werra and Harm de Vries},
229
+ year={2024},
230
+ eprint={2402.19173},
231
+ archivePrefix={arXiv},
232
+ primaryClass={cs.SE}
233
+ }
234
+ ```
235
+