Upload train_with_trackio.py with huggingface_hub
Browse files- train_with_trackio.py +36 -0
train_with_trackio.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# /// script
|
| 2 |
+
# requires-python = ">=3.10"
|
| 3 |
+
# dependencies = ["trl", "datasets", "trackio"]
|
| 4 |
+
# ///
|
| 5 |
+
"""Simple SFT training WITH trackio - logs may block on HF Jobs."""
|
| 6 |
+
|
| 7 |
+
import sys
|
| 8 |
+
sys.stdout.reconfigure(line_buffering=True)
|
| 9 |
+
|
| 10 |
+
from datasets import load_dataset
|
| 11 |
+
from trl import SFTTrainer, SFTConfig
|
| 12 |
+
|
| 13 |
+
print("=" * 50)
|
| 14 |
+
print("Training WITH Trackio")
|
| 15 |
+
print("=" * 50)
|
| 16 |
+
|
| 17 |
+
dataset = load_dataset("trl-lib/Capybara", split="train[:1000]")
|
| 18 |
+
print(f"Dataset loaded: {len(dataset)} samples")
|
| 19 |
+
|
| 20 |
+
config = SFTConfig(
|
| 21 |
+
output_dir="./output",
|
| 22 |
+
max_steps=50,
|
| 23 |
+
logging_steps=10,
|
| 24 |
+
report_to="trackio",
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
trainer = SFTTrainer(
|
| 28 |
+
model="Qwen/Qwen2.5-0.5B",
|
| 29 |
+
train_dataset=dataset,
|
| 30 |
+
args=config,
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
print("Starting training...")
|
| 34 |
+
trainer.train()
|
| 35 |
+
print("Training complete!")
|
| 36 |
+
print("=" * 50)
|