saemzzang commited on
Commit
2d37693
β€’
1 Parent(s): c5fcff1

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +59 -0
README.md CHANGED
@@ -20,3 +20,62 @@ tags:
20
  This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  This llama model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth) and Huggingface's TRL library.
21
 
22
  [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
23
+
24
+ ```
25
+ model = FastLanguageModel.get_peft_model(
26
+ model,
27
+ r=8, # 0보닀 큰 μ–΄λ–€ μˆ«μžλ„ 선택 κ°€λŠ₯! 8, 16, 32, 64, 128이 ꢌμž₯λ©λ‹ˆλ‹€.
28
+ lora_alpha=16, # LoRA μ•ŒνŒŒ 값을 μ„€μ •ν•©λ‹ˆλ‹€.
29
+ lora_dropout=0.05, # λ“œλ‘­μ•„μ›ƒμ„ μ§€μ›ν•©λ‹ˆλ‹€.
30
+ target_modules=[
31
+ "q_proj",
32
+ "k_proj",
33
+ "v_proj",
34
+ "o_proj",
35
+ "gate_proj",
36
+ "up_proj",
37
+ "down_proj",
38
+ ], # νƒ€κ²Ÿ λͺ¨λ“ˆμ„ μ§€μ •ν•©λ‹ˆλ‹€.
39
+ bias="none", # λ°”μ΄μ–΄μŠ€λ₯Ό μ§€μ›ν•©λ‹ˆλ‹€.
40
+ # True λ˜λŠ” "unsloth"λ₯Ό μ‚¬μš©ν•˜μ—¬ 맀우 κΈ΄ μ»¨ν…μŠ€νŠΈμ— λŒ€ν•΄ VRAM을 30% 덜 μ‚¬μš©ν•˜κ³ , 2λ°° 더 큰 배치 크기λ₯Ό μ§€μ›ν•©λ‹ˆλ‹€.
41
+ use_gradient_checkpointing="unsloth",
42
+ random_state=123, # λ‚œμˆ˜ μƒνƒœλ₯Ό μ„€μ •ν•©λ‹ˆλ‹€.
43
+ use_rslora=False, # μˆœμœ„ μ•ˆμ •ν™” LoRAλ₯Ό μ§€μ›ν•©λ‹ˆλ‹€.
44
+ loftq_config=None, # LoftQλ₯Ό μ§€μ›ν•©λ‹ˆλ‹€.
45
+ )
46
+
47
+ from trl import SFTTrainer
48
+ from transformers import TrainingArguments
49
+
50
+ tokenizer.padding_side = "right" # ν† ν¬λ‚˜μ΄μ €μ˜ νŒ¨λ”©μ„ 였λ₯Έμͺ½μœΌλ‘œ μ„€μ •ν•©λ‹ˆλ‹€.
51
+
52
+ # SFTTrainerλ₯Ό μ‚¬μš©ν•˜μ—¬ λͺ¨λΈ ν•™μŠ΅ μ„€μ •
53
+ trainer = SFTTrainer(
54
+ model=model, # ν•™μŠ΅ν•  λͺ¨λΈ
55
+ tokenizer=tokenizer, # ν† ν¬λ‚˜μ΄μ €
56
+ train_dataset=dataset, # ν•™μŠ΅ 데이터셋
57
+ eval_dataset=dataset,
58
+ dataset_text_field="text", # λ°μ΄ν„°μ…‹μ—μ„œ ν…μŠ€νŠΈ ν•„λ“œμ˜ 이름
59
+ max_seq_length=max_seq_length, # μ΅œλŒ€ μ‹œν€€μŠ€ 길이
60
+ dataset_num_proc=2, # 데이터 μ²˜λ¦¬μ— μ‚¬μš©ν•  ν”„λ‘œμ„ΈμŠ€ 수
61
+ packing=False, # 짧은 μ‹œν€€μŠ€μ— λŒ€ν•œ ν•™μŠ΅ 속도λ₯Ό 5λ°° λΉ λ₯΄κ²Œ ν•  수 있음
62
+ args=TrainingArguments(
63
+ per_device_train_batch_size=2, # 각 λ””λ°”μ΄μŠ€λ‹Ή ν›ˆλ ¨ 배치 크기
64
+ gradient_accumulation_steps=4, # κ·Έλž˜λ””μ–ΈνŠΈ λˆ„μ  단계
65
+ warmup_steps=5, # μ›œμ—… μŠ€ν… 수
66
+ num_train_epochs=3, # ν›ˆλ ¨ 에폭 수
67
+ max_steps=120, # μ΅œλŒ€ μŠ€ν… 수
68
+ do_eval=True,
69
+ evaluation_strategy="steps",
70
+ logging_steps=1, # logging μŠ€ν… 수
71
+ learning_rate=2e-4, # ν•™μŠ΅λ₯ 
72
+ fp16=not torch.cuda.is_bf16_supported(), # fp16 μ‚¬μš© μ—¬λΆ€, bf16이 μ§€μ›λ˜μ§€ μ•ŠλŠ” κ²½μš°μ—λ§Œ μ‚¬μš©
73
+ bf16=torch.cuda.is_bf16_supported(), # bf16 μ‚¬μš© μ—¬λΆ€, bf16이 μ§€μ›λ˜λŠ” κ²½μš°μ—λ§Œ μ‚¬μš©
74
+ optim="adamw_8bit", # μ΅œμ ν™” μ•Œκ³ λ¦¬μ¦˜
75
+ weight_decay=0.01, # κ°€μ€‘μΉ˜ κ°μ†Œ
76
+ lr_scheduler_type="cosine", # ν•™μŠ΅λ₯  μŠ€μΌ€μ€„λŸ¬ μœ ν˜•
77
+ seed=123, # 랜덀 μ‹œλ“œ
78
+ output_dir="outputs", # 좜λ ₯ 디렉토리
79
+ ),
80
+ )
81
+ ```