Update README.md
Browse files
README.md
CHANGED
|
@@ -27,8 +27,77 @@ tags:
|
|
| 27 |
- **SFT Trainer**λ₯Ό ν΅ν΄ νλ ¨μ μ§ν
|
| 28 |
- νμ© λ°μ΄ν°
|
| 29 |
- [q_a_korean_futsal](https://huggingface.co/datasets/Dongwookss/q_a_korean_futsal)
|
| 30 |
-
- λ§ν¬ νμ΅μ μν΄ 'ν΄μ'μ²΄λ‘ λ³ννκ³
|
| 31 |
-
|
|
|
|
| 32 |
|
|
|
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
- **SFT Trainer**λ₯Ό ν΅ν΄ νλ ¨μ μ§ν
|
| 28 |
- νμ© λ°μ΄ν°
|
| 29 |
- [q_a_korean_futsal](https://huggingface.co/datasets/Dongwookss/q_a_korean_futsal)
|
| 30 |
+
- λ§ν¬ νμ΅μ μν΄ 'ν΄μ'μ²΄λ‘ λ³ννκ³ μΈμΏλ§μ λ£μ΄ λͺ¨λΈ 컨μ
μ μ μ§νμμ΅λλ€.
|
| 31 |
+
|
| 32 |
+
- **Environment** : Colab νκ²½μμ μ§ννμμΌλ©° L4 GPUλ₯Ό μ¬μ©νμμ΅λλ€.
|
| 33 |
|
| 34 |
+
```python
|
| 35 |
|
| 36 |
+
from unsloth import FastLanguageModel
|
| 37 |
+
import torch
|
| 38 |
+
from trl import SFTTrainer
|
| 39 |
+
from transformers import TrainingArguments
|
| 40 |
|
| 41 |
+
max_seq_length = 256
|
| 42 |
+
dtype = None
|
| 43 |
+
load_in_4bit = False
|
| 44 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 45 |
+
model_name="HuggingFaceH4/zephyr-7b-beta",
|
| 46 |
+
max_seq_length=max_seq_length,
|
| 47 |
+
dtype=dtype,
|
| 48 |
+
load_in_4bit=load_in_4bit,
|
| 49 |
+
#token = ,
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
model = FastLanguageModel.get_peft_model(
|
| 53 |
+
model,
|
| 54 |
+
r=32,
|
| 55 |
+
lora_alpha=64,
|
| 56 |
+
lora_dropout=0.05,
|
| 57 |
+
target_modules=[
|
| 58 |
+
"q_proj",
|
| 59 |
+
"k_proj",
|
| 60 |
+
"v_proj",
|
| 61 |
+
"o_proj",
|
| 62 |
+
"gate_proj",
|
| 63 |
+
"up_proj",
|
| 64 |
+
"down_proj",
|
| 65 |
+
], # νκ² λͺ¨λ
|
| 66 |
+
bias="none",
|
| 67 |
+
use_gradient_checkpointing="unsloth",
|
| 68 |
+
random_state=123,
|
| 69 |
+
use_rslora=False,
|
| 70 |
+
loftq_config=None,
|
| 71 |
+
)
|
| 72 |
+
|
| 73 |
+
tokenizer.padding_side = "right"
|
| 74 |
+
|
| 75 |
+
trainer = SFTTrainer(
|
| 76 |
+
model=model,
|
| 77 |
+
tokenizer=tokenizer,
|
| 78 |
+
train_dataset=dataset,
|
| 79 |
+
dataset_text_field="text",
|
| 80 |
+
max_seq_length=max_seq_length,
|
| 81 |
+
dataset_num_proc=2,
|
| 82 |
+
packing=False,
|
| 83 |
+
args=TrainingArguments(
|
| 84 |
+
per_device_train_batch_size=20,
|
| 85 |
+
gradient_accumulation_steps=2,
|
| 86 |
+
warmup_steps=5,
|
| 87 |
+
num_train_epochs=3,
|
| 88 |
+
max_steps = 1761,
|
| 89 |
+
logging_steps = 10,
|
| 90 |
+
learning_rate=2e-5,
|
| 91 |
+
fp16=not torch.cuda.is_bf16_supported(),
|
| 92 |
+
bf16=torch.cuda.is_bf16_supported(),
|
| 93 |
+
optim="adamw_8bit",
|
| 94 |
+
weight_decay=0.01,
|
| 95 |
+
lr_scheduler_type="cosine",
|
| 96 |
+
seed=123,
|
| 97 |
+
output_dir="outputs",
|
| 98 |
+
),
|
| 99 |
+
)
|
| 100 |
+
|
| 101 |
+
trainer.train()
|
| 102 |
+
|
| 103 |
+
```
|