LoganResearch commited on
Commit
413ceac
·
verified ·
1 Parent(s): 97bd2b2

Upload training_scripts/quickstart.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. training_scripts/quickstart.py +184 -0
training_scripts/quickstart.py ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ ÜBERMENSCHETIEN QUICK START
4
+ ============================
5
+ One-command setup and training.
6
+
7
+ Usage:
8
+ python quickstart.py --full # Run full pipeline
9
+ python quickstart.py --train-dense # Just dense training
10
+ python quickstart.py --train-cfhot # Just CF-HoT heads
11
+ python quickstart.py --improve # Just self-improvement
12
+ python quickstart.py --test # Test current model
13
+
14
+ "From zero to self-improving in one command"
15
+ """
16
+
17
+ import os
18
+ import sys
19
+ import argparse
20
+ import subprocess
21
+ from pathlib import Path
22
+
23
+ ROOT = os.path.dirname(os.path.abspath(__file__))
24
+
25
+ def run_command(cmd, description):
26
+ """Run a command with nice output."""
27
+ print(f"\n{'='*70}")
28
+ print(f"🚀 {description}")
29
+ print(f"{'='*70}")
30
+ print(f"$ {cmd}\n")
31
+
32
+ result = subprocess.run(cmd, shell=True, cwd=ROOT)
33
+
34
+ if result.returncode != 0:
35
+ print(f"\n❌ Failed: {description}")
36
+ return False
37
+
38
+ print(f"\n✓ Complete: {description}")
39
+ return True
40
+
41
+
42
+ def check_dependencies():
43
+ """Check required packages are installed."""
44
+ print("\n🔍 Checking dependencies...")
45
+
46
+ required = [
47
+ "torch",
48
+ "transformers",
49
+ "peft",
50
+ "bitsandbytes",
51
+ "accelerate",
52
+ ]
53
+
54
+ missing = []
55
+ for pkg in required:
56
+ try:
57
+ __import__(pkg)
58
+ print(f" ✓ {pkg}")
59
+ except ImportError:
60
+ print(f" ✗ {pkg}")
61
+ missing.append(pkg)
62
+
63
+ if missing:
64
+ print(f"\n❌ Missing packages: {', '.join(missing)}")
65
+ print("Install with: pip install " + " ".join(missing))
66
+ return False
67
+
68
+ print("\n✓ All dependencies installed")
69
+ return True
70
+
71
+
72
+ def train_dense(steps=100):
73
+ """Run THE CONDENSATOR dense training."""
74
+ return run_command(
75
+ f"python the_condensator.py --stages sft,dpo,rl --steps {steps}",
76
+ "THE CONDENSATOR - Dense Response Training"
77
+ )
78
+
79
+
80
+ def train_cfhot(steps=3000):
81
+ """Train CF-HoT behavior heads."""
82
+ success = True
83
+
84
+ for behavior in ["repetition", "hedging", "verbosity"]:
85
+ if not run_command(
86
+ f"python train_cfhot_head.py --behavior {behavior} --steps {steps}",
87
+ f"CF-HoT {behavior.upper()} Head Training"
88
+ ):
89
+ success = False
90
+
91
+ return success
92
+
93
+
94
+ def train_self_improve(iterations=5):
95
+ """Run stable self-improvement."""
96
+ return run_command(
97
+ f"python train_self_improve.py --iterations {iterations}",
98
+ "Stable Self-Improvement Loop"
99
+ )
100
+
101
+
102
+ def test_model(checkpoint=None):
103
+ """Test the model."""
104
+ cmd = "python the_condensator.py --eval-only"
105
+ if checkpoint:
106
+ cmd += f" --checkpoint {checkpoint}"
107
+ return run_command(cmd, "Model Evaluation")
108
+
109
+
110
+ def full_pipeline():
111
+ """Run the complete training pipeline."""
112
+ print("\n" + "="*70)
113
+ print("🔥 ÜBERMENSCHETIEN FULL TRAINING PIPELINE")
114
+ print("="*70)
115
+ print("""
116
+ This will run:
117
+ 1. THE CONDENSATOR (SFT → DPO → RL)
118
+ 2. CF-HoT Head Training (repetition, hedging, verbosity)
119
+ 3. Stable Self-Improvement Loop
120
+
121
+ Estimated time: 2-4 hours on RTX 3090
122
+ """)
123
+
124
+ if not check_dependencies():
125
+ return False
126
+
127
+ # Step 1: Dense training
128
+ if not train_dense(100):
129
+ return False
130
+
131
+ # Step 2: CF-HoT heads
132
+ if not train_cfhot(1000): # Fewer steps for quick start
133
+ return False
134
+
135
+ # Step 3: Self-improvement
136
+ if not train_self_improve(3):
137
+ return False
138
+
139
+ print("\n" + "="*70)
140
+ print("✓ ÜBERMENSCHETIEN TRAINING COMPLETE!")
141
+ print("="*70)
142
+ print("""
143
+ Your model is ready! Run:
144
+
145
+ python ubermenschetien_v2_full.py
146
+
147
+ Commands:
148
+ > hello # Chat
149
+ > !eval # Evaluate quality
150
+ > !improve # Continue self-improvement
151
+ """)
152
+
153
+ return True
154
+
155
+
156
+ def main():
157
+ parser = argparse.ArgumentParser(description="Übermenschetien Quick Start")
158
+ parser.add_argument("--full", action="store_true", help="Run full pipeline")
159
+ parser.add_argument("--train-dense", action="store_true", help="Run dense training only")
160
+ parser.add_argument("--train-cfhot", action="store_true", help="Run CF-HoT training only")
161
+ parser.add_argument("--improve", action="store_true", help="Run self-improvement only")
162
+ parser.add_argument("--test", action="store_true", help="Test current model")
163
+ parser.add_argument("--steps", type=int, default=100, help="Training steps")
164
+ parser.add_argument("--checkpoint", type=str, default=None, help="Checkpoint path for testing")
165
+
166
+ args = parser.parse_args()
167
+
168
+ if args.full:
169
+ full_pipeline()
170
+ elif args.train_dense:
171
+ train_dense(args.steps)
172
+ elif args.train_cfhot:
173
+ train_cfhot(args.steps)
174
+ elif args.improve:
175
+ train_self_improve()
176
+ elif args.test:
177
+ test_model(args.checkpoint)
178
+ else:
179
+ parser.print_help()
180
+ print("\n💡 Try: python quickstart.py --full")
181
+
182
+
183
+ if __name__ == "__main__":
184
+ main()