Skip to content

Commit 44cb0d7

Browse files
authored
Update README.md
1 parent 948f959 commit 44cb0d7

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1+
# 💫 StarCoder QLoRA 4bit Fork
2+
I followed this guide [Making LLMs even more accessible with bitsandbytes, 4-bit quantization and QLoRA
3+
](https://huggingface.co/blog/4bit-transformers-bitsandbytes) by huggingface and implement the code in this repo
4+
to load the model in 4bit int and train using the methods outlined in the paper.
5+
6+
To make this work you're going to need the latese accelerate, transformers, and bitsandbytes libs.
7+
```
8+
pip install -q -U bitsandbytes
9+
pip install -q -U git+https://github.com/huggingface/transformers.git
10+
pip install -q -U git+https://github.com/huggingface/peft.git
11+
pip install -q -U git+https://github.com/huggingface/accelerate.git
12+
```
13+
14+
The model can beloaded in 11GB of VRAM at 4bit.
15+
```
16+
from transformers import BitsAndBytesConfig
17+
nf4_config = BitsAndBytesConfig(
18+
load_in_4bit=True,
19+
bnb_4bit_quant_type="nf4",
20+
bnb_4bit_use_double_quant=True,
21+
bnb_4bit_compute_dtype=torch.bfloat16
22+
)
23+
24+
model_nf4 = AutoModelForCausalLM.from_pretrained(model_id, quantization_config=nf4_config)
25+
```
26+
27+
We add a the new optimizer to TrainingArguments()
28+
```
29+
...
30+
optim="paged_adamw_8bit"
31+
...
32+
```
33+
34+
To utilize a second GPU for faster training we change the device map:
35+
```
36+
device_map={"": Accelerator().process_index},
37+
```
38+
39+
We launch the trainer with accelerate to make use of the second GPU.
40+
```
41+
accelerate launch /home/gpu/code/starcoder/finetune/finetune.py --model_path=bigcode/starcoder --dataset_name=ArmelR/stack-exchange-instruction --subset=data/finetune --split=train --size_valid_set 10000 --streaming --seq_length 2600 --max_steps 1000 --batch_size 1 --input_column_name=question --output_column_name=response --save_freq=100 --learning_rate 0.0001 --lora_r 16
42+
```
43+
![image](https://github.com/binaryninja/starcoder/assets/5916066/cc159829-125a-48d2-8239-f65fdbd4ad91)
44+
45+
146
# 💫 StarCoder
247

348
[Paper](https://drive.google.com/file/d/1cN-b9GnWtHzQRoE7M7gAEyivY0kl4BYs/view) | [Model](https://huggingface.co/bigcode/starcoder) | [Playground](https://huggingface.co/spaces/bigcode/bigcode-playground) | [VSCode](https://marketplace.visualstudio.com/items?itemName=HuggingFace.huggingface-vscode) | [Chat](https://huggingface.co/spaces/HuggingFaceH4/starchat-playground)

0 commit comments

Comments
 (0)