Initial GPTQ model commit
Browse files
README.md
ADDED
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
inference: false
|
3 |
+
license: llama2
|
4 |
+
model-index:
|
5 |
+
- name: Phind-CodeLlama-34B-v1
|
6 |
+
results:
|
7 |
+
- dataset:
|
8 |
+
name: HumanEval
|
9 |
+
type: openai_humaneval
|
10 |
+
metrics:
|
11 |
+
- name: pass@1
|
12 |
+
type: pass@1
|
13 |
+
value: 67.6%
|
14 |
+
verified: false
|
15 |
+
task:
|
16 |
+
type: text-generation
|
17 |
+
model_creator: Phind
|
18 |
+
model_link: https://huggingface.co/Phind/Phind-CodeLlama-34B-v1
|
19 |
+
model_name: Phind CodeLlama 34B v1
|
20 |
+
model_type: llama
|
21 |
+
quantized_by: TheBloke
|
22 |
+
tags:
|
23 |
+
- code llama
|
24 |
+
---
|
25 |
+
|
26 |
+
<!-- header start -->
|
27 |
+
<!-- 200823 -->
|
28 |
+
<div style="width: auto; margin-left: auto; margin-right: auto">
|
29 |
+
<img src="https://i.imgur.com/EBdldam.jpg" alt="TheBlokeAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
|
30 |
+
</div>
|
31 |
+
<div style="display: flex; justify-content: space-between; width: 100%;">
|
32 |
+
<div style="display: flex; flex-direction: column; align-items: flex-start;">
|
33 |
+
<p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://discord.gg/theblokeai">Chat & support: TheBloke's Discord server</a></p>
|
34 |
+
</div>
|
35 |
+
<div style="display: flex; flex-direction: column; align-items: flex-end;">
|
36 |
+
<p style="margin-top: 0.5em; margin-bottom: 0em;"><a href="https://www.patreon.com/TheBlokeAI">Want to contribute? TheBloke's Patreon page</a></p>
|
37 |
+
</div>
|
38 |
+
</div>
|
39 |
+
<div style="text-align:center; margin-top: 0em; margin-bottom: 0em"><p style="margin-top: 0.25em; margin-bottom: 0em;">TheBloke's LLM work is generously supported by a grant from <a href="https://a16z.com">andreessen horowitz (a16z)</a></p></div>
|
40 |
+
<hr style="margin-top: 1.0em; margin-bottom: 1.0em;">
|
41 |
+
<!-- header end -->
|
42 |
+
|
43 |
+
# Phind CodeLlama 34B v1 - GPTQ
|
44 |
+
- Model creator: [Phind](https://huggingface.co/Phind)
|
45 |
+
- Original model: [Phind CodeLlama 34B v1](https://huggingface.co/Phind/Phind-CodeLlama-34B-v1)
|
46 |
+
|
47 |
+
## Description
|
48 |
+
|
49 |
+
This repo contains GPTQ model files for [Phind's Phind CodeLlama 34B v1](https://huggingface.co/Phind/Phind-CodeLlama-34B-v1).
|
50 |
+
|
51 |
+
Multiple GPTQ parameter permutations are provided; see Provided Files below for details of the options provided, their parameters, and the software used to create them.
|
52 |
+
|
53 |
+
## Repositories available
|
54 |
+
|
55 |
+
* [GPTQ models for GPU inference, with multiple quantisation parameter options.](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GPTQ)
|
56 |
+
* [2, 3, 4, 5, 6 and 8-bit GGUF models for CPU+GPU inference](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GGUF)
|
57 |
+
* [2, 3, 4, 5, 6 and 8-bit GGML models for CPU+GPU inference (deprecated)](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GGML)
|
58 |
+
* [Phind's original unquantised fp16 model in pytorch format, for GPU inference and for further conversions](https://huggingface.co/Phind/Phind-CodeLlama-34B-v1)
|
59 |
+
|
60 |
+
## Prompt template: Plain-with-newline
|
61 |
+
|
62 |
+
```
|
63 |
+
{prompt} \n
|
64 |
+
```
|
65 |
+
|
66 |
+
## Provided files and GPTQ parameters
|
67 |
+
|
68 |
+
Multiple quantisation parameters are provided, to allow you to choose the best one for your hardware and requirements.
|
69 |
+
|
70 |
+
Each separate quant is in a different branch. See below for instructions on fetching from different branches.
|
71 |
+
|
72 |
+
All GPTQ files are made with AutoGPTQ.
|
73 |
+
|
74 |
+
<details>
|
75 |
+
<summary>Explanation of GPTQ parameters</summary>
|
76 |
+
|
77 |
+
- Bits: The bit size of the quantised model.
|
78 |
+
- GS: GPTQ group size. Higher numbers use less VRAM, but have lower quantisation accuracy. "None" is the lowest possible value.
|
79 |
+
- Act Order: True or False. Also known as `desc_act`. True results in better quantisation accuracy. Some GPTQ clients have issues with models that use Act Order plus Group Size.
|
80 |
+
- Damp %: A GPTQ parameter that affects how samples are processed for quantisation. 0.01 is default, but 0.1 results in slightly better accuracy.
|
81 |
+
- GPTQ dataset: The dataset used for quantisation. Using a dataset more appropriate to the model's training can improve quantisation accuracy. Note that the GPTQ dataset is not the same as the dataset used to train the model - please refer to the original model repo for details of the training dataset(s).
|
82 |
+
- Sequence Length: The length of the dataset sequences used for quantisation. Ideally this is the same as the model sequence length. For some very long sequence models (16+K), a lower sequence length may have to be used. Note that a lower sequence length does not limit the sequence length of the quantised model. It only impacts the quantisation accuracy on longer inference sequences.
|
83 |
+
- ExLlama Compatibility: Whether this file can be loaded with ExLlama, which currently only supports Llama models in 4-bit.
|
84 |
+
|
85 |
+
</details>
|
86 |
+
|
87 |
+
| Branch | Bits | GS | Act Order | Damp % | GPTQ Dataset | Seq Len | Size | ExLlama | Desc |
|
88 |
+
| ------ | ---- | -- | --------- | ------ | ------------ | ------- | ---- | ------- | ---- |
|
89 |
+
| [main](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GPTQ/tree/main) | 4 | None | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 8192 | 17.69 GB | Yes | Most compatible option. Good inference speed in AutoGPTQ and GPTQ-for-LLaMa. Lower inference quality than other options. |
|
90 |
+
| [gptq-4bit-32g-actorder_True](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GPTQ/tree/gptq-4bit-32g-actorder_True) | 4 | 32 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 8192 | 20.28 GB | Yes | 4-bit, with Act Order and group size 32g. Gives highest possible inference quality, with maximum VRAM usage. Poor AutoGPTQ CUDA speed. |
|
91 |
+
| [gptq-4bit-64g-actorder_True](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GPTQ/tree/gptq-4bit-64g-actorder_True) | 4 | 64 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 8192 | 18.98 GB | Yes | 4-bit, with Act Order and group size 64g. Uses less VRAM than 32g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
|
92 |
+
| [gptq-4bit-128g-actorder_True](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GPTQ/tree/gptq-4bit-128g-actorder_True) | 4 | 128 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 8192 | 18.33 GB | Yes | 4-bit, with Act Order and group size 128g. Uses even less VRAM than 64g, but with slightly lower accuracy. Poor AutoGPTQ CUDA speed. |
|
93 |
+
| [gptq-3bit--1g-actorder_True](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GPTQ/tree/gptq-3bit--1g-actorder_True) | 3 | None | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 8192 | 13.54 GB | No | 3-bit, with Act Order and no group size. Lowest possible VRAM requirements. May be lower quality than 3-bit 128g. |
|
94 |
+
| [gptq-3bit-128g-actorder_True](https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GPTQ/tree/gptq-3bit-128g-actorder_True) | 3 | 128 | Yes | 0.1 | [Evol Instruct Code](https://huggingface.co/datasets/nickrosh/Evol-Instruct-Code-80k-v1) | 8192 | 14.14 GB | No | 3-bit, with group size 128g and act-order. Higher quality than 128g-False but poor AutoGPTQ CUDA speed. |
|
95 |
+
|
96 |
+
## How to download from branches
|
97 |
+
|
98 |
+
- In text-generation-webui, you can add `:branch` to the end of the download name, eg `TheBloke/Phind-CodeLlama-34B-v1-GPTQ:gptq-4bit-32g-actorder_True`
|
99 |
+
- With Git, you can clone a branch with:
|
100 |
+
```
|
101 |
+
git clone --single-branch --branch gptq-4bit-32g-actorder_True https://huggingface.co/TheBloke/Phind-CodeLlama-34B-v1-GPTQ
|
102 |
+
```
|
103 |
+
- In Python Transformers code, the branch is the `revision` parameter; see below.
|
104 |
+
|
105 |
+
## How to easily download and use this model in [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
|
106 |
+
|
107 |
+
Please make sure you're using the latest version of [text-generation-webui](https://github.com/oobabooga/text-generation-webui).
|
108 |
+
|
109 |
+
It is strongly recommended to use the text-generation-webui one-click-installers unless you know how to make a manual install.
|
110 |
+
|
111 |
+
1. Click the **Model tab**.
|
112 |
+
2. Under **Download custom model or LoRA**, enter `TheBloke/Phind-CodeLlama-34B-v1-GPTQ`.
|
113 |
+
- To download from a specific branch, enter for example `TheBloke/Phind-CodeLlama-34B-v1-GPTQ:gptq-4bit-32g-actorder_True`
|
114 |
+
- see Provided Files above for the list of branches for each option.
|
115 |
+
3. Click **Download**.
|
116 |
+
4. The model will start downloading. Once it's finished it will say "Done"
|
117 |
+
5. In the top left, click the refresh icon next to **Model**.
|
118 |
+
6. In the **Model** dropdown, choose the model you just downloaded: `Phind-CodeLlama-34B-v1-GPTQ`
|
119 |
+
7. The model will automatically load, and is now ready for use!
|
120 |
+
8. If you want any custom settings, set them and then click **Save settings for this model** followed by **Reload the Model** in the top right.
|
121 |
+
* Note that you do not need to set GPTQ parameters any more. These are set automatically from the file `quantize_config.json`.
|
122 |
+
9. Once you're ready, click the **Text Generation tab** and enter a prompt to get started!
|
123 |
+
|
124 |
+
## How to use this GPTQ model from Python code
|
125 |
+
|
126 |
+
First make sure you have [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ) 0.3.1 or later installed:
|
127 |
+
|
128 |
+
```
|
129 |
+
pip3 install auto-gptq
|
130 |
+
```
|
131 |
+
|
132 |
+
If you have problems installing AutoGPTQ, please build from source instead:
|
133 |
+
```
|
134 |
+
pip3 uninstall -y auto-gptq
|
135 |
+
git clone https://github.com/PanQiWei/AutoGPTQ
|
136 |
+
cd AutoGPTQ
|
137 |
+
pip3 install .
|
138 |
+
```
|
139 |
+
|
140 |
+
Then try the following example code:
|
141 |
+
|
142 |
+
```python
|
143 |
+
from transformers import AutoTokenizer, pipeline, logging
|
144 |
+
from auto_gptq import AutoGPTQForCausalLM, BaseQuantizeConfig
|
145 |
+
|
146 |
+
model_name_or_path = "TheBloke/Phind-CodeLlama-34B-v1-GPTQ"
|
147 |
+
|
148 |
+
use_triton = False
|
149 |
+
|
150 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=True)
|
151 |
+
|
152 |
+
model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
|
153 |
+
use_safetensors=True,
|
154 |
+
trust_remote_code=False,
|
155 |
+
device="cuda:0",
|
156 |
+
use_triton=use_triton,
|
157 |
+
quantize_config=None)
|
158 |
+
|
159 |
+
"""
|
160 |
+
# To download from a specific branch, use the revision parameter, as in this example:
|
161 |
+
# Note that `revision` requires AutoGPTQ 0.3.1 or later!
|
162 |
+
|
163 |
+
model = AutoGPTQForCausalLM.from_quantized(model_name_or_path,
|
164 |
+
revision="gptq-4bit-32g-actorder_True",
|
165 |
+
use_safetensors=True,
|
166 |
+
trust_remote_code=False,
|
167 |
+
device="cuda:0",
|
168 |
+
quantize_config=None)
|
169 |
+
"""
|
170 |
+
|
171 |
+
prompt = "Tell me about AI"
|
172 |
+
prompt_template=f'''{prompt} \n
|
173 |
+
'''
|
174 |
+
|
175 |
+
print("\n\n*** Generate:")
|
176 |
+
|
177 |
+
input_ids = tokenizer(prompt_template, return_tensors='pt').input_ids.cuda()
|
178 |
+
output = model.generate(inputs=input_ids, temperature=0.7, max_new_tokens=512)
|
179 |
+
print(tokenizer.decode(output[0]))
|
180 |
+
|
181 |
+
# Inference can also be done using transformers' pipeline
|
182 |
+
|
183 |
+
# Prevent printing spurious transformers error when using pipeline with AutoGPTQ
|
184 |
+
logging.set_verbosity(logging.CRITICAL)
|
185 |
+
|
186 |
+
print("*** Pipeline:")
|
187 |
+
pipe = pipeline(
|
188 |
+
"text-generation",
|
189 |
+
model=model,
|
190 |
+
tokenizer=tokenizer,
|
191 |
+
max_new_tokens=512,
|
192 |
+
temperature=0.7,
|
193 |
+
top_p=0.95,
|
194 |
+
repetition_penalty=1.15
|
195 |
+
)
|
196 |
+
|
197 |
+
print(pipe(prompt_template)[0]['generated_text'])
|
198 |
+
```
|
199 |
+
|
200 |
+
## Compatibility
|
201 |
+
|
202 |
+
The files provided will work with AutoGPTQ (CUDA and Triton modes), GPTQ-for-LLaMa (only CUDA has been tested), and Occ4m's GPTQ-for-LLaMa fork.
|
203 |
+
|
204 |
+
ExLlama works with Llama models in 4-bit. Please see the Provided Files table above for per-file compatibility.
|
205 |
+
|
206 |
+
<!-- footer start -->
|
207 |
+
<!-- 200823 -->
|
208 |
+
## Discord
|
209 |
+
|
210 |
+
For further support, and discussions on these models and AI in general, join us at:
|
211 |
+
|
212 |
+
[TheBloke AI's Discord server](https://discord.gg/theblokeai)
|
213 |
+
|
214 |
+
## Thanks, and how to contribute.
|
215 |
+
|
216 |
+
Thanks to the [chirper.ai](https://chirper.ai) team!
|
217 |
+
|
218 |
+
I've had a lot of people ask if they can contribute. I enjoy providing models and helping people, and would love to be able to spend even more time doing it, as well as expanding into new projects like fine tuning/training.
|
219 |
+
|
220 |
+
If you're able and willing to contribute it will be most gratefully received and will help me to keep providing more models, and to start work on new AI projects.
|
221 |
+
|
222 |
+
Donaters will get priority support on any and all AI/LLM/model questions and requests, access to a private Discord room, plus other benefits.
|
223 |
+
|
224 |
+
* Patreon: https://patreon.com/TheBlokeAI
|
225 |
+
* Ko-Fi: https://ko-fi.com/TheBlokeAI
|
226 |
+
|
227 |
+
**Special thanks to**: Aemon Algiz.
|
228 |
+
|
229 |
+
**Patreon special mentions**: Kacper Wikieł, knownsqashed, Leonard Tan, Asp the Wyvern, Daniel P. Andersen, Luke Pendergrass, Stanislav Ovsiannikov, RoA, Dave, Ai Maven, Kalila, Will Dee, Imad Khwaja, Nitin Borwankar, Joseph William Delisle, Tony Hughes, Cory Kujawski, Rishabh Srivastava, Russ Johnson, Stephen Murray, Lone Striker, Johann-Peter Hartmann, Elle, J, Deep Realms, SuperWojo, Raven Klaugh, Sebastain Graf, ReadyPlayerEmma, Alps Aficionado, Mano Prime, Derek Yates, Gabriel Puliatti, Mesiah Bishop, Magnesian, Sean Connelly, biorpg, Iucharbius, Olakabola, Fen Risland, Space Cruiser, theTransient, Illia Dulskyi, Thomas Belote, Spencer Kim, Pieter, John Detwiler, Fred von Graf, Michael Davis, Swaroop Kallakuri, subjectnull, Clay Pascal, Subspace Studios, Chris Smitley, Enrico Ros, usrbinkat, Steven Wood, alfie_i, David Ziegler, Willem Michiel, Matthew Berman, Andrey, Pyrater, Jeffrey Morgan, vamX, LangChain4j, Luke @flexchar, Trenton Dambrowitz, Pierre Kircher, Alex, Sam, James Bentley, Edmond Seymore, Eugene Pentland, Pedro Madruga, Rainer Wilmers, Dan Guido, Nathan LeClaire, Spiking Neurons AB, Talal Aujan, zynix, Artur Olbinski, Michael Levine, 阿明, K, John Villwock, Nikolai Manek, Femi Adebogun, senxiiz, Deo Leter, NimbleBox.ai, Viktor Bowallius, Geoffrey Montalvo, Mandus, Ajan Kanaga, ya boyyy, Jonathan Leane, webtim, Brandon Frisco, danny, Alexandros Triantafyllidis, Gabriel Tamborski, Randy H, terasurfer, Vadim, Junyu Yang, Vitor Caleffi, Chadd, transmissions 11
|
230 |
+
|
231 |
+
|
232 |
+
Thank you to all my generous patrons and donaters!
|
233 |
+
|
234 |
+
And thank you again to a16z for their generous grant.
|
235 |
+
|
236 |
+
<!-- footer end -->
|
237 |
+
|
238 |
+
# Original model card: Phind's Phind CodeLlama 34B v1
|
239 |
+
|
240 |
+
|
241 |
+
# **Phind-CodeLlama-34B-v1**
|
242 |
+
We've fine-tuned CodeLlama-34B and CodeLlama-34B-Python on an internal Phind dataset that achieve 67.6% and 69.5% pass@1 on HumanEval, respectively. GPT-4 achieves 67%. We've applied OpenAI's decontamination methodology to our dataset to ensure result validity.
|
243 |
+
|
244 |
+
More details can be found on our [blog post](https://www.phind.com/blog/code-llama-beats-gpt4).
|
245 |
+
|
246 |
+
## Model Details
|
247 |
+
This model is fine-tuned from CodeLlama-34B and achieves 67.6% pass@1 on HumanEval.
|
248 |
+
|
249 |
+
## Dataset Details
|
250 |
+
We fined-tuned on a proprietary dataset of ~80k high quality programming problems and solutions. This dataset consists of instruction-answer pairs instead of code completion examples, making it structurally different from HumanEval. The Phind models were trained for 2 epochs, for a total of ~160k examples shown. LoRA was not used -- both models are a native finetune. We used DeepSpeed ZeRO 3 and Flash Attention 2 to train these models in three hours on 32 A100-80GB GPUs. We used a sequence length of 4096 tokens.
|
251 |
+
|
252 |
+
## How to Get Started with the Model
|
253 |
+
|
254 |
+
Make sure to install Transformers from the main git branch:
|
255 |
+
|
256 |
+
```bash
|
257 |
+
pip install git+https://github.com/huggingface/transformers.git
|
258 |
+
```
|
259 |
+
|
260 |
+
## How to Prompt the Model
|
261 |
+
**Please note that this model is somewhat instruction-tuned, but not chat-tuned.**
|
262 |
+
|
263 |
+
Do not try to use the Llama chat markup with this model. Instead, simply tell it what you want and add "\n: " at the end of your task.
|
264 |
+
|
265 |
+
For example:
|
266 |
+
|
267 |
+
```
|
268 |
+
Write me a linked list implementation: \n
|
269 |
+
```
|
270 |
+
|
271 |
+
## How to reproduce HumanEval Results
|
272 |
+
|
273 |
+
To reproduce our results:
|
274 |
+
|
275 |
+
```python
|
276 |
+
|
277 |
+
from transformers import AutoTokenizer, LlamaForCausalLM
|
278 |
+
from human_eval.data import write_jsonl, read_problems
|
279 |
+
from tqdm import tqdm
|
280 |
+
|
281 |
+
# initialize the model
|
282 |
+
|
283 |
+
model_path = "Phind/Phind-CodeLlama-34B-v1"
|
284 |
+
model = LlamaForCausalLM.from_pretrained(model_path, device_map="auto")
|
285 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
286 |
+
|
287 |
+
# HumanEval helper
|
288 |
+
|
289 |
+
def generate_one_completion(prompt: str):
|
290 |
+
tokenizer.pad_token = tokenizer.eos_token
|
291 |
+
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=4096)
|
292 |
+
|
293 |
+
# Generate
|
294 |
+
generate_ids = model.generate(inputs.input_ids.to("cuda"), max_new_tokens=256, do_sample=True, top_p=0.75, top_k=40, temperature=0.1)
|
295 |
+
completion = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
296 |
+
completion = completion.replace(prompt, "").split("\n\n\n")[0]
|
297 |
+
|
298 |
+
return completion
|
299 |
+
|
300 |
+
# perform HumanEval
|
301 |
+
problems = read_problems()
|
302 |
+
|
303 |
+
num_samples_per_task = 1
|
304 |
+
samples = [
|
305 |
+
dict(task_id=task_id, completion=generate_one_completion(problems[task_id]["prompt"]))
|
306 |
+
for task_id in tqdm(problems)
|
307 |
+
for _ in range(num_samples_per_task)
|
308 |
+
]
|
309 |
+
write_jsonl("samples.jsonl", samples)
|
310 |
+
|
311 |
+
# run `evaluate_functional_correctness samples.jsonl` in your HumanEval code sandbox
|
312 |
+
```
|
313 |
+
|
314 |
+
## Bias, Risks, and Limitations
|
315 |
+
|
316 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations. -->
|
317 |
+
This model has undergone very limited testing. Additional safety testing should be performed before any real-world deployments.
|
318 |
+
|
319 |
+
|
320 |
+
## Training details
|
321 |
+
|
322 |
+
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
323 |
+
|
324 |
+
- **Hardware Type:** 32x A100-80GB
|
325 |
+
- **Hours used:** 90 GPU-hours
|
326 |
+
- **Cloud Provider:** AWS
|
327 |
+
- **Compute Region:** us-east-1
|