lokegud commited on
Commit
540a49d
Β·
verified Β·
1 Parent(s): 907dd77

Upload train_v2_expanded.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. train_v2_expanded.py +98 -0
train_v2_expanded.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # /// script
2
+ # dependencies = ["trl>=0.12.0", "peft>=0.7.0", "trackio", "torch", "transformers"]
3
+ # ///
4
+
5
+ from datasets import load_dataset
6
+ from peft import LoraConfig
7
+ from trl import SFTTrainer, SFTConfig
8
+ import trackio
9
+
10
+ print("πŸš€ Starting Creative AI Assistant Training (v2 - Expanded)")
11
+ print("=" * 60)
12
+
13
+ # Load expanded multi-domain dataset
14
+ dataset = load_dataset("lokegud/creative-ai-knowledge-base", split="train")
15
+ print(f"πŸ“Š Dataset loaded: {len(dataset)} examples")
16
+
17
+ # Split for evaluation
18
+ dataset_split = dataset.train_test_split(test_size=0.15, seed=42)
19
+ train_dataset = dataset_split["train"]
20
+ eval_dataset = dataset_split["test"]
21
+
22
+ print(f"πŸ“ˆ Train: {len(train_dataset)} | Eval: {len(eval_dataset)}")
23
+
24
+ # LoRA configuration - optimized for 1.5B model with larger dataset
25
+ peft_config = LoraConfig(
26
+ r=32, # Higher rank for better learning across domains
27
+ lora_alpha=64,
28
+ lora_dropout=0.05,
29
+ target_modules=["q_proj", "v_proj", "k_proj", "o_proj", "gate_proj", "up_proj", "down_proj"],
30
+ task_type="CAUSAL_LM"
31
+ )
32
+
33
+ # Training configuration for 1,177 examples
34
+ # With 1,177 examples: 1,000 train, 177 eval
35
+ # Steps per epoch: 1000 / (2 * 8) = ~62 steps/epoch
36
+ # Total steps: 62 * 3 epochs = ~186 steps
37
+ training_args = SFTConfig(
38
+ output_dir="creative-ai-assistant-v2",
39
+ num_train_epochs=3,
40
+ per_device_train_batch_size=2,
41
+ per_device_eval_batch_size=2,
42
+ gradient_accumulation_steps=8, # Effective batch size: 16
43
+ learning_rate=2e-4,
44
+ warmup_ratio=0.1, # Warm up for 10% of training (~19 steps)
45
+ logging_steps=5, # Log every 5 steps
46
+ eval_strategy="epoch", # Evaluate after each epoch
47
+ save_strategy="epoch", # Save after each epoch
48
+ save_total_limit=3,
49
+ load_best_model_at_end=True,
50
+ metric_for_best_model="eval_loss",
51
+ greater_is_better=False,
52
+ push_to_hub=True,
53
+ hub_model_id="lokegud/creative-ai-assistant-v2",
54
+ hub_strategy="end", # Only push final model
55
+ hub_private_repo=False,
56
+ report_to="trackio",
57
+ project="creative-ai-assistant",
58
+ run_name="v2-expanded-1177examples",
59
+ gradient_checkpointing=True,
60
+ bf16=True, # Faster training with bf16
61
+ max_length=2048, # Longer context for full content
62
+ dataset_text_field="messages", # Chat format
63
+ )
64
+
65
+ print("πŸ”§ Initializing trainer with Qwen2.5-1.5B-Instruct...")
66
+
67
+ # Initialize trainer
68
+ trainer = SFTTrainer(
69
+ model="Qwen/Qwen2.5-1.5B-Instruct",
70
+ train_dataset=train_dataset,
71
+ eval_dataset=eval_dataset,
72
+ peft_config=peft_config,
73
+ args=training_args,
74
+ )
75
+
76
+ print("πŸ‹οΈ Training Creative AI Assistant v2...")
77
+ trainer.train()
78
+
79
+ print("πŸ“€ Pushing final model to Hub...")
80
+ trainer.push_to_hub()
81
+
82
+ print("βœ… Training complete!")
83
+ print(f"πŸ“¦ Model: lokegud/creative-ai-assistant-v2")
84
+ print(f"πŸ“Š Trackio: https://lokegud-trackio.hf.space/")
85
+ print(f"πŸ“š Dataset: https://huggingface.co/datasets/lokegud/creative-ai-knowledge-base")
86
+ print(f"")
87
+ print(f"🎯 v2 Capabilities:")
88
+ print(f" - ComfyUI workflows & troubleshooting")
89
+ print(f" - 3D graphics (Blender, USD)")
90
+ print(f" - XR/VR/AR development")
91
+ print(f" - Image generation (SD, SDXL, Flux)")
92
+ print(f" - LLM training & fine-tuning")
93
+ print(f" - Audio synthesis & production")
94
+ print(f" - Anatomy & character design")
95
+ print(f" - Cinematography & camera work")
96
+ print(f" - Scriptwriting & story structure")
97
+ print(f" - Game engine development")
98
+ print(f" - Machine learning fundamentals")