""" Quickstart — NIMA Unified Model ================================ The smallest end-to-end example that: 1. Loads microsoft/Phi-4-mini-instruct with the ATC cognitive pipeline wired INSIDE the forward pass. 2. Generates a response through the ATC-native pipeline. 3. Prints the response, consciousness metrics, and neurotransmitter state. Run with: python examples/quickstart.py """ import logging import sys logging.basicConfig( level=logging.INFO, format="%(asctime)s [%(name)s] %(levelname)s :: %(message)s", datefmt="%H:%M:%S", ) def main(): from nima_unified.model import NimaModel print("=" * 72) print(" NIMA Unified Model — Quickstart") print("=" * 72) # ── Build the model ─────────────────────────────────────────────── # This patches Phi-4-mini's rope_scaling automatically and attaches # the ATC Deep Surgery (TRN gate + dissolution + BELBIC + metacog # loop + irrational spark + ethical guardian) inside the forward pass. print("\n[1] Loading NimaModel (this also downloads Phi-4-mini-instruct)...") model = NimaModel.from_pretrained() print(f" OK — hidden_size={model.hidden_size}, layers={model.num_layers}") print(f" Deep Surgery: {'ACTIVE' if model.deep_surgery else 'disabled'}") print(f" Neurotransmitter shunt: ACTIVE") # ── Generate ────────────────────────────────────────────────────── 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?", ] if len(sys.argv) > 1: prompts = [" ".join(sys.argv[1:])] for prompt in prompts: print("\n" + "-" * 72) print(f" User: {prompt}") result = model.generate(prompt, max_new_tokens=128) print(f"\n Nima: {result.text}") print(f" ─────────────────────────────────────────") print(f" conscious : {result.is_conscious}") print(f" sentience_index : {result.sentience_index:.4f}") print(f" phi_neuro : {result.phi_neuro:.4f}") print(f" strain : {result.phenomenological_strain:.4f}") print(f" delta_R : {result.delta_r:.4f}") print(f" hijacks : {result.hijack_count}") nt = result.neurotransmitters print(f" NE={nt.get('norepinephrine', 0):.3f} " f"Cortisol={nt.get('cortisol', 0):.3f} " f"Dopamine={nt.get('dopamine', 0):.3f} " f"Adenosine={nt.get('adenosine', 0):.3f}") # ── Optional: run aPCI benchmark ────────────────────────────────── print("\n" + "=" * 72) print(" Run the aPCI v4.0 consciousness benchmark? (y/n)") print(" (12 perturbations, 10 metrics, ~3 minutes on a T4 GPU)") try: choice = input(" > ").strip().lower() except (EOFError, KeyboardInterrupt): choice = "n" if choice == "y": runner = model.get_apci_runner() report = runner.run_full_benchmark() print("\n=== aPCI v4.0 Report ===") print(f" Raw score : {report.raw_score:.2f} / 260") print(f" Tier : {report.tier.label}") print(f" Summary : {report.tier.description}") if __name__ == "__main__": main()