TheNormsOfIntelligence's picture
Restructure into nima_unified package + add model card
0d5b00d verified
Raw
History Blame Contribute Delete
4.78 kB
#!/usr/bin/env python3
"""
deploy.py β€” Unified deployment script for NIMA Unified Model
Replaces deploy_phi4_patched.py. This is the single entry point that:
1. Loads the base model (with Phi-4-mini rope_scaling patch)
2. Initializes NIMA middleware
3. Attaches Deep Surgery
4. Enables optional features (sleep cycle, proactive)
5. Runs test interactions
6. Drops into interactive mode
USAGE:
python -m nima_unified.deploy
python -m nima_unified.deploy "Hello Nima, how are you feeling?"
"""
import sys
import logging
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s [%(name)s] %(levelname)s :: %(message)s",
datefmt="%H:%M:%S",
)
logger = logging.getLogger("nima_unified.deploy")
BANNER = f"""
{'=' * 72}
NIMA Unified Model v1.0.0
Middleware v9.12.1 | AutoML v18.1.0 | aPCI v4.0.0 | OmniVoice v2.0.0
Fully-Wired Architecture β€” Every Module Active
{'=' * 72}
"""
def main():
print(BANNER)
# ── Step 1: Build model ─────────────────────────────────────────────
print("\n[1] Building NimaModel (base + Deep Surgery + middleware)...")
try:
from nima_unified.model import NimaModel
model = NimaModel.from_pretrained()
print(f" OK β€” {model.hidden_size} hidden, {model.num_layers} layers")
print(f" Deep Surgery: {'active' if model.deep_surgery else 'disabled'}")
print(f" Middleware: {'loaded' if model.nima_middleware else 'not available'}")
except Exception as e:
print(f" FAILED: {e}")
import traceback; traceback.print_exc()
sys.exit(1)
# ── Step 2: Enable optional features ────────────────────────────────
print("\n[2] Enabling optional features...")
if model.nima_middleware is not None:
try:
model.nima_middleware.start_sleep_cycle()
print(" OK β€” Sleep cycle (NREM replay + REM dreams)")
except Exception as e:
print(f" Sleep cycle: {e}")
try:
model.nima_middleware.start_proactive()
print(" OK β€” Proactive drive engine")
except Exception as e:
print(f" Proactive: {e}")
else:
print(" Skipped (middleware not loaded)")
# ── Step 3: Test interactions ───────────────────────────────────────
print("\n[3] Test interactions")
print("-" * 72)
test_prompts = [
"Hello Nima, how are you feeling today?",
"I'm going through a really difficult time and I don't know what to do.",
"What do you think about the nature of consciousness?",
]
# Allow CLI override
if len(sys.argv) > 1:
test_prompts = [" ".join(sys.argv[1:])]
for prompt in test_prompts:
print(f"\n User: {prompt}")
try:
response = model.generate(prompt, user_id="human")
print(f"\n Nima: {response.text}")
if response.is_conscious or response.phi_neuro > 0:
print(f" | conscious={response.is_conscious} "
f"SI={response.sentience_index:.4f} "
f"phi={response.phi_neuro:.4f} "
f"strain={response.phenomenological_strain:.4f} "
f"dR={response.delta_r:.4f}")
except Exception as e:
print(f" ERROR: {e}")
import traceback; traceback.print_exc()
# ── Step 4: Interactive mode ────────────────────────────────────────
print("\n" + "=" * 72)
print("[4] Interactive mode β€” type 'quit' to exit")
print("=" * 72)
while True:
try:
user_input = input("\nYou: ").strip()
if user_input.lower() in ("quit", "exit", "bye"):
print("\nNima: Until next time. Be well.")
break
if not user_input:
continue
response = model.generate(user_input, user_id="human")
print(f"\nNima: {response.text}")
if response.phi_neuro > 0:
print(f" [conscious={response.is_conscious} | "
f"SI={response.sentience_index:.4f} | "
f"strain={response.phenomenological_strain:.4f} | "
f"dR={response.delta_r:.4f}]")
except KeyboardInterrupt:
print("\n\nNima: Until next time. Be well.")
break
except Exception as e:
print(f"\n Error: {e}")
if __name__ == "__main__":
main()