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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-8b-code-instruct - bnb 4bits
|
11 |
+
- Model creator: https://huggingface.co/ibm-granite/
|
12 |
+
- Original model: https://huggingface.co/ibm-granite/granite-8b-code-instruct/
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
Original model description:
|
18 |
+
---
|
19 |
+
pipeline_tag: text-generation
|
20 |
+
base_model: ibm-granite/granite-8b-code-base
|
21 |
+
inference: false
|
22 |
+
license: apache-2.0
|
23 |
+
datasets:
|
24 |
+
- bigcode/commitpackft
|
25 |
+
- TIGER-Lab/MathInstruct
|
26 |
+
- meta-math/MetaMathQA
|
27 |
+
- glaiveai/glaive-code-assistant-v3
|
28 |
+
- glaive-function-calling-v2
|
29 |
+
- bugdaryan/sql-create-context-instruction
|
30 |
+
- garage-bAInd/Open-Platypus
|
31 |
+
- nvidia/HelpSteer
|
32 |
+
metrics:
|
33 |
+
- code_eval
|
34 |
+
library_name: transformers
|
35 |
+
tags:
|
36 |
+
- code
|
37 |
+
- granite
|
38 |
+
model-index:
|
39 |
+
- name: granite-8b-code-instruct
|
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: 57.9
|
50 |
+
veriefied: false
|
51 |
+
- task:
|
52 |
+
type: text-generation
|
53 |
+
dataset:
|
54 |
+
type: bigcode/humanevalpack
|
55 |
+
name: HumanEvalSynthesis(JavaScript)
|
56 |
+
metrics:
|
57 |
+
- name: pass@1
|
58 |
+
type: pass@1
|
59 |
+
value: 52.4
|
60 |
+
veriefied: false
|
61 |
+
- task:
|
62 |
+
type: text-generation
|
63 |
+
dataset:
|
64 |
+
type: bigcode/humanevalpack
|
65 |
+
name: HumanEvalSynthesis(Java)
|
66 |
+
metrics:
|
67 |
+
- name: pass@1
|
68 |
+
type: pass@1
|
69 |
+
value: 58.5
|
70 |
+
veriefied: false
|
71 |
+
- task:
|
72 |
+
type: text-generation
|
73 |
+
dataset:
|
74 |
+
type: bigcode/humanevalpack
|
75 |
+
name: HumanEvalSynthesis(Go)
|
76 |
+
metrics:
|
77 |
+
- name: pass@1
|
78 |
+
type: pass@1
|
79 |
+
value: 43.3
|
80 |
+
veriefied: false
|
81 |
+
- task:
|
82 |
+
type: text-generation
|
83 |
+
dataset:
|
84 |
+
type: bigcode/humanevalpack
|
85 |
+
name: HumanEvalSynthesis(C++)
|
86 |
+
metrics:
|
87 |
+
- name: pass@1
|
88 |
+
type: pass@1
|
89 |
+
value: 48.2
|
90 |
+
veriefied: false
|
91 |
+
- task:
|
92 |
+
type: text-generation
|
93 |
+
dataset:
|
94 |
+
type: bigcode/humanevalpack
|
95 |
+
name: HumanEvalSynthesis(Rust)
|
96 |
+
metrics:
|
97 |
+
- name: pass@1
|
98 |
+
type: pass@1
|
99 |
+
value: 37.2
|
100 |
+
veriefied: false
|
101 |
+
- task:
|
102 |
+
type: text-generation
|
103 |
+
dataset:
|
104 |
+
type: bigcode/humanevalpack
|
105 |
+
name: HumanEvalExplain(Python)
|
106 |
+
metrics:
|
107 |
+
- name: pass@1
|
108 |
+
type: pass@1
|
109 |
+
value: 53.0
|
110 |
+
veriefied: false
|
111 |
+
- task:
|
112 |
+
type: text-generation
|
113 |
+
dataset:
|
114 |
+
type: bigcode/humanevalpack
|
115 |
+
name: HumanEvalExplain(JavaScript)
|
116 |
+
metrics:
|
117 |
+
- name: pass@1
|
118 |
+
type: pass@1
|
119 |
+
value: 42.7
|
120 |
+
veriefied: false
|
121 |
+
- task:
|
122 |
+
type: text-generation
|
123 |
+
dataset:
|
124 |
+
type: bigcode/humanevalpack
|
125 |
+
name: HumanEvalExplain(Java)
|
126 |
+
metrics:
|
127 |
+
- name: pass@1
|
128 |
+
type: pass@1
|
129 |
+
value: 52.4
|
130 |
+
veriefied: false
|
131 |
+
- task:
|
132 |
+
type: text-generation
|
133 |
+
dataset:
|
134 |
+
type: bigcode/humanevalpack
|
135 |
+
name: HumanEvalExplain(Go)
|
136 |
+
metrics:
|
137 |
+
- name: pass@1
|
138 |
+
type: pass@1
|
139 |
+
value: 36.6
|
140 |
+
veriefied: false
|
141 |
+
- task:
|
142 |
+
type: text-generation
|
143 |
+
dataset:
|
144 |
+
type: bigcode/humanevalpack
|
145 |
+
name: HumanEvalExplain(C++)
|
146 |
+
metrics:
|
147 |
+
- name: pass@1
|
148 |
+
type: pass@1
|
149 |
+
value: 43.9
|
150 |
+
veriefied: false
|
151 |
+
- task:
|
152 |
+
type: text-generation
|
153 |
+
dataset:
|
154 |
+
type: bigcode/humanevalpack
|
155 |
+
name: HumanEvalExplain(Rust)
|
156 |
+
metrics:
|
157 |
+
- name: pass@1
|
158 |
+
type: pass@1
|
159 |
+
value: 16.5
|
160 |
+
veriefied: false
|
161 |
+
- task:
|
162 |
+
type: text-generation
|
163 |
+
dataset:
|
164 |
+
type: bigcode/humanevalpack
|
165 |
+
name: HumanEvalFix(Python)
|
166 |
+
metrics:
|
167 |
+
- name: pass@1
|
168 |
+
type: pass@1
|
169 |
+
value: 39.6
|
170 |
+
veriefied: false
|
171 |
+
- task:
|
172 |
+
type: text-generation
|
173 |
+
dataset:
|
174 |
+
type: bigcode/humanevalpack
|
175 |
+
name: HumanEvalFix(JavaScript)
|
176 |
+
metrics:
|
177 |
+
- name: pass@1
|
178 |
+
type: pass@1
|
179 |
+
value: 40.9
|
180 |
+
veriefied: false
|
181 |
+
- task:
|
182 |
+
type: text-generation
|
183 |
+
dataset:
|
184 |
+
type: bigcode/humanevalpack
|
185 |
+
name: HumanEvalFix(Java)
|
186 |
+
metrics:
|
187 |
+
- name: pass@1
|
188 |
+
type: pass@1
|
189 |
+
value: 48.2
|
190 |
+
veriefied: false
|
191 |
+
- task:
|
192 |
+
type: text-generation
|
193 |
+
dataset:
|
194 |
+
type: bigcode/humanevalpack
|
195 |
+
name: HumanEvalFix(Go)
|
196 |
+
metrics:
|
197 |
+
- name: pass@1
|
198 |
+
type: pass@1
|
199 |
+
value: 41.5
|
200 |
+
veriefied: false
|
201 |
+
- task:
|
202 |
+
type: text-generation
|
203 |
+
dataset:
|
204 |
+
type: bigcode/humanevalpack
|
205 |
+
name: HumanEvalFix(C++)
|
206 |
+
metrics:
|
207 |
+
- name: pass@1
|
208 |
+
type: pass@1
|
209 |
+
value: 39.0
|
210 |
+
veriefied: false
|
211 |
+
- task:
|
212 |
+
type: text-generation
|
213 |
+
dataset:
|
214 |
+
type: bigcode/humanevalpack
|
215 |
+
name: HumanEvalFix(Rust)
|
216 |
+
metrics:
|
217 |
+
- name: pass@1
|
218 |
+
type: pass@1
|
219 |
+
value: 32.9
|
220 |
+
veriefied: false
|
221 |
+
---
|
222 |
+
|
223 |
+
![image/png](https://cdn-uploads.huggingface.co/production/uploads/62cd5057674cdb524450093d/1hzxoPwqkBJXshKVVe6_9.png)
|
224 |
+
|
225 |
+
# Granite-8B-Code-Instruct
|
226 |
+
|
227 |
+
## Model Summary
|
228 |
+
**Granite-8B-Code-Instruct** is a 8B parameter model fine tuned from *Granite-8B-Code-Base* on a combination of **permissively licensed** instruction data to enhance instruction following capabilities including logical reasoning and problem-solving skills.
|
229 |
+
|
230 |
+
- **Developers:** IBM Research
|
231 |
+
- **GitHub Repository:** [ibm-granite/granite-code-models](https://github.com/ibm-granite/granite-code-models)
|
232 |
+
- **Paper:** [Granite Code Models: A Family of Open Foundation Models for Code Intelligence](https://arxiv.org/abs/2405.04324)
|
233 |
+
- **Release Date**: May 6th, 2024
|
234 |
+
- **License:** [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0).
|
235 |
+
|
236 |
+
## Usage
|
237 |
+
> [!WARNING]
|
238 |
+
> **You need to build transformers from source to use this model correctly.**
|
239 |
+
> Relevant PR: https://github.com/huggingface/transformers/pull/30031
|
240 |
+
> ```shell
|
241 |
+
> git clone https://github.com/huggingface/transformers
|
242 |
+
> cd transformers/
|
243 |
+
> pip install ./
|
244 |
+
> cd ..
|
245 |
+
> ```
|
246 |
+
|
247 |
+
### Intended use
|
248 |
+
The model is designed to respond to coding related instructions and can be used to build coding assitants.
|
249 |
+
|
250 |
+
<!-- TO DO: Check starcoder2 instruct code example that includes the template https://huggingface.co/bigcode/starcoder2-15b-instruct-v0.1 -->
|
251 |
+
|
252 |
+
### Generation
|
253 |
+
This is a simple example of how to use **Granite-8B-Code-Instruct** model.
|
254 |
+
|
255 |
+
```python
|
256 |
+
import torch
|
257 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
258 |
+
device = "cuda" # or "cpu"
|
259 |
+
model_path = "ibm-granite/granite-8b-code-instruct"
|
260 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
261 |
+
# drop device_map if running on CPU
|
262 |
+
model = AutoModelForCausalLM.from_pretrained(model_path, device_map=device)
|
263 |
+
model.eval()
|
264 |
+
# change input text as desired
|
265 |
+
chat = [
|
266 |
+
{ "role": "user", "content": "Write a code to find the maximum value in a list of numbers." },
|
267 |
+
]
|
268 |
+
chat = tokenizer.apply_chat_template(chat, tokenize=False, add_generation_prompt=True)
|
269 |
+
# tokenize the text
|
270 |
+
input_tokens = tokenizer(chat, return_tensors="pt")
|
271 |
+
# transfer tokenized inputs to the device
|
272 |
+
for i in input_tokens:
|
273 |
+
input_tokens[i] = input_tokens[i].to(device)
|
274 |
+
# generate output tokens
|
275 |
+
output = model.generate(**input_tokens, max_new_tokens=100)
|
276 |
+
# decode output tokens into text
|
277 |
+
output = tokenizer.batch_decode(output)
|
278 |
+
# loop over the batch to print, in this example the batch size is 1
|
279 |
+
for i in output:
|
280 |
+
print(i)
|
281 |
+
```
|
282 |
+
|
283 |
+
<!-- TO DO: Check this part -->
|
284 |
+
## Training Data
|
285 |
+
Granite Code Instruct models are trained on the following types of data.
|
286 |
+
* Code Commits Datasets: we sourced code commits data from the [CommitPackFT](https://huggingface.co/datasets/bigcode/commitpackft) dataset, a filtered version of the full CommitPack dataset. From CommitPackFT dataset, we only consider data for 92 programming languages. Our inclusion criteria boils down to selecting programming languages common across CommitPackFT and the 116 languages that we considered to pretrain the code-base model (*Granite-8B-Code-Base*).
|
287 |
+
* Math Datasets: We consider two high-quality math datasets, [MathInstruct](https://huggingface.co/datasets/TIGER-Lab/MathInstruct) and [MetaMathQA](https://huggingface.co/datasets/meta-math/MetaMathQA). Due to license issues, we filtered out GSM8K-RFT and Camel-Math from MathInstruct dataset.
|
288 |
+
* Code Instruction Datasets: We use [Glaive-Code-Assistant-v3](https://huggingface.co/datasets/glaiveai/glaive-code-assistant-v3), [Glaive-Function-Calling-v2](https://huggingface.co/datasets/glaiveai/glaive-function-calling-v2), [NL2SQL11](https://huggingface.co/datasets/bugdaryan/sql-create-context-instruction) and a small collection of synthetic API calling datasets.
|
289 |
+
* Language Instruction Datasets: We include high-quality datasets such as [HelpSteer](https://huggingface.co/datasets/nvidia/HelpSteer) and an open license-filtered version of [Platypus](https://huggingface.co/datasets/garage-bAInd/Open-Platypus). We also include a collection of hardcoded prompts to ensure our model generates correct outputs given inquiries about its name or developers.
|
290 |
+
|
291 |
+
## Infrastructure
|
292 |
+
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.
|
293 |
+
|
294 |
+
## Ethical Considerations and Limitations
|
295 |
+
Granite code instruct models are primarily finetuned using instruction-response pairs across a specific set of programming languages. Thus, their performance may be limited with out-of-domain programming languages. In this situation, it is beneficial providing few-shot examples to steer the model's output. Moreover, developers should perform safety testing and target-specific tuning before deploying these models on critical applications. The model also inherits ethical considerations and limitations from its base model. For more information, please refer to *[Granite-8B-Code-Base](https://huggingface.co/ibm-granite/granite-8b-code-base)* model card.
|
296 |
+
|
297 |
+
|