Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- mlabonne/Evol-Instruct-Python-26k
|
5 |
+
pipeline_tag: text-generation
|
6 |
+
---
|
7 |
+
# π¦π» PyLlama-7b
|
8 |
+
|
9 |
+
π [Article](https://medium.com/@mlabonne/a-beginners-guide-to-llm-fine-tuning-4bae7d4da672)
|
10 |
+
|
11 |
+
<center><img src="https://i.imgur.com/5m7OJQU.png" width="300"></center>
|
12 |
+
|
13 |
+
This is a [`codellama/CodeLlama-7b-hf`](https://huggingface.co/codellama/CodeLlama-7b-hf) model fine-tuned using QLoRA (4-bit precision) on the [`mlabonne/Evol-Instruct-Python-1k`](https://huggingface.co/datasets/mlabonne/Evol-Instruct-Python-26k).
|
14 |
+
|
15 |
+
## π§ Training
|
16 |
+
|
17 |
+
It was trained on an RTX 3090 in 9h 52m 34s with the following configuration file:
|
18 |
+
|
19 |
+
```yaml
|
20 |
+
base_model: codellama/CodeLlama-7b-hf
|
21 |
+
base_model_config: codellama/CodeLlama-7b-hf
|
22 |
+
model_type: LlamaForCausalLM
|
23 |
+
tokenizer_type: LlamaTokenizer
|
24 |
+
is_llama_derived_model: true
|
25 |
+
hub_model_id: PyLlama-7b
|
26 |
+
|
27 |
+
load_in_8bit: false
|
28 |
+
load_in_4bit: true
|
29 |
+
strict: false
|
30 |
+
|
31 |
+
datasets:
|
32 |
+
- path: mlabonne/Evol-Instruct-Python-26k
|
33 |
+
type: alpaca
|
34 |
+
dataset_prepared_path: last_run_prepared
|
35 |
+
val_set_size: 0.02
|
36 |
+
output_dir: ./qlora-out
|
37 |
+
|
38 |
+
adapter: qlora
|
39 |
+
lora_model_dir:
|
40 |
+
|
41 |
+
sequence_len: 2048
|
42 |
+
sample_packing: true
|
43 |
+
|
44 |
+
lora_r: 32
|
45 |
+
lora_alpha: 16
|
46 |
+
lora_dropout: 0.05
|
47 |
+
lora_target_modules:
|
48 |
+
lora_target_linear: true
|
49 |
+
lora_fan_in_fan_out:
|
50 |
+
|
51 |
+
wandb_project: axolotl
|
52 |
+
wandb_entity:
|
53 |
+
wandb_watch:
|
54 |
+
wandb_run_id:
|
55 |
+
wandb_log_model:
|
56 |
+
|
57 |
+
gradient_accumulation_steps: 1
|
58 |
+
micro_batch_size: 10
|
59 |
+
num_epochs: 3
|
60 |
+
optimizer: paged_adamw_32bit
|
61 |
+
lr_scheduler: cosine
|
62 |
+
learning_rate: 0.0002
|
63 |
+
|
64 |
+
train_on_inputs: false
|
65 |
+
group_by_length: false
|
66 |
+
bf16: true
|
67 |
+
fp16: false
|
68 |
+
tf32: false
|
69 |
+
|
70 |
+
gradient_checkpointing: true
|
71 |
+
early_stopping_patience:
|
72 |
+
resume_from_checkpoint:
|
73 |
+
local_rank:
|
74 |
+
logging_steps: 1
|
75 |
+
xformers_attention:
|
76 |
+
flash_attention: true
|
77 |
+
|
78 |
+
warmup_steps: 100
|
79 |
+
eval_steps: 0.01
|
80 |
+
save_strategy: epoch
|
81 |
+
save_steps:
|
82 |
+
debug:
|
83 |
+
deepspeed:
|
84 |
+
weight_decay: 0.0
|
85 |
+
fsdp:
|
86 |
+
fsdp_config:
|
87 |
+
special_tokens:
|
88 |
+
bos_token: "<s>"
|
89 |
+
eos_token: "</s>"
|
90 |
+
unk_token: "<unk>"
|
91 |
+
```
|
92 |
+
|
93 |
+
Here are the loss curves:
|
94 |
+
|
95 |
+
[TO ADD]
|
96 |
+
|
97 |
+
[<img src="https://raw.githubusercontent.com/OpenAccess-AI-Collective/axolotl/main/image/axolotl-badge-web.png" alt="Built with Axolotl" width="200" height="32"/>](https://github.com/OpenAccess-AI-Collective/axolotl)
|
98 |
+
|
99 |
+
## π» Usage
|
100 |
+
|
101 |
+
``` python
|
102 |
+
# pip install transformers accelerate
|
103 |
+
|
104 |
+
from transformers import AutoTokenizer
|
105 |
+
import transformers
|
106 |
+
import torch
|
107 |
+
|
108 |
+
model = "mlabonne/PyLlama-7b"
|
109 |
+
prompt = "Your prompt"
|
110 |
+
|
111 |
+
tokenizer = AutoTokenizer.from_pretrained(model)
|
112 |
+
pipeline = transformers.pipeline(
|
113 |
+
"text-generation",
|
114 |
+
model=model,
|
115 |
+
torch_dtype=torch.float16,
|
116 |
+
device_map="auto",
|
117 |
+
)
|
118 |
+
|
119 |
+
sequences = pipeline(
|
120 |
+
f'{prompt}',
|
121 |
+
do_sample=True,
|
122 |
+
top_k=10,
|
123 |
+
num_return_sequences=1,
|
124 |
+
eos_token_id=tokenizer.eos_token_id,
|
125 |
+
max_length=200,
|
126 |
+
)
|
127 |
+
for seq in sequences:
|
128 |
+
print(f"Result: {seq['generated_text']}")
|
129 |
+
```
|