RichardErkhov commited on
Commit
5c37399
1 Parent(s): f2b5b1d

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +232 -0
README.md ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-3b - bnb 4bits
11
+ - Model creator: https://huggingface.co/bigcode/
12
+ - Original model: https://huggingface.co/bigcode/starcoder2-3b/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ pipeline_tag: text-generation
20
+ inference: true
21
+ widget:
22
+ - text: 'def print_hello_world():'
23
+ example_title: Hello world
24
+ group: Python
25
+ datasets:
26
+ - bigcode/the-stack-v2-train
27
+ license: bigcode-openrail-m
28
+ library_name: transformers
29
+ tags:
30
+ - code
31
+ model-index:
32
+ - name: starcoder2-3b
33
+ results:
34
+ - task:
35
+ type: text-generation
36
+ dataset:
37
+ name: CruxEval-I
38
+ type: cruxeval-i
39
+ metrics:
40
+ - type: pass@1
41
+ value: 32.7
42
+ - task:
43
+ type: text-generation
44
+ dataset:
45
+ name: DS-1000
46
+ type: ds-1000
47
+ metrics:
48
+ - type: pass@1
49
+ value: 25.0
50
+ - task:
51
+ type: text-generation
52
+ dataset:
53
+ name: GSM8K (PAL)
54
+ type: gsm8k-pal
55
+ metrics:
56
+ - type: accuracy
57
+ value: 27.7
58
+ - task:
59
+ type: text-generation
60
+ dataset:
61
+ name: HumanEval+
62
+ type: humanevalplus
63
+ metrics:
64
+ - type: pass@1
65
+ value: 27.4
66
+ - task:
67
+ type: text-generation
68
+ dataset:
69
+ name: HumanEval
70
+ type: humaneval
71
+ metrics:
72
+ - type: pass@1
73
+ value: 31.7
74
+ - task:
75
+ type: text-generation
76
+ dataset:
77
+ name: RepoBench-v1.1
78
+ type: repobench-v1.1
79
+ metrics:
80
+ - type: edit-smiliarity
81
+ value: 71.19
82
+ ---
83
+
84
+ # StarCoder2
85
+
86
+ <center>
87
+ <img src="https://huggingface.co/datasets/bigcode/admin_private/resolve/main/starcoder2_banner.png" alt="SC2" width="900" height="600">
88
+ </center>
89
+
90
+ ## Table of Contents
91
+
92
+ 1. [Model Summary](##model-summary)
93
+ 2. [Use](##use)
94
+ 3. [Limitations](##limitations)
95
+ 4. [Training](##training)
96
+ 5. [License](##license)
97
+ 6. [Citation](##citation)
98
+
99
+ ## Model Summary
100
+
101
+ StarCoder2-3B model is a 3B 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+ trillion tokens.
102
+
103
+ - **Project Website:** [bigcode-project.org](https://www.bigcode-project.org)
104
+ - **Paper:** [Link](https://huggingface.co/papers/2402.19173)
105
+ - **Point of Contact:** [[email protected]](mailto:[email protected])
106
+ - **Languages:** 17 Programming languages
107
+
108
+ ## Use
109
+
110
+ ### Intended use
111
+
112
+ 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.
113
+
114
+ ### Generation
115
+ 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).
116
+
117
+ First, make sure to install `transformers` from source:
118
+ ```bash
119
+ pip install git+https://github.com/huggingface/transformers.git
120
+ ```
121
+
122
+ #### Running the model on CPU/GPU/multi GPU
123
+ * _Using full precision_
124
+ ```python
125
+ # pip install git+https://github.com/huggingface/transformers.git # TODO: merge PR to main
126
+ from transformers import AutoModelForCausalLM, AutoTokenizer
127
+
128
+ checkpoint = "bigcode/starcoder2-3b"
129
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
130
+
131
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
132
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
133
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
134
+
135
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
136
+ outputs = model.generate(inputs)
137
+ print(tokenizer.decode(outputs[0]))
138
+ ```
139
+ ```bash
140
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
141
+ Memory footprint: 12624.81 MB
142
+ ```
143
+ * _Using `torch.bfloat16`_
144
+ ```python
145
+ # pip install accelerate
146
+ import torch
147
+ from transformers import AutoTokenizer, AutoModelForCausalLM
148
+
149
+ checkpoint = "bigcode/starcoder2-3b"
150
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
151
+
152
+ # for fp16 use `torch_dtype=torch.float16` instead
153
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
154
+
155
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
156
+ outputs = model.generate(inputs)
157
+ print(tokenizer.decode(outputs[0]))
158
+ ```
159
+ ```bash
160
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
161
+ Memory footprint: 6312.41 MB
162
+ ```
163
+
164
+ #### Quantized Versions through `bitsandbytes`
165
+ * _Using 8-bit precision (int8)_
166
+
167
+ ```python
168
+ # pip install bitsandbytes accelerate
169
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
170
+
171
+ # to use 4bit use `load_in_4bit=True` instead
172
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
173
+
174
+ checkpoint = "bigcode/starcoder2-3b"
175
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
176
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
177
+
178
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
179
+ outputs = model.generate(inputs)
180
+ print(tokenizer.decode(outputs[0]))
181
+ ```
182
+ ```bash
183
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
184
+ # load_in_8bit
185
+ Memory footprint: 3434.07 MB
186
+ # load_in_4bit
187
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
188
+ Memory footprint: 1994.90 MB
189
+ ```
190
+ ### Attribution & Other Requirements
191
+
192
+ 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.
193
+
194
+ # Limitations
195
+
196
+ The model has been trained on source code from 600+ programming languages. The predominant language in source is English although other languages are also present. As such the model is capable to generate code snippets provided some context but the generated code is not guaranteed to work as intended. It can be inefficient, contain bugs or exploits. See [the paper](https://huggingface.co/papers/2402.19173) for an in-depth discussion of the model limitations.
197
+
198
+ # Training
199
+
200
+ ## Model
201
+
202
+ - **Architecture:** Transformer decoder with grouped-query and sliding window attention and Fill-in-the-Middle objective
203
+ - **Pretraining steps:** 1.2 million
204
+ - **Pretraining tokens:** 3+ trillion
205
+ - **Precision:** bfloat16
206
+
207
+ ## Hardware
208
+
209
+ - **GPUs:** 160 A100
210
+
211
+ ## Software
212
+
213
+ - **Framework:** TODO
214
+ - **Neural networks:** [PyTorch](https://github.com/pytorch/pytorch)
215
+
216
+ # License
217
+
218
+ 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).
219
+
220
+ # Citation
221
+
222
+ ```bash
223
+ @misc{lozhkov2024starcoder,
224
+ title={StarCoder 2 and The Stack v2: The Next Generation},
225
+ 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},
226
+ year={2024},
227
+ eprint={2402.19173},
228
+ archivePrefix={arXiv},
229
+ primaryClass={cs.SE}
230
+ }
231
+ ```
232
+