RichardErkhov commited on
Commit
9a610a1
·
verified ·
1 Parent(s): a5c0f40

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +268 -0
README.md ADDED
@@ -0,0 +1,268 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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-128k - AWQ
11
+ - Model creator: https://huggingface.co/ibm-granite/
12
+ - Original model: https://huggingface.co/ibm-granite/granite-3b-code-base-128k/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ pipeline_tag: text-generation
20
+ inference: false
21
+ license: apache-2.0
22
+ datasets:
23
+ - codeparrot/github-code-clean
24
+ - bigcode/starcoderdata
25
+ # - Stackexchange
26
+ # - CommonCrawl
27
+ - open-web-math/open-web-math
28
+ - math-ai/StackMathQA
29
+ # - Arxiv
30
+ # - Wikipedia
31
+ # - conceptofmind/FLAN_2022 # Original link is broken, we used IBM's filtered version
32
+ metrics:
33
+ - code_eval
34
+ library_name: transformers
35
+ tags:
36
+ - code
37
+ - granite
38
+ model-index:
39
+ - name: granite-3b-code-base-128k
40
+ results:
41
+ - task:
42
+ type: text-generation
43
+ dataset:
44
+ type: bigcode/humanevalpack
45
+ name: HumanEvalSynthesis (Python)
46
+ metrics:
47
+ - name: pass@1
48
+ type: pass@1
49
+ value: 36.0
50
+ verified: false
51
+ - task:
52
+ type: text-generation
53
+ dataset:
54
+ type: bigcode/humanevalpack
55
+ name: HumanEvalSynthesis (Average)
56
+ metrics:
57
+ - name: pass@1
58
+ type: pass@1
59
+ value: 30.5
60
+ verified: false
61
+ - task:
62
+ type: text-generation
63
+ dataset:
64
+ type: bigcode/humanevalpack
65
+ name: HumanEvalExplain (Average)
66
+ metrics:
67
+ - name: pass@1
68
+ type: pass@1
69
+ value: 22.4
70
+ verified: false
71
+ - task:
72
+ type: text-generation
73
+ dataset:
74
+ type: bigcode/humanevalpack
75
+ name: HumanEvalFix (Average)
76
+ metrics:
77
+ - name: pass@1
78
+ type: pass@1
79
+ value: 19.9
80
+ verified: false
81
+ - task:
82
+ type: text-generation
83
+ dataset:
84
+ type: repoqa
85
+ name: RepoQA (Python@16K)
86
+ metrics:
87
+ - name: pass@1 (thresh=0.5)
88
+ type: pass@1 (thresh=0.5)
89
+ value: 40.0
90
+ verified: false
91
+ - task:
92
+ type: text-generation
93
+ dataset:
94
+ type: repoqa
95
+ name: RepoQA (C++@16K)
96
+ metrics:
97
+ - name: pass@1 (thresh=0.5)
98
+ type: pass@1 (thresh=0.5)
99
+ value: 36.0
100
+ verified: false
101
+ - task:
102
+ type: text-generation
103
+ dataset:
104
+ type: repoqa
105
+ name: RepoQA (Java@16K)
106
+ metrics:
107
+ - name: pass@1 (thresh=0.5)
108
+ type: pass@1 (thresh=0.5)
109
+ value: 37.0
110
+ verified: false
111
+ - task:
112
+ type: text-generation
113
+ dataset:
114
+ type: repoqa
115
+ name: RepoQA (TypeScript@16K)
116
+ metrics:
117
+ - name: pass@1 (thresh=0.5)
118
+ type: pass@1 (thresh=0.5)
119
+ value: 27.0
120
+ verified: false
121
+ - task:
122
+ type: text-generation
123
+ dataset:
124
+ type: repoqa
125
+ name: RepoQA (Rust@16K)
126
+ metrics:
127
+ - name: pass@1 (thresh=0.5)
128
+ type: pass@1 (thresh=0.5)
129
+ value: 29.0
130
+ verified: false
131
+ - task:
132
+ type: text-generation
133
+ dataset:
134
+ type: lcc
135
+ name: LCC (Balanced)
136
+ metrics:
137
+ - name: Exact Match@4K
138
+ type: Exact Match@4K
139
+ value: 54.6
140
+ verified: false
141
+ - task:
142
+ type: text-generation
143
+ dataset:
144
+ type: lcc
145
+ name: LCC (Balanced)
146
+ metrics:
147
+ - name: Exact Match@8K
148
+ type: Exact Match@8K
149
+ value: 56.8
150
+ verified: false
151
+ - task:
152
+ type: text-generation
153
+ dataset:
154
+ type: lcc
155
+ name: LCC (Balanced)
156
+ metrics:
157
+ - name: Exact Match@16K
158
+ type: Exact Match@16K
159
+ value: 52.2
160
+ verified: false
161
+ - task:
162
+ type: text-generation
163
+ dataset:
164
+ type: lcc
165
+ name: LCC (Balanced)
166
+ metrics:
167
+ - name: Exact Match@32K
168
+ type: Exact Match@32K
169
+ value: 57.8
170
+ verified: false
171
+ - task:
172
+ type: text-generation
173
+ dataset:
174
+ type: repobench
175
+ name: RepoBench-P (Balanced)
176
+ metrics:
177
+ - name: Exact Match@4K
178
+ type: Exact Match@4K
179
+ value: 39.8
180
+ verified: false
181
+ - task:
182
+ type: text-generation
183
+ dataset:
184
+ type: repobench
185
+ name: RepoBench-P (Balanced)
186
+ metrics:
187
+ - name: Exact Match@8K
188
+ type: Exact Match@8K
189
+ value: 46.8
190
+ verified: false
191
+ - task:
192
+ type: text-generation
193
+ dataset:
194
+ type: repobench
195
+ name: RepoBench-P (Balanced)
196
+ metrics:
197
+ - name: Exact Match@16K
198
+ type: Exact Match@16K
199
+ value: 43.1
200
+ verified: false
201
+ - task:
202
+ type: text-generation
203
+ dataset:
204
+ type: repobench
205
+ name: RepoBench-Pn(Balanced)
206
+ metrics:
207
+ - name: Exact Match@32K
208
+ type: Exact Match@32K
209
+ value: 45.3
210
+ verified: false
211
+ ---
212
+
213
+ ![image/png](https://cdn-uploads.huggingface.co/production/uploads/62cd5057674cdb524450093d/1hzxoPwqkBJXshKVVe6_9.png)
214
+
215
+ # Granite-3B-Code-Base-128K
216
+
217
+ ## Model Summary
218
+ **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.
219
+ 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.
220
+
221
+ - **Developers:** IBM Research
222
+ - **GitHub Repository:** [ibm-granite/granite-code-models](https://github.com/ibm-granite/granite-code-models)
223
+ - **Paper:** [Scaling Granite Code Models to 128K Context](https://arxiv.org/abs/2405.04324)
224
+ - **Release Date**: July 18th, 2024
225
+ - **License:** [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0).
226
+
227
+ ## Usage
228
+ ### Intended use
229
+ 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.
230
+
231
+ ### Generation
232
+ This is a simple example of how to use **Granite-3B-Code-Base-128K** model.
233
+
234
+ ```python
235
+ import torch
236
+ from transformers import AutoModelForCausalLM, AutoTokenizer
237
+ device = "cuda" # or "cpu"
238
+ model_path = "ibm-granite/granite-3b-code-base-128k"
239
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
240
+ # drop device_map if running on CPU
241
+ model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
242
+ model.eval()
243
+ # change input text as desired
244
+ input_text = "def generate():"
245
+ # tokenize the text
246
+ input_tokens = tokenizer(input_text, return_tensors="pt")
247
+ # transfer tokenized inputs to the device
248
+ for i in input_tokens:
249
+ input_tokens[i] = input_tokens[i].to(device)
250
+ # generate output tokens
251
+ output = model.generate(**input_tokens)
252
+ # decode output tokens into text
253
+ output = tokenizer.batch_decode(output)
254
+ # loop over the batch to print, in this example the batch size is 1
255
+ for i in output:
256
+ print(i)
257
+ ```
258
+
259
+ ## Training Data
260
+ Starting from the base Granite model, this model was further pretrained on repository-level code data with per-language context-length 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.
261
+
262
+ ## Infrastructure
263
+ 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.
264
+
265
+ ## Ethical Considerations and Limitations
266
+ 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. 
267
+
268
+