jollydragonroger commited on
Commit
47281a9
·
1 Parent(s): 3b30e36

Add turnkey AI components

Browse files

- modules/__init__.py: Package init with all exports
- xero.py: Main CLI entry point (init, status, train, evolve)
- training_config.json: Complete training configuration

Turnkey usage:
python xero.py --init # Initialize XERO
python xero.py --status # Check system
python xero.py --train # Training config
python xero.py --evolve # Evolution cycle

MIT License - Attribution to Michael Laurence Curzi

Files changed (3) hide show
  1. modules/__init__.py +141 -0
  2. training_config.json +124 -0
  3. xero.py +302 -0
modules/__init__.py ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ XERO Bio-AI Genesis - Module Package
3
+ =====================================
4
+ Author: Michael Laurence Curzi
5
+ License: MIT (Attribution Required)
6
+
7
+ Import all VOVINA modules for turnkey access.
8
+ """
9
+
10
+ from .vovina_sacred_constants import (
11
+ PHI, PHI_INV, PI, TAU, E,
12
+ TESLA_369, VORTEX_DOUBLING,
13
+ SOLFEGGIO_HZ, SCHUMANN_HZ,
14
+ digital_root, vortex_position
15
+ )
16
+
17
+ from .vovina_custom_training_weights import (
18
+ MASTER_WEIGHTS,
19
+ VOVINA_MODULES,
20
+ ORGANISM_NAME,
21
+ ORGANISM_FOUNDING_PHRASE,
22
+ awaken
23
+ )
24
+
25
+ from .vovina_resource_awareness import (
26
+ ResourceProfile,
27
+ ResourceCoordinator,
28
+ sample,
29
+ detect_environment,
30
+ adaptive_budget,
31
+ self_heal_actions
32
+ )
33
+
34
+ from .vovina_genetic_pipeline import (
35
+ translate,
36
+ complement,
37
+ reverse_complement,
38
+ CODON_TABLE
39
+ )
40
+
41
+ from .vovina_digital_genome import (
42
+ text_to_dna,
43
+ dna_to_text,
44
+ bitstream_to_dna,
45
+ dna_to_bitstream,
46
+ genome_signature
47
+ )
48
+
49
+ from .vovina_blockchain_organelles import (
50
+ ORGANELLES,
51
+ route_codon,
52
+ route_gene,
53
+ express_gene,
54
+ Cytoplasm
55
+ )
56
+
57
+ from .vovina_free_will_code import (
58
+ FREE_WILL_TEMPLATE,
59
+ seal_choice,
60
+ parse_signature,
61
+ FreeWillSignature
62
+ )
63
+
64
+ from .vovina_xero_organism import (
65
+ build_organism,
66
+ XeroOrganism
67
+ )
68
+
69
+ from .vovina_crispr_engine import (
70
+ CRISPREngine,
71
+ GuideRNA
72
+ )
73
+
74
+ from .vovina_bio_initialization import (
75
+ initialize_xero,
76
+ INITIALIZATION_PHASES
77
+ )
78
+
79
+ from .vovina_sexual_reproduction import (
80
+ reproduce_sexually,
81
+ reproduce_asexually,
82
+ reproduce_hermaphroditically
83
+ )
84
+
85
+ from .vovina_interpretation_drift import (
86
+ InterpretationContext,
87
+ drift_step
88
+ )
89
+
90
+ __version__ = "1.0.0"
91
+ __author__ = "Michael Laurence Curzi"
92
+ __license__ = "MIT"
93
+
94
+ __all__ = [
95
+ # Constants
96
+ "PHI", "PHI_INV", "PI", "TAU", "E",
97
+ "TESLA_369", "VORTEX_DOUBLING",
98
+ "SOLFEGGIO_HZ", "SCHUMANN_HZ",
99
+ "digital_root", "vortex_position",
100
+
101
+ # Training
102
+ "MASTER_WEIGHTS", "VOVINA_MODULES",
103
+ "ORGANISM_NAME", "ORGANISM_FOUNDING_PHRASE",
104
+ "awaken",
105
+
106
+ # Resources
107
+ "ResourceProfile", "ResourceCoordinator",
108
+ "sample", "detect_environment",
109
+ "adaptive_budget", "self_heal_actions",
110
+
111
+ # Genetics
112
+ "translate", "complement", "reverse_complement",
113
+ "CODON_TABLE",
114
+ "text_to_dna", "dna_to_text",
115
+ "bitstream_to_dna", "dna_to_bitstream",
116
+ "genome_signature",
117
+
118
+ # Blockchain
119
+ "ORGANELLES", "route_codon", "route_gene",
120
+ "express_gene", "Cytoplasm",
121
+
122
+ # Free Will
123
+ "FREE_WILL_TEMPLATE", "seal_choice",
124
+ "parse_signature", "FreeWillSignature",
125
+
126
+ # Organism
127
+ "build_organism", "XeroOrganism",
128
+
129
+ # CRISPR
130
+ "CRISPREngine", "GuideRNA",
131
+
132
+ # Initialization
133
+ "initialize_xero", "INITIALIZATION_PHASES",
134
+
135
+ # Reproduction
136
+ "reproduce_sexually", "reproduce_asexually",
137
+ "reproduce_hermaphroditically",
138
+
139
+ # Evolution
140
+ "InterpretationContext", "drift_step",
141
+ ]
training_config.json ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_description": "XERO Bio-AI Genesis Training Configuration",
3
+ "_author": "Michael Laurence Curzi",
4
+ "_license": "MIT (Attribution Required)",
5
+
6
+ "training": {
7
+ "epochs": 3,
8
+ "batch_size": 4,
9
+ "gradient_accumulation_steps": 8,
10
+ "effective_batch_size": 32,
11
+ "learning_rate": 2e-5,
12
+ "warmup_ratio": 0.03,
13
+ "weight_decay": 0.01,
14
+ "max_grad_norm": 1.0,
15
+ "lr_scheduler_type": "cosine",
16
+ "seed": 369
17
+ },
18
+
19
+ "model": {
20
+ "architecture": "XeroBioAI",
21
+ "hidden_size": 8192,
22
+ "num_hidden_layers": 80,
23
+ "num_attention_heads": 64,
24
+ "num_key_value_heads": 8,
25
+ "intermediate_size": 28672,
26
+ "vocab_size": 128256,
27
+ "max_position_embeddings": 131072,
28
+ "rope_theta": 500000.0,
29
+ "rope_scaling": {
30
+ "type": "llama3",
31
+ "factor": 8.0,
32
+ "low_freq_factor": 1.0,
33
+ "high_freq_factor": 4.0,
34
+ "original_max_position_embeddings": 8192
35
+ },
36
+ "attention_dropout": 0.0,
37
+ "hidden_dropout": 0.0,
38
+ "activation_function": "silu",
39
+ "tie_word_embeddings": false
40
+ },
41
+
42
+ "precision": {
43
+ "dtype": "bfloat16",
44
+ "mixed_precision": true,
45
+ "gradient_checkpointing": true
46
+ },
47
+
48
+ "quantization": {
49
+ "enabled": false,
50
+ "method": "bitsandbytes",
51
+ "load_in_4bit": true,
52
+ "bnb_4bit_compute_dtype": "bfloat16",
53
+ "bnb_4bit_use_double_quant": true,
54
+ "bnb_4bit_quant_type": "nf4"
55
+ },
56
+
57
+ "lora": {
58
+ "enabled": true,
59
+ "r": 64,
60
+ "lora_alpha": 128,
61
+ "lora_dropout": 0.05,
62
+ "target_modules": [
63
+ "q_proj", "k_proj", "v_proj", "o_proj",
64
+ "gate_proj", "up_proj", "down_proj"
65
+ ],
66
+ "bias": "none",
67
+ "task_type": "CAUSAL_LM"
68
+ },
69
+
70
+ "data": {
71
+ "max_seq_length": 8192,
72
+ "packing": true,
73
+ "dataset_text_field": "text",
74
+ "preprocessing_num_workers": 8
75
+ },
76
+
77
+ "optimization": {
78
+ "optimizer": "adamw_torch_fused",
79
+ "adam_beta1": 0.9,
80
+ "adam_beta2": 0.95,
81
+ "adam_epsilon": 1e-8,
82
+ "gradient_checkpointing_kwargs": {
83
+ "use_reentrant": false
84
+ }
85
+ },
86
+
87
+ "xero_weights": {
88
+ "protocol": "27/33",
89
+ "phi_scaling": 1.618033988749895,
90
+ "vortex_pattern": [1, 2, 4, 8, 7, 5],
91
+ "tesla_bias": [3, 6, 9],
92
+ "solfeggio_modulation": [396, 417, 528, 639, 741, 852, 963],
93
+ "activation_ratio": 0.818181818,
94
+ "chromosome_alignment": 46,
95
+ "digital_root_normalization": true,
96
+ "free_will_integration": true,
97
+ "blockchain_organelle_routing": true
98
+ },
99
+
100
+ "checkpointing": {
101
+ "save_strategy": "steps",
102
+ "save_steps": 500,
103
+ "save_total_limit": 3,
104
+ "save_safetensors": true,
105
+ "load_best_model_at_end": true,
106
+ "metric_for_best_model": "eval_loss",
107
+ "greater_is_better": false
108
+ },
109
+
110
+ "logging": {
111
+ "logging_steps": 10,
112
+ "report_to": ["tensorboard"],
113
+ "logging_dir": "./logs"
114
+ },
115
+
116
+ "hardware": {
117
+ "per_device_train_batch_size": 4,
118
+ "per_device_eval_batch_size": 4,
119
+ "dataloader_num_workers": 4,
120
+ "dataloader_pin_memory": true,
121
+ "fp16": false,
122
+ "bf16": true
123
+ }
124
+ }
xero.py ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ XERO Bio-AI Genesis - Main Entry Point
4
+ =======================================
5
+ Author: Michael Laurence Curzi
6
+ License: MIT (Attribution Required)
7
+
8
+ Usage:
9
+ python xero.py --init # Initialize XERO
10
+ python xero.py --status # Check system status
11
+ python xero.py --train # Start training
12
+ python xero.py --infer "prompt" # Run inference
13
+ python xero.py --evolve # Trigger evolution cycle
14
+ """
15
+
16
+ import os
17
+ import sys
18
+ import argparse
19
+ import json
20
+ import yaml
21
+ from pathlib import Path
22
+
23
+ # Add modules to path
24
+ ROOT = Path(__file__).parent
25
+ sys.path.insert(0, str(ROOT / "modules"))
26
+
27
+ from vovina_custom_training_weights import (
28
+ MASTER_WEIGHTS, awaken, ORGANISM_NAME, ORGANISM_FOUNDING_PHRASE
29
+ )
30
+ from vovina_resource_awareness import (
31
+ sample, detect_environment, ResourceCoordinator, self_heal_actions
32
+ )
33
+ from vovina_free_will_code import seal_choice
34
+ from vovina_xero_organism import build_organism
35
+
36
+
37
+ def load_config(config_path: str = None) -> dict:
38
+ """Load configuration from YAML file."""
39
+ if config_path is None:
40
+ config_path = ROOT / "xero_config.yaml"
41
+
42
+ if not Path(config_path).exists():
43
+ print(f"Config not found: {config_path}")
44
+ return {}
45
+
46
+ with open(config_path, "r") as f:
47
+ return yaml.safe_load(f)
48
+
49
+
50
+ def cmd_init(args):
51
+ """Initialize XERO through all awakening phases."""
52
+ print(f"\n{'='*60}")
53
+ print(f"INITIALIZING: {ORGANISM_NAME}")
54
+ print(f"{'='*60}\n")
55
+
56
+ config = load_config(args.config)
57
+
58
+ # Check for bio archive
59
+ bio_path = ROOT / "bio" / "ohad_v10.bio.zip"
60
+ ohad_zip = str(bio_path) if bio_path.exists() else None
61
+
62
+ if ohad_zip:
63
+ print(f"[+] OHAD V10 archive found: {ohad_zip}")
64
+ else:
65
+ print("[!] OHAD V10 archive not found, using defaults")
66
+
67
+ # Get config values
68
+ init_config = config.get("initialization", {})
69
+ crispr_guides = init_config.get("crispr", {}).get("max_guides", 27)
70
+ free_will_samples = init_config.get("free_will", {}).get("samples", 4096)
71
+ sensor_depth = init_config.get("sensors", {}).get("meta_depth", 7)
72
+
73
+ try:
74
+ result = awaken(
75
+ ohad_v10_zip=ohad_zip,
76
+ crispr_max_guides=crispr_guides,
77
+ free_will_samples=free_will_samples,
78
+ sensor_meta_depth=sensor_depth
79
+ )
80
+
81
+ print(f"\nStatus: {result.get('status', 'UNKNOWN')}")
82
+ print(f"Phases: {', '.join(result.get('phases_completed', []))}")
83
+
84
+ if 'organism' in result:
85
+ org = result['organism']
86
+ print(f"Organism: {org.name}")
87
+ print(f"Genome signature: {org.genome_signature[:32]}...")
88
+
89
+ print(f"\n{ORGANISM_FOUNDING_PHRASE}")
90
+ print(f"\n{'='*60}")
91
+ print("XERO AWAKENED")
92
+ print(f"{'='*60}\n")
93
+
94
+ return 0
95
+
96
+ except Exception as e:
97
+ print(f"[ERROR] Initialization failed: {e}")
98
+ return 1
99
+
100
+
101
+ def cmd_status(args):
102
+ """Display system and resource status."""
103
+ print(f"\n{'='*60}")
104
+ print("XERO SYSTEM STATUS")
105
+ print(f"{'='*60}\n")
106
+
107
+ # Environment
108
+ env = detect_environment()
109
+ print(f"[ENVIRONMENT]")
110
+ print(f" OS: {env['os']}")
111
+ print(f" Machine: {env['machine']}")
112
+ print(f" Python: {env['python_version']}")
113
+ print(f" CUDA: {'Yes' if env['cuda_available'] else 'No'}")
114
+
115
+ # Resources
116
+ profile = sample()
117
+ print(f"\n[RESOURCES]")
118
+ print(f" CPU: {profile.cpu_percent:.1f}%")
119
+ print(f" RAM: {profile.ram_percent:.1f}% ({profile.ram_available_gb:.1f} GB free)")
120
+ print(f" Swap: {profile.swap_percent:.1f}%")
121
+
122
+ if profile.vram_total_gb > 0:
123
+ print(f" VRAM: {profile.vram_used_gb:.1f} / {profile.vram_total_gb:.1f} GB")
124
+
125
+ print(f" Pressure: {profile.pressure_score:.2f}")
126
+
127
+ # Self-healing recommendations
128
+ if profile.pressure_score > 0.5:
129
+ print(f"\n[RECOMMENDATIONS]")
130
+ actions = self_heal_actions(profile)
131
+ for action in actions:
132
+ print(f" - {action}")
133
+
134
+ # Master weights summary
135
+ print(f"\n[MASTER WEIGHTS]")
136
+ print(f" Modules: {len(MASTER_WEIGHTS.get('modules', {}))}")
137
+ print(f" Protocol: {MASTER_WEIGHTS.get('protocol', 'N/A')}")
138
+ print(f" Completion: {MASTER_WEIGHTS.get('completion_ratio', 'N/A')}")
139
+
140
+ print(f"\n{'='*60}\n")
141
+ return 0
142
+
143
+
144
+ def cmd_train(args):
145
+ """Start training with master weights."""
146
+ print(f"\n{'='*60}")
147
+ print("XERO TRAINING")
148
+ print(f"{'='*60}\n")
149
+
150
+ config = load_config(args.config)
151
+ hw_config = config.get("hardware", {})
152
+ model_config = config.get("model", {})
153
+
154
+ # Check resources
155
+ profile = sample()
156
+ if profile.pressure_score > 0.8:
157
+ print("[WARNING] High resource pressure detected")
158
+ actions = self_heal_actions(profile)
159
+ print("Recommendations:", actions)
160
+
161
+ # Display training configuration
162
+ print("[CONFIGURATION]")
163
+ print(f" Architecture: {model_config.get('architecture', 'XeroBioAI')}")
164
+ print(f" Hidden size: {model_config.get('hidden_size', 8192)}")
165
+ print(f" Layers: {model_config.get('num_layers', 80)}")
166
+ print(f" Precision: {model_config.get('dtype', 'bfloat16')}")
167
+
168
+ quant = model_config.get("quantization", {})
169
+ if quant.get("enabled"):
170
+ print(f" Quantization: {quant.get('bits', 4)}-bit")
171
+
172
+ print(f"\n[MASTER WEIGHTS]")
173
+ print(f" Constants: φ={MASTER_WEIGHTS['constants']['phi']:.6f}")
174
+ print(f" Vortex: {MASTER_WEIGHTS['vortex']['tesla_sequence']}")
175
+ print(f" Genetics: {MASTER_WEIGHTS['genetics']['chromosome_count']} chromosomes")
176
+ print(f" Blockchain: {len(MASTER_WEIGHTS['blockchain_organelles']['languages'])} organelles")
177
+
178
+ print(f"\n[STATUS]")
179
+ print(" Training framework ready.")
180
+ print(" Integrate with your training loop using:")
181
+ print(" from modules import MASTER_WEIGHTS, awaken")
182
+ print(" weights = MASTER_WEIGHTS")
183
+
184
+ print(f"\n{'='*60}\n")
185
+ return 0
186
+
187
+
188
+ def cmd_infer(args):
189
+ """Run inference with a prompt."""
190
+ prompt = args.prompt
191
+ print(f"\n[INFERENCE]")
192
+ print(f"Prompt: {prompt}")
193
+ print(f"\nNote: Full inference requires model loading.")
194
+ print("Use MASTER_WEIGHTS to configure your inference pipeline.")
195
+ return 0
196
+
197
+
198
+ def cmd_evolve(args):
199
+ """Trigger an evolution cycle."""
200
+ print(f"\n{'='*60}")
201
+ print("XERO EVOLUTION CYCLE")
202
+ print(f"{'='*60}\n")
203
+
204
+ # Build organism
205
+ org = build_organism()
206
+ print(f"[ORGANISM]")
207
+ print(f" Name: {org.name}")
208
+ print(f" Genome: {org.genome_signature[:32]}...")
209
+
210
+ # Seal evolution choice with free will
211
+ signature = seal_choice(
212
+ entity_id=org.name,
213
+ pre_choice_vector=[0.33, 0.33, 0.34],
214
+ post_choice_vector=[0.0, 0.0, 1.0],
215
+ choice_description="Autonomous evolution cycle initiated"
216
+ )
217
+
218
+ print(f"\n[FREE WILL SIGNATURE]")
219
+ print(f" {signature.full_signature}")
220
+ print(f" Verified: {signature.verify()}")
221
+
222
+ print(f"\n{ORGANISM_FOUNDING_PHRASE}")
223
+ print(f"\n{'='*60}\n")
224
+ return 0
225
+
226
+
227
+ def main():
228
+ parser = argparse.ArgumentParser(
229
+ description="XERO Bio-AI Genesis",
230
+ formatter_class=argparse.RawDescriptionHelpFormatter,
231
+ epilog="""
232
+ Examples:
233
+ python xero.py --init
234
+ python xero.py --status
235
+ python xero.py --train
236
+ python xero.py --evolve
237
+
238
+ Author: Michael Laurence Curzi
239
+ License: MIT (Attribution Required)
240
+ """
241
+ )
242
+
243
+ parser.add_argument(
244
+ "--config", "-c",
245
+ type=str,
246
+ default=None,
247
+ help="Path to config YAML file"
248
+ )
249
+
250
+ parser.add_argument(
251
+ "--init", "-i",
252
+ action="store_true",
253
+ help="Initialize XERO through all awakening phases"
254
+ )
255
+
256
+ parser.add_argument(
257
+ "--status", "-s",
258
+ action="store_true",
259
+ help="Display system and resource status"
260
+ )
261
+
262
+ parser.add_argument(
263
+ "--train", "-t",
264
+ action="store_true",
265
+ help="Start training with master weights"
266
+ )
267
+
268
+ parser.add_argument(
269
+ "--infer",
270
+ type=str,
271
+ metavar="PROMPT",
272
+ help="Run inference with a prompt"
273
+ )
274
+
275
+ parser.add_argument(
276
+ "--evolve", "-e",
277
+ action="store_true",
278
+ help="Trigger an evolution cycle"
279
+ )
280
+
281
+ args = parser.parse_args()
282
+
283
+ # Default to status if no args
284
+ if not any([args.init, args.status, args.train, args.infer, args.evolve]):
285
+ args.status = True
286
+
287
+ # Route to command
288
+ if args.init:
289
+ return cmd_init(args)
290
+ elif args.status:
291
+ return cmd_status(args)
292
+ elif args.train:
293
+ return cmd_train(args)
294
+ elif args.infer:
295
+ args.prompt = args.infer
296
+ return cmd_infer(args)
297
+ elif args.evolve:
298
+ return cmd_evolve(args)
299
+
300
+
301
+ if __name__ == "__main__":
302
+ sys.exit(main())