Text Generation
Transformers
GGUF
code
granite
Eval Results
munish0838 commited on
Commit
c052a35
1 Parent(s): 41e381c

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +293 -0
README.md ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ---
3
+
4
+ pipeline_tag: text-generation
5
+ inference: false
6
+ license: apache-2.0
7
+ datasets:
8
+ - codeparrot/github-code-clean
9
+ - bigcode/starcoderdata
10
+ # - Stackexchange
11
+ # - CommonCrawl
12
+ - open-web-math/open-web-math
13
+ - math-ai/StackMathQA
14
+ # - Arxiv
15
+ # - Wikipedia
16
+ # - conceptofmind/FLAN_2022 # Original link is broken, we used IBM's filtered version
17
+ metrics:
18
+ - code_eval
19
+ library_name: transformers
20
+ tags:
21
+ - code
22
+ - granite
23
+ model-index:
24
+ - name: granite-3b-code-base-2k
25
+ results:
26
+ - task:
27
+ type: text-generation
28
+ dataset:
29
+ type: mbpp
30
+ name: MBPP
31
+ metrics:
32
+ - name: pass@1
33
+ type: pass@1
34
+ value: 36.0
35
+ veriefied: false
36
+ - task:
37
+ type: text-generation
38
+ dataset:
39
+ type: evalplus/mbppplus
40
+ name: MBPP+
41
+ metrics:
42
+ - name: pass@1
43
+ type: pass@1
44
+ value: 45.1
45
+ veriefied: false
46
+ - task:
47
+ type: text-generation
48
+ dataset:
49
+ type: bigcode/humanevalpack
50
+ name: HumanEvalSynthesis(Python)
51
+ metrics:
52
+ - name: pass@1
53
+ type: pass@1
54
+ value: 36.6
55
+ veriefied: false
56
+ - task:
57
+ type: text-generation
58
+ dataset:
59
+ type: bigcode/humanevalpack
60
+ name: HumanEvalSynthesis(JavaScript)
61
+ metrics:
62
+ - name: pass@1
63
+ type: pass@1
64
+ value: 37.2
65
+ veriefied: false
66
+ - task:
67
+ type: text-generation
68
+ dataset:
69
+ type: bigcode/humanevalpack
70
+ name: HumanEvalSynthesis(Java)
71
+ metrics:
72
+ - name: pass@1
73
+ type: pass@1
74
+ value: 40.9
75
+ veriefied: false
76
+ - task:
77
+ type: text-generation
78
+ dataset:
79
+ type: bigcode/humanevalpack
80
+ name: HumanEvalSynthesis(Go)
81
+ metrics:
82
+ - name: pass@1
83
+ type: pass@1
84
+ value: 26.2
85
+ veriefied: false
86
+ - task:
87
+ type: text-generation
88
+ dataset:
89
+ type: bigcode/humanevalpack
90
+ name: HumanEvalSynthesis(C++)
91
+ metrics:
92
+ - name: pass@1
93
+ type: pass@1
94
+ value: 35.4
95
+ veriefied: false
96
+ - task:
97
+ type: text-generation
98
+ dataset:
99
+ type: bigcode/humanevalpack
100
+ name: HumanEvalSynthesis(Rust)
101
+ metrics:
102
+ - name: pass@1
103
+ type: pass@1
104
+ value: 22.0
105
+ veriefied: false
106
+ - task:
107
+ type: text-generation
108
+ dataset:
109
+ type: bigcode/humanevalpack
110
+ name: HumanEvalExplain(Python)
111
+ metrics:
112
+ - name: pass@1
113
+ type: pass@1
114
+ value: 25.0
115
+ veriefied: false
116
+ - task:
117
+ type: text-generation
118
+ dataset:
119
+ type: bigcode/humanevalpack
120
+ name: HumanEvalExplain(JavaScript)
121
+ metrics:
122
+ - name: pass@1
123
+ type: pass@1
124
+ value: 18.9
125
+ veriefied: false
126
+ - task:
127
+ type: text-generation
128
+ dataset:
129
+ type: bigcode/humanevalpack
130
+ name: HumanEvalExplain(Java)
131
+ metrics:
132
+ - name: pass@1
133
+ type: pass@1
134
+ value: 29.9
135
+ veriefied: false
136
+ - task:
137
+ type: text-generation
138
+ dataset:
139
+ type: bigcode/humanevalpack
140
+ name: HumanEvalExplain(Go)
141
+ metrics:
142
+ - name: pass@1
143
+ type: pass@1
144
+ value: 17.1
145
+ veriefied: false
146
+ - task:
147
+ type: text-generation
148
+ dataset:
149
+ type: bigcode/humanevalpack
150
+ name: HumanEvalExplain(C++)
151
+ metrics:
152
+ - name: pass@1
153
+ type: pass@1
154
+ value: 26.8
155
+ veriefied: false
156
+ - task:
157
+ type: text-generation
158
+ dataset:
159
+ type: bigcode/humanevalpack
160
+ name: HumanEvalExplain(Rust)
161
+ metrics:
162
+ - name: pass@1
163
+ type: pass@1
164
+ value: 14.0
165
+ veriefied: false
166
+ - task:
167
+ type: text-generation
168
+ dataset:
169
+ type: bigcode/humanevalpack
170
+ name: HumanEvalFix(Python)
171
+ metrics:
172
+ - name: pass@1
173
+ type: pass@1
174
+ value: 18.3
175
+ veriefied: false
176
+ - task:
177
+ type: text-generation
178
+ dataset:
179
+ type: bigcode/humanevalpack
180
+ name: HumanEvalFix(JavaScript)
181
+ metrics:
182
+ - name: pass@1
183
+ type: pass@1
184
+ value: 23.2
185
+ veriefied: false
186
+ - task:
187
+ type: text-generation
188
+ dataset:
189
+ type: bigcode/humanevalpack
190
+ name: HumanEvalFix(Java)
191
+ metrics:
192
+ - name: pass@1
193
+ type: pass@1
194
+ value: 29.9
195
+ veriefied: false
196
+ - task:
197
+ type: text-generation
198
+ dataset:
199
+ type: bigcode/humanevalpack
200
+ name: HumanEvalFix(Go)
201
+ metrics:
202
+ - name: pass@1
203
+ type: pass@1
204
+ value: 24.4
205
+ veriefied: false
206
+ - task:
207
+ type: text-generation
208
+ dataset:
209
+ type: bigcode/humanevalpack
210
+ name: HumanEvalFix(C++)
211
+ metrics:
212
+ - name: pass@1
213
+ type: pass@1
214
+ value: 16.5
215
+ veriefied: false
216
+ - task:
217
+ type: text-generation
218
+ dataset:
219
+ type: bigcode/humanevalpack
220
+ name: HumanEvalFix(Rust)
221
+ metrics:
222
+ - name: pass@1
223
+ type: pass@1
224
+ value: 3.7
225
+ veriefied: false
226
+
227
+ ---
228
+
229
+ ![](https://lh7-rt.googleusercontent.com/docsz/AD_4nXeiuCm7c8lEwEJuRey9kiVZsRn2W-b4pWlu3-X534V3YmVuVc2ZL-NXg2RkzSOOS2JXGHutDuyyNAUtdJI65jGTo8jT9Y99tMi4H4MqL44Uc5QKG77B0d6-JfIkZHFaUA71-RtjyYZWVIhqsNZcx8-OMaA?key=xt3VSDoCbmTY7o-cwwOFwQ)
230
+
231
+ # QuantFactory/granite-3b-code-base-2k-GGUF
232
+ This is quantized version of [ibm-granite/granite-3b-code-base-2k](https://huggingface.co/ibm-granite/granite-3b-code-base-2k) created using llama.cpp
233
+
234
+ # Original Model Card
235
+
236
+
237
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/62cd5057674cdb524450093d/1hzxoPwqkBJXshKVVe6_9.png)
238
+
239
+ # Granite-3B-Code-Base-2K
240
+
241
+ ## Model Summary
242
+ **Granite-3B-Code-Base-2K** 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.
243
+
244
+ - **Developers:** IBM Research
245
+ - **GitHub Repository:** [ibm-granite/granite-code-models](https://github.com/ibm-granite/granite-code-models)
246
+ - **Paper:** [Granite Code Models: A Family of Open Foundation Models for Code Intelligence](https://arxiv.org/abs/2405.04324)
247
+ - **Release Date**: May 6th, 2024
248
+ - **License:** [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0).
249
+
250
+ ## Usage
251
+ ### Intended use
252
+ 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.
253
+
254
+ ### Generation
255
+ This is a simple example of how to use **Granite-3B-Code-Base-2K** model.
256
+
257
+ ```python
258
+ import torch
259
+ from transformers import AutoModelForCausalLM, AutoTokenizer
260
+ device = "cuda" # or "cpu"
261
+ model_path = "ibm-granite/granite-3b-code-base-2k"
262
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
263
+ # drop device_map if running on CPU
264
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
265
+ model.eval()
266
+ # change input text as desired
267
+ input_text = "def generate():"
268
+ # tokenize the text
269
+ input_tokens = tokenizer(input_text, return_tensors="pt")
270
+ # transfer tokenized inputs to the device
271
+ for i in input_tokens:
272
+ input_tokens[i] = input_tokens[i].to(device)
273
+ # generate output tokens
274
+ output = model.generate(**input_tokens)
275
+ # decode output tokens into text
276
+ output = tokenizer.batch_decode(output)
277
+ # loop over the batch to print, in this example the batch size is 1
278
+ for i in output:
279
+ print(i)
280
+ ```
281
+
282
+ ## Training Data
283
+ - **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.
284
+ - **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.
285
+ - **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.
286
+ - **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.
287
+
288
+ ## Infrastructure
289
+ 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.
290
+
291
+ ## Ethical Considerations and Limitations
292
+ 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-2K** 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-2K** model with ethical intentions and in a responsible way. 
293
+