Update training script for ThaiLLM-8B-SFT-IQ

#2
Files changed (1) hide show
  1. README.md +57 -0
README.md CHANGED
@@ -75,6 +75,63 @@ The model is fine-tuned from **ThaiLLM-8B-SFT** using supervised fine-tuning (SF
75
  | Batch size | 8 |
76
 
77
  Training data consists of Thai medical question–answer pairs with context grounding and citation supervision.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
  ---
80
 
 
75
  | Batch size | 8 |
76
 
77
  Training data consists of Thai medical question–answer pairs with context grounding and citation supervision.
78
+ - **Training Script**
79
+ - ```bash
80
+ model_base, tokenizer = FastLanguageModel.from_pretrained(
81
+ base_model,
82
+ max_seq_length=max_seq,
83
+ load_in_4bit=True,
84
+ load_in_8bit=False,
85
+ full_finetuning=False,
86
+ device_map = "balanced",
87
+ )
88
+
89
+ model = FastLanguageModel.get_peft_model(
90
+ model_base,
91
+ r=r,
92
+ lora_alpha=r, # Set lora_alpha = r
93
+ lora_dropout=0,
94
+ bias="none",
95
+ target_modules=[
96
+ "q_proj", "k_proj", "v_proj", "o_proj",
97
+ "gate_proj", "up_proj", "down_proj"
98
+ ],
99
+ use_gradient_checkpointing="unsloth",
100
+ random_state=seed,
101
+ use_rslora=False,
102
+ loftq_config=None,
103
+ )
104
+
105
+ trainer = SFTTrainer(
106
+ model=model,
107
+ tokenizer=tokenizer,
108
+ train_dataset=train_ds,
109
+ dataset_num_proc=4,
110
+ args=SFTConfig(
111
+ dataset_text_field="text",
112
+ per_device_train_batch_size=2,
113
+ gradient_accumulation_steps=8,
114
+ gradient_checkpointing = True,
115
+ warmup_ratio=0.1,
116
+ warmup_steps=5,
117
+ # max_steps = 1000, # If max_steps is set → ignore num_train_epochs
118
+ num_train_epochs=3, # Epoch ..
119
+ learning_rate=args.learning_rate,
120
+ logging_steps=1,
121
+ optim="adamw_8bit",
122
+ weight_decay=0.01,
123
+ lr_scheduler_type="cosine",
124
+ fp16=not torch.cuda.is_bf16_supported(),
125
+ bf16=torch.cuda.is_bf16_supported(),
126
+ seed=args.seed,
127
+ report_to=["tensorboard"],
128
+ output_dir=f"{paths['log_path']}",
129
+ logging_dir=f"{paths['log_path']}",
130
+ ),
131
+ )
132
+
133
+ trainer.train()
134
+ ```
135
 
136
  ---
137