RichardErkhov commited on
Commit
87e095f
1 Parent(s): fc2a4c8

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +233 -0
README.md ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-15b - bnb 4bits
11
+ - Model creator: https://huggingface.co/bigcode/
12
+ - Original model: https://huggingface.co/bigcode/starcoder2-15b/
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-15b
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: 48.1
45
+ - task:
46
+ type: text-generation
47
+ dataset:
48
+ name: DS-1000
49
+ type: ds-1000
50
+ metrics:
51
+ - type: pass@1
52
+ value: 33.8
53
+ - task:
54
+ type: text-generation
55
+ dataset:
56
+ name: GSM8K (PAL)
57
+ type: gsm8k-pal
58
+ metrics:
59
+ - type: accuracy
60
+ value: 65.1
61
+ - task:
62
+ type: text-generation
63
+ dataset:
64
+ name: HumanEval+
65
+ type: humanevalplus
66
+ metrics:
67
+ - type: pass@1
68
+ value: 37.8
69
+ - task:
70
+ type: text-generation
71
+ dataset:
72
+ name: HumanEval
73
+ type: humaneval
74
+ metrics:
75
+ - type: pass@1
76
+ value: 46.3
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: 74.08
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-15B model is a 15B parameter model trained on 600+ 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 4+ trillion tokens.
105
+ The model was trained with [NVIDIA NeMo™ Framework](https://www.nvidia.com/en-us/ai-data-science/generative-ai/nemo-framework/) using the [NVIDIA Eos Supercomputer](https://blogs.nvidia.com/blog/eos/) built with [NVIDIA DGX H100](https://www.nvidia.com/en-us/data-center/dgx-h100/) systems.
106
+
107
+ - **Project Website:** [bigcode-project.org](https://www.bigcode-project.org)
108
+ - **Paper:** [Link](https://huggingface.co/papers/2402.19173)
109
+ - **Point of Contact:** [[email protected]](mailto:[email protected])
110
+ - **Languages:** 600+ Programming languages
111
+
112
+ ## Use
113
+
114
+ ### Intended use
115
+
116
+ 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.
117
+
118
+ ### Generation
119
+ 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).
120
+
121
+ First, make sure to install `transformers` from source:
122
+ ```bash
123
+ pip install git+https://github.com/huggingface/transformers.git
124
+ ```
125
+
126
+ #### Running the model on CPU/GPU/multi GPU
127
+ * _Using full precision_
128
+ ```python
129
+ # pip install git+https://github.com/huggingface/transformers.git # TODO: merge PR to main
130
+ from transformers import AutoModelForCausalLM, AutoTokenizer
131
+
132
+ checkpoint = "bigcode/starcoder2-15b"
133
+ device = "cuda" # for GPU usage or "cpu" for CPU usage
134
+
135
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
136
+ # for multiple GPUs install accelerate and do `model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto")`
137
+ model = AutoModelForCausalLM.from_pretrained(checkpoint).to(device)
138
+
139
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to(device)
140
+ outputs = model.generate(inputs)
141
+ print(tokenizer.decode(outputs[0]))
142
+ ```
143
+
144
+ * _Using `torch.bfloat16`_
145
+ ```python
146
+ # pip install accelerate
147
+ import torch
148
+ from transformers import AutoTokenizer, AutoModelForCausalLM
149
+
150
+ checkpoint = "bigcode/starcoder2-15b"
151
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
152
+
153
+ # for fp16 use `torch_dtype=torch.float16` instead
154
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, device_map="auto", torch_dtype=torch.bfloat16)
155
+
156
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
157
+ outputs = model.generate(inputs)
158
+ print(tokenizer.decode(outputs[0]))
159
+ ```
160
+ ```bash
161
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
162
+ Memory footprint: 32251.33 MB
163
+ ```
164
+
165
+ #### Quantized Versions through `bitsandbytes`
166
+ * _Using 8-bit precision (int8)_
167
+
168
+ ```python
169
+ # pip install bitsandbytes accelerate
170
+ from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
171
+
172
+ # to use 4bit use `load_in_4bit=True` instead
173
+ quantization_config = BitsAndBytesConfig(load_in_8bit=True)
174
+
175
+ checkpoint = "bigcode/starcoder2-15b"
176
+ tokenizer = AutoTokenizer.from_pretrained(checkpoint)
177
+ model = AutoModelForCausalLM.from_pretrained(checkpoint, quantization_config=quantization_config)
178
+
179
+ inputs = tokenizer.encode("def print_hello_world():", return_tensors="pt").to("cuda")
180
+ outputs = model.generate(inputs)
181
+ print(tokenizer.decode(outputs[0]))
182
+ ```
183
+ ```bash
184
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
185
+ # load_in_8bit
186
+ Memory footprint: 16900.18 MB
187
+ # load_in_4bit
188
+ >>> print(f"Memory footprint: {model.get_memory_footprint() / 1e6:.2f} MB")
189
+ Memory footprint: 9224.60 MB
190
+ ```
191
+ ### Attribution & Other Requirements
192
+
193
+ 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 let's you search through the pretraining data to identify where generated code came from and apply the proper attribution to your code.
194
+
195
+ # Limitations
196
+
197
+ 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.
198
+
199
+ # Training
200
+
201
+ ## Model
202
+
203
+ - **Architecture:** Transformer decoder with grouped-query and sliding window attention and Fill-in-the-Middle objective
204
+ - **Pretraining steps:** 1 million
205
+ - **Pretraining tokens:** 4+ trillion
206
+ - **Precision:** bfloat16
207
+
208
+ ## Hardware
209
+
210
+ - **GPUs:** 1024 x H100
211
+
212
+ ## Software
213
+
214
+ - **Framework:** [NeMo Framework](https://www.nvidia.com/en-us/ai-data-science/generative-ai/nemo-framework/)
215
+ - **Neural networks:** [PyTorch](https://github.com/pytorch/pytorch)
216
+
217
+ # License
218
+
219
+ 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).
220
+
221
+ # Citation
222
+
223
+ ```bash
224
+ @misc{lozhkov2024starcoder,
225
+ title={StarCoder 2 and The Stack v2: The Next Generation},
226
+ 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},
227
+ year={2024},
228
+ eprint={2402.19173},
229
+ archivePrefix={arXiv},
230
+ primaryClass={cs.SE}
231
+ }
232
+ ```
233
+