Upload train.py with huggingface_hub
Browse files
train.py
CHANGED
|
@@ -10,8 +10,8 @@
|
|
| 10 |
# ///
|
| 11 |
"""Lexwell SFT — Qwen2.5-3B-Instruct fine-tune on IRAC contract-review corpus.
|
| 12 |
|
| 13 |
-
|
| 14 |
-
and
|
| 15 |
"""
|
| 16 |
from datasets import load_dataset
|
| 17 |
from peft import LoraConfig
|
|
@@ -24,7 +24,6 @@ OUT = "Curious-PM/lexwell-contract-irac-qwen2.5-3b-lora"
|
|
| 24 |
print(f"Loading dataset {DS}...")
|
| 25 |
ds = load_dataset(DS, data_files="lexwell_v2.jsonl", split="train")
|
| 26 |
print(f"Loaded {len(ds)} rows")
|
| 27 |
-
print(f"First row keys: {list(ds[0].keys())}")
|
| 28 |
|
| 29 |
trainer = SFTTrainer(
|
| 30 |
model=BASE,
|
|
@@ -38,20 +37,24 @@ trainer = SFTTrainer(
|
|
| 38 |
args=SFTConfig(
|
| 39 |
output_dir="lexwell-lora",
|
| 40 |
num_train_epochs=10,
|
| 41 |
-
per_device_train_batch_size=
|
| 42 |
-
gradient_accumulation_steps=
|
| 43 |
learning_rate=2e-4,
|
| 44 |
max_length=2048,
|
| 45 |
logging_steps=10,
|
| 46 |
eval_strategy="no",
|
| 47 |
save_strategy="no",
|
| 48 |
bf16=True,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
push_to_hub=True,
|
| 50 |
hub_model_id=OUT,
|
| 51 |
hub_strategy="end",
|
| 52 |
report_to="trackio",
|
| 53 |
project="lexwell-irac",
|
| 54 |
-
run_name="qwen2.5-3b-sft-r16-e10",
|
| 55 |
),
|
| 56 |
)
|
| 57 |
|
|
|
|
| 10 |
# ///
|
| 11 |
"""Lexwell SFT — Qwen2.5-3B-Instruct fine-tune on IRAC contract-review corpus.
|
| 12 |
|
| 13 |
+
Memory-tuned for a10g-large (24 GB): gradient checkpointing + batch 2 + grad-accum 2
|
| 14 |
+
keeps effective batch at 4 and total steps at 200 across 10 epochs.
|
| 15 |
"""
|
| 16 |
from datasets import load_dataset
|
| 17 |
from peft import LoraConfig
|
|
|
|
| 24 |
print(f"Loading dataset {DS}...")
|
| 25 |
ds = load_dataset(DS, data_files="lexwell_v2.jsonl", split="train")
|
| 26 |
print(f"Loaded {len(ds)} rows")
|
|
|
|
| 27 |
|
| 28 |
trainer = SFTTrainer(
|
| 29 |
model=BASE,
|
|
|
|
| 37 |
args=SFTConfig(
|
| 38 |
output_dir="lexwell-lora",
|
| 39 |
num_train_epochs=10,
|
| 40 |
+
per_device_train_batch_size=2,
|
| 41 |
+
gradient_accumulation_steps=2,
|
| 42 |
learning_rate=2e-4,
|
| 43 |
max_length=2048,
|
| 44 |
logging_steps=10,
|
| 45 |
eval_strategy="no",
|
| 46 |
save_strategy="no",
|
| 47 |
bf16=True,
|
| 48 |
+
gradient_checkpointing=True,
|
| 49 |
+
gradient_checkpointing_kwargs={"use_reentrant": False},
|
| 50 |
+
optim="adamw_torch_fused",
|
| 51 |
+
dataloader_pin_memory=False,
|
| 52 |
push_to_hub=True,
|
| 53 |
hub_model_id=OUT,
|
| 54 |
hub_strategy="end",
|
| 55 |
report_to="trackio",
|
| 56 |
project="lexwell-irac",
|
| 57 |
+
run_name="qwen2.5-3b-sft-r16-e10-gc",
|
| 58 |
),
|
| 59 |
)
|
| 60 |
|