rpand002 commited on
Commit
5e8e846
1 Parent(s): 4278875

update readme

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