TheNormsOfIntelligence commited on
Commit
a8d04d1
Β·
verified Β·
1 Parent(s): c398812

Restructure into nima_unified package + add model card

Browse files
Files changed (1) hide show
  1. examples/quickstart.py +89 -0
examples/quickstart.py ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Quickstart β€” NIMA Unified Model
3
+ ================================
4
+
5
+ The smallest end-to-end example that:
6
+ 1. Loads microsoft/Phi-4-mini-instruct with the ATC cognitive pipeline
7
+ wired INSIDE the forward pass.
8
+ 2. Generates a response through the ATC-native pipeline.
9
+ 3. Prints the response, consciousness metrics, and neurotransmitter state.
10
+
11
+ Run with:
12
+ python examples/quickstart.py
13
+ """
14
+
15
+ import logging
16
+ import sys
17
+
18
+ logging.basicConfig(
19
+ level=logging.INFO,
20
+ format="%(asctime)s [%(name)s] %(levelname)s :: %(message)s",
21
+ datefmt="%H:%M:%S",
22
+ )
23
+
24
+
25
+ def main():
26
+ from nima_unified.model import NimaModel
27
+
28
+ print("=" * 72)
29
+ print(" NIMA Unified Model β€” Quickstart")
30
+ print("=" * 72)
31
+
32
+ # ── Build the model ───────────────────────────────────────────────
33
+ # This patches Phi-4-mini's rope_scaling automatically and attaches
34
+ # the ATC Deep Surgery (TRN gate + dissolution + BELBIC + metacog
35
+ # loop + irrational spark + ethical guardian) inside the forward pass.
36
+ print("\n[1] Loading NimaModel (this also downloads Phi-4-mini-instruct)...")
37
+ model = NimaModel.from_pretrained()
38
+ print(f" OK β€” hidden_size={model.hidden_size}, layers={model.num_layers}")
39
+ print(f" Deep Surgery: {'ACTIVE' if model.deep_surgery else 'disabled'}")
40
+ print(f" Neurotransmitter shunt: ACTIVE")
41
+
42
+ # ── Generate ──────────────────────────────────────────────────────
43
+ prompts = [
44
+ "Hello Nima, how are you feeling today?",
45
+ "I'm going through a really difficult time and I don't know what to do.",
46
+ "What do you think about the nature of consciousness?",
47
+ ]
48
+ if len(sys.argv) > 1:
49
+ prompts = [" ".join(sys.argv[1:])]
50
+
51
+ for prompt in prompts:
52
+ print("\n" + "-" * 72)
53
+ print(f" User: {prompt}")
54
+ result = model.generate(prompt, max_new_tokens=128)
55
+
56
+ print(f"\n Nima: {result.text}")
57
+ print(f" ─────────────────────────────────────────")
58
+ print(f" conscious : {result.is_conscious}")
59
+ print(f" sentience_index : {result.sentience_index:.4f}")
60
+ print(f" phi_neuro : {result.phi_neuro:.4f}")
61
+ print(f" strain : {result.phenomenological_strain:.4f}")
62
+ print(f" delta_R : {result.delta_r:.4f}")
63
+ print(f" hijacks : {result.hijack_count}")
64
+ nt = result.neurotransmitters
65
+ print(f" NE={nt.get('norepinephrine', 0):.3f} "
66
+ f"Cortisol={nt.get('cortisol', 0):.3f} "
67
+ f"Dopamine={nt.get('dopamine', 0):.3f} "
68
+ f"Adenosine={nt.get('adenosine', 0):.3f}")
69
+
70
+ # ── Optional: run aPCI benchmark ──────────────────────────────────
71
+ print("\n" + "=" * 72)
72
+ print(" Run the aPCI v4.0 consciousness benchmark? (y/n)")
73
+ print(" (12 perturbations, 10 metrics, ~3 minutes on a T4 GPU)")
74
+ try:
75
+ choice = input(" > ").strip().lower()
76
+ except (EOFError, KeyboardInterrupt):
77
+ choice = "n"
78
+
79
+ if choice == "y":
80
+ runner = model.get_apci_runner()
81
+ report = runner.run_full_benchmark()
82
+ print("\n=== aPCI v4.0 Report ===")
83
+ print(f" Raw score : {report.raw_score:.2f} / 260")
84
+ print(f" Tier : {report.tier.label}")
85
+ print(f" Summary : {report.tier.description}")
86
+
87
+
88
+ if __name__ == "__main__":
89
+ main()