RichardErkhov commited on
Commit
ad2bf15
1 Parent(s): 5830544

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +326 -0
README.md ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ granite-3b-code-base - GGUF
11
+ - Model creator: https://huggingface.co/ibm-granite/
12
+ - Original model: https://huggingface.co/ibm-granite/granite-3b-code-base/
13
+
14
+
15
+ | Name | Quant method | Size |
16
+ | ---- | ---- | ---- |
17
+ | [granite-3b-code-base.Q2_K.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q2_K.gguf) | Q2_K | 1.25GB |
18
+ | [granite-3b-code-base.IQ3_XS.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.IQ3_XS.gguf) | IQ3_XS | 1.37GB |
19
+ | [granite-3b-code-base.IQ3_S.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.IQ3_S.gguf) | IQ3_S | 1.45GB |
20
+ | [granite-3b-code-base.Q3_K_S.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q3_K_S.gguf) | Q3_K_S | 1.45GB |
21
+ | [granite-3b-code-base.IQ3_M.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.IQ3_M.gguf) | IQ3_M | 1.51GB |
22
+ | [granite-3b-code-base.Q3_K.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q3_K.gguf) | Q3_K | 1.61GB |
23
+ | [granite-3b-code-base.Q3_K_M.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q3_K_M.gguf) | Q3_K_M | 1.61GB |
24
+ | [granite-3b-code-base.Q3_K_L.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q3_K_L.gguf) | Q3_K_L | 1.75GB |
25
+ | [granite-3b-code-base.IQ4_XS.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.IQ4_XS.gguf) | IQ4_XS | 1.78GB |
26
+ | [granite-3b-code-base.Q4_0.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q4_0.gguf) | Q4_0 | 1.86GB |
27
+ | [granite-3b-code-base.IQ4_NL.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.IQ4_NL.gguf) | IQ4_NL | 1.87GB |
28
+ | [granite-3b-code-base.Q4_K_S.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q4_K_S.gguf) | Q4_K_S | 1.88GB |
29
+ | [granite-3b-code-base.Q4_K.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q4_K.gguf) | Q4_K | 1.99GB |
30
+ | [granite-3b-code-base.Q4_K_M.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q4_K_M.gguf) | Q4_K_M | 1.99GB |
31
+ | [granite-3b-code-base.Q4_1.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q4_1.gguf) | Q4_1 | 2.06GB |
32
+ | [granite-3b-code-base.Q5_0.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q5_0.gguf) | Q5_0 | 2.25GB |
33
+ | [granite-3b-code-base.Q5_K_S.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q5_K_S.gguf) | Q5_K_S | 2.25GB |
34
+ | [granite-3b-code-base.Q5_K.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q5_K.gguf) | Q5_K | 2.32GB |
35
+ | [granite-3b-code-base.Q5_K_M.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q5_K_M.gguf) | Q5_K_M | 2.32GB |
36
+ | [granite-3b-code-base.Q5_1.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q5_1.gguf) | Q5_1 | 2.45GB |
37
+ | [granite-3b-code-base.Q6_K.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q6_K.gguf) | Q6_K | 2.67GB |
38
+ | [granite-3b-code-base.Q8_0.gguf](https://huggingface.co/RichardErkhov/ibm-granite_-_granite-3b-code-base-gguf/blob/main/granite-3b-code-base.Q8_0.gguf) | Q8_0 | 3.45GB |
39
+
40
+
41
+
42
+
43
+ Original model description:
44
+ ---
45
+ pipeline_tag: text-generation
46
+ inference: false
47
+ license: apache-2.0
48
+ datasets:
49
+ - codeparrot/github-code-clean
50
+ - bigcode/starcoderdata
51
+ # - Stackexchange
52
+ # - CommonCrawl
53
+ - open-web-math/open-web-math
54
+ - math-ai/StackMathQA
55
+ # - Arxiv
56
+ # - Wikipedia
57
+ # - conceptofmind/FLAN_2022 # Original link is broken, we used IBM's filtered version
58
+ metrics:
59
+ - code_eval
60
+ library_name: transformers
61
+ tags:
62
+ - code
63
+ - granite
64
+ model-index:
65
+ - name: granite-3b-code-base
66
+ results:
67
+ - task:
68
+ type: text-generation
69
+ dataset:
70
+ type: mbpp
71
+ name: MBPP
72
+ metrics:
73
+ - name: pass@1
74
+ type: pass@1
75
+ value: 36.0
76
+ veriefied: false
77
+ - task:
78
+ type: text-generation
79
+ dataset:
80
+ type: evalplus/mbppplus
81
+ name: MBPP+
82
+ metrics:
83
+ - name: pass@1
84
+ type: pass@1
85
+ value: 45.1
86
+ veriefied: false
87
+ - task:
88
+ type: text-generation
89
+ dataset:
90
+ type: bigcode/humanevalpack
91
+ name: HumanEvalSynthesis(Python)
92
+ metrics:
93
+ - name: pass@1
94
+ type: pass@1
95
+ value: 36.6
96
+ veriefied: false
97
+ - task:
98
+ type: text-generation
99
+ dataset:
100
+ type: bigcode/humanevalpack
101
+ name: HumanEvalSynthesis(JavaScript)
102
+ metrics:
103
+ - name: pass@1
104
+ type: pass@1
105
+ value: 37.2
106
+ veriefied: false
107
+ - task:
108
+ type: text-generation
109
+ dataset:
110
+ type: bigcode/humanevalpack
111
+ name: HumanEvalSynthesis(Java)
112
+ metrics:
113
+ - name: pass@1
114
+ type: pass@1
115
+ value: 40.9
116
+ veriefied: false
117
+ - task:
118
+ type: text-generation
119
+ dataset:
120
+ type: bigcode/humanevalpack
121
+ name: HumanEvalSynthesis(Go)
122
+ metrics:
123
+ - name: pass@1
124
+ type: pass@1
125
+ value: 26.2
126
+ veriefied: false
127
+ - task:
128
+ type: text-generation
129
+ dataset:
130
+ type: bigcode/humanevalpack
131
+ name: HumanEvalSynthesis(C++)
132
+ metrics:
133
+ - name: pass@1
134
+ type: pass@1
135
+ value: 35.4
136
+ veriefied: false
137
+ - task:
138
+ type: text-generation
139
+ dataset:
140
+ type: bigcode/humanevalpack
141
+ name: HumanEvalSynthesis(Rust)
142
+ metrics:
143
+ - name: pass@1
144
+ type: pass@1
145
+ value: 22.0
146
+ veriefied: false
147
+ - task:
148
+ type: text-generation
149
+ dataset:
150
+ type: bigcode/humanevalpack
151
+ name: HumanEvalExplain(Python)
152
+ metrics:
153
+ - name: pass@1
154
+ type: pass@1
155
+ value: 25.0
156
+ veriefied: false
157
+ - task:
158
+ type: text-generation
159
+ dataset:
160
+ type: bigcode/humanevalpack
161
+ name: HumanEvalExplain(JavaScript)
162
+ metrics:
163
+ - name: pass@1
164
+ type: pass@1
165
+ value: 18.9
166
+ veriefied: false
167
+ - task:
168
+ type: text-generation
169
+ dataset:
170
+ type: bigcode/humanevalpack
171
+ name: HumanEvalExplain(Java)
172
+ metrics:
173
+ - name: pass@1
174
+ type: pass@1
175
+ value: 29.9
176
+ veriefied: false
177
+ - task:
178
+ type: text-generation
179
+ dataset:
180
+ type: bigcode/humanevalpack
181
+ name: HumanEvalExplain(Go)
182
+ metrics:
183
+ - name: pass@1
184
+ type: pass@1
185
+ value: 17.1
186
+ veriefied: false
187
+ - task:
188
+ type: text-generation
189
+ dataset:
190
+ type: bigcode/humanevalpack
191
+ name: HumanEvalExplain(C++)
192
+ metrics:
193
+ - name: pass@1
194
+ type: pass@1
195
+ value: 26.8
196
+ veriefied: false
197
+ - task:
198
+ type: text-generation
199
+ dataset:
200
+ type: bigcode/humanevalpack
201
+ name: HumanEvalExplain(Rust)
202
+ metrics:
203
+ - name: pass@1
204
+ type: pass@1
205
+ value: 14.0
206
+ veriefied: false
207
+ - task:
208
+ type: text-generation
209
+ dataset:
210
+ type: bigcode/humanevalpack
211
+ name: HumanEvalFix(Python)
212
+ metrics:
213
+ - name: pass@1
214
+ type: pass@1
215
+ value: 18.3
216
+ veriefied: false
217
+ - task:
218
+ type: text-generation
219
+ dataset:
220
+ type: bigcode/humanevalpack
221
+ name: HumanEvalFix(JavaScript)
222
+ metrics:
223
+ - name: pass@1
224
+ type: pass@1
225
+ value: 23.2
226
+ veriefied: false
227
+ - task:
228
+ type: text-generation
229
+ dataset:
230
+ type: bigcode/humanevalpack
231
+ name: HumanEvalFix(Java)
232
+ metrics:
233
+ - name: pass@1
234
+ type: pass@1
235
+ value: 29.9
236
+ veriefied: false
237
+ - task:
238
+ type: text-generation
239
+ dataset:
240
+ type: bigcode/humanevalpack
241
+ name: HumanEvalFix(Go)
242
+ metrics:
243
+ - name: pass@1
244
+ type: pass@1
245
+ value: 24.4
246
+ veriefied: false
247
+ - task:
248
+ type: text-generation
249
+ dataset:
250
+ type: bigcode/humanevalpack
251
+ name: HumanEvalFix(C++)
252
+ metrics:
253
+ - name: pass@1
254
+ type: pass@1
255
+ value: 16.5
256
+ veriefied: false
257
+ - task:
258
+ type: text-generation
259
+ dataset:
260
+ type: bigcode/humanevalpack
261
+ name: HumanEvalFix(Rust)
262
+ metrics:
263
+ - name: pass@1
264
+ type: pass@1
265
+ value: 3.7
266
+ veriefied: false
267
+ ---
268
+
269
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/62cd5057674cdb524450093d/1hzxoPwqkBJXshKVVe6_9.png)
270
+
271
+ # Granite-3B-Code-Base
272
+
273
+ ## Model Summary
274
+ **Granite-3B-Code-Base** is a decoder-only code model designed for code generative tasks (e.g., code generation, code explanation, code fixing, etc.). It is trained from scratch with a two-phase training strategy. In phase 1, our model is trained on 4 trillion tokens sourced from 116 programming languages, ensuring a comprehensive understanding of programming languages and syntax. In phase 2, our model is trained on 500 billion tokens with a carefully designed mixture of high-quality data from code and natural language domains to improve the models’ ability to reason and follow instructions.
275
+
276
+ - **Developers:** IBM Research
277
+ - **GitHub Repository:** [ibm-granite/granite-code-models](https://github.com/ibm-granite/granite-code-models)
278
+ - **Paper:** [Granite Code Models: A Family of Open Foundation Models for Code Intelligence](https://arxiv.org/abs/2405.04324)
279
+ - **Release Date**: May 6th, 2024
280
+ - **License:** [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0).
281
+
282
+ ## Usage
283
+ ### Intended use
284
+ Prominent enterprise use cases of LLMs in software engineering productivity include code generation, code explanation, code fixing, generating unit tests, generating documentation, addressing technical debt issues, vulnerability detection, code translation, and more. All Granite Code Base models, including the **3B parameter model**, are able to handle these tasks as they were trained on a large amount of code data from 116 programming languages.
285
+
286
+ ### Generation
287
+ This is a simple example of how to use **Granite-3B-Code-Base** model.
288
+
289
+ ```python
290
+ import torch
291
+ from transformers import AutoModelForCausalLM, AutoTokenizer
292
+ device = "cuda" # or "cpu"
293
+ model_path = "ibm-granite/granite-3b-code-base"
294
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
295
+ # drop device_map if running on CPU
296
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
297
+ model.eval()
298
+ # change input text as desired
299
+ input_text = "def generate():"
300
+ # tokenize the text
301
+ input_tokens = tokenizer(input_text, return_tensors="pt")
302
+ # transfer tokenized inputs to the device
303
+ for i in input_tokens:
304
+ input_tokens[i] = input_tokens[i].to(device)
305
+ # generate output tokens
306
+ output = model.generate(**input_tokens)
307
+ # decode output tokens into text
308
+ output = tokenizer.batch_decode(output)
309
+ # loop over the batch to print, in this example the batch size is 1
310
+ for i in output:
311
+ print(i)
312
+ ```
313
+
314
+ ## Training Data
315
+ - **Data Collection and Filtering:** Pretraining code data is sourced from a combination of publicly available datasets (e.g., [GitHub Code Clean](https://huggingface.co/datasets/codeparrot/github-code-clean), [Starcoder data](https://huggingface.co/datasets/bigcode/starcoderdata)), and additional public code repositories and issues from GitHub. We filter raw data to retain a list of 116 programming languages. After language filtering, we also filter out low-quality code.
316
+ - **Exact and Fuzzy Deduplication:** We adopt an aggressive deduplication strategy that includes both exact and fuzzy deduplication to remove documents having (near) identical code content.
317
+ - **HAP, PII, Malware Filtering:** We apply a HAP content filter that reduces models' likelihood of generating hateful, abusive, or profane language. We also make sure to redact Personally Identifiable Information (PII) by replacing PII content (e.g., names, email addresses, keys, passwords) with corresponding tokens (e.g., ⟨NAME⟩, ⟨EMAIL⟩, ⟨KEY⟩, ⟨PASSWORD⟩). Moreover, we scan all datasets using [ClamAV](https://www.clamav.net/) to identify and remove instances of malware in the source code.
318
+ - **Natural Language Datasets:** In addition to collecting code data for model training, we curate several publicly available high-quality natural language datasets to improve models' proficiency in language understanding and mathematical reasoning. Unlike the code data, we do not deduplicate these datasets.
319
+
320
+ ## Infrastructure
321
+ We train the Granite Code models using two of IBM's super computing clusters, namely Vela and Blue Vela, both outfitted with NVIDIA A100 and H100 GPUs respectively. These clusters provide a scalable and efficient infrastructure for training our models over thousands of GPUs.
322
+
323
+ ## Ethical Considerations and Limitations
324
+ The use of Large Language Models involves risks and ethical considerations people must be aware of. Regarding code generation, caution is urged against complete reliance on specific code models for crucial decisions or impactful information as the generated code is not guaranteed to work as intended. **Granite-3B-Code-Base** model is not the exception in this regard. Even though this model is suited for multiple code-related tasks, it has not undergone any safety alignment, there it may produce problematic outputs. Additionally, it remains uncertain whether smaller models might exhibit increased susceptibility to hallucination in generation scenarios by copying source code verbatim from the training dataset due to their reduced sizes and memorization capacities. This aspect is currently an active area of research, and we anticipate more rigorous exploration, comprehension, and mitigations in this domain. Regarding ethics, a latent risk associated with all Large Language Models is their malicious utilization. We urge the community to use **Granite-3B-Code-Base** model with ethical intentions and in a responsible way. 
325
+
326
+