TechxGenus commited on
Commit
9ed522d
1 Parent(s): 5b52d2b

Upload README.md

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