Upload demo_train.py with huggingface_hub
Browse files- demo_train.py +26 -6
demo_train.py
CHANGED
|
@@ -12,14 +12,30 @@
|
|
| 12 |
from datasets import load_dataset
|
| 13 |
from peft import LoraConfig
|
| 14 |
from trl import SFTTrainer, SFTConfig
|
|
|
|
| 15 |
import os
|
| 16 |
|
| 17 |
print("π Starting TRL + Trackio Demo")
|
| 18 |
print("=" * 50)
|
| 19 |
|
| 20 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
print("\nπ Loading dataset...")
|
| 22 |
-
dataset = load_dataset("trl-lib/Capybara", split="train[:
|
| 23 |
print(f"β
Dataset loaded: {len(dataset)} examples")
|
| 24 |
|
| 25 |
# Get username for hub push
|
|
@@ -33,12 +49,12 @@ config = SFTConfig(
|
|
| 33 |
push_to_hub=True,
|
| 34 |
hub_model_id=f"{username}/trl-trackio-demo",
|
| 35 |
|
| 36 |
-
#
|
| 37 |
-
max_steps=
|
| 38 |
per_device_train_batch_size=2,
|
| 39 |
|
| 40 |
-
# Logging
|
| 41 |
-
logging_steps=
|
| 42 |
|
| 43 |
# Trackio monitoring - this is the key!
|
| 44 |
report_to="trackio",
|
|
@@ -76,6 +92,10 @@ trainer.train()
|
|
| 76 |
print("\nπΎ Pushing to Hub...")
|
| 77 |
trainer.push_to_hub()
|
| 78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
print("\nβ
Demo complete!")
|
| 80 |
print(f"π¦ Model saved to: https://huggingface.co/{username}/trl-trackio-demo")
|
| 81 |
print("π Check Trackio for training metrics and visualizations!")
|
|
|
|
| 12 |
from datasets import load_dataset
|
| 13 |
from peft import LoraConfig
|
| 14 |
from trl import SFTTrainer, SFTConfig
|
| 15 |
+
import trackio
|
| 16 |
import os
|
| 17 |
|
| 18 |
print("π Starting TRL + Trackio Demo")
|
| 19 |
print("=" * 50)
|
| 20 |
|
| 21 |
+
# Initialize Trackio with Space sync for remote viewing
|
| 22 |
+
# Trackio will auto-create the Space if it doesn't exist
|
| 23 |
+
print("\nπ Initializing Trackio...")
|
| 24 |
+
trackio.init(
|
| 25 |
+
project="trl-demo",
|
| 26 |
+
space_id="evalstate/trl-trackio-dashboard", # Auto-creates if needed!
|
| 27 |
+
config={
|
| 28 |
+
"model": "Qwen/Qwen2.5-0.5B",
|
| 29 |
+
"dataset": "trl-lib/Capybara",
|
| 30 |
+
"max_steps": 50, # Longer for better visualization
|
| 31 |
+
"learning_rate": 2e-5,
|
| 32 |
+
}
|
| 33 |
+
)
|
| 34 |
+
print("β
Trackio initialized! Dashboard: https://huggingface.co/spaces/evalstate/trl-trackio-dashboard")
|
| 35 |
+
|
| 36 |
+
# Load a small dataset (200 examples for better visualization)
|
| 37 |
print("\nπ Loading dataset...")
|
| 38 |
+
dataset = load_dataset("trl-lib/Capybara", split="train[:200]")
|
| 39 |
print(f"β
Dataset loaded: {len(dataset)} examples")
|
| 40 |
|
| 41 |
# Get username for hub push
|
|
|
|
| 49 |
push_to_hub=True,
|
| 50 |
hub_model_id=f"{username}/trl-trackio-demo",
|
| 51 |
|
| 52 |
+
# Training settings (longer for better metrics)
|
| 53 |
+
max_steps=50, # More steps for visualization
|
| 54 |
per_device_train_batch_size=2,
|
| 55 |
|
| 56 |
+
# Logging (log frequently for real-time monitoring)
|
| 57 |
+
logging_steps=5,
|
| 58 |
|
| 59 |
# Trackio monitoring - this is the key!
|
| 60 |
report_to="trackio",
|
|
|
|
| 92 |
print("\nπΎ Pushing to Hub...")
|
| 93 |
trainer.push_to_hub()
|
| 94 |
|
| 95 |
+
# Finish Trackio logging
|
| 96 |
+
print("\nπ Finalizing Trackio...")
|
| 97 |
+
trackio.finish()
|
| 98 |
+
|
| 99 |
print("\nβ
Demo complete!")
|
| 100 |
print(f"π¦ Model saved to: https://huggingface.co/{username}/trl-trackio-demo")
|
| 101 |
print("π Check Trackio for training metrics and visualizations!")
|