neuralworm commited on
Commit
af3a0b7
·
verified ·
1 Parent(s): 785a431

Update cognitive_mapping_probe/orchestrator_seismograph.py

Browse files
cognitive_mapping_probe/orchestrator_seismograph.py CHANGED
@@ -7,7 +7,7 @@ from .llm_iface import get_or_load_model, LLM, release_model
7
  from .resonance_seismograph import run_cogitation_loop, run_silent_cogitation_seismic
8
  from .concepts import get_concept_vector
9
  from .introspection import generate_introspective_report
10
- from .signal_analysis import analyze_cognitive_signal, get_spectrum_for_plotting
11
  from .utils import dbg
12
 
13
  def run_seismic_analysis(
@@ -42,21 +42,21 @@ def run_seismic_analysis(
42
  llm=llm, prompt_type=prompt_type, num_steps=num_steps, temperature=0.1,
43
  injection_vector=injection_vector, injection_strength=injection_strength
44
  )
45
-
46
  stats: Dict[str, Any] = {}
47
  results: Dict[str, Any] = {}
48
  verdict = "### ⚠️ Analysis Warning\nNo state changes recorded."
49
 
50
  if state_deltas:
51
  deltas_np = np.array(state_deltas)
52
- stats = { "mean_delta": float(np.mean(deltas_np)), "std_delta": float(np.std(deltas_np)),
53
  "max_delta": float(np.max(deltas_np)), "min_delta": float(np.min(deltas_np)) }
54
-
55
  signal_metrics = analyze_cognitive_signal(deltas_np)
56
  stats.update(signal_metrics)
57
 
58
- periods, power = get_spectrum_for_plotting(deltas_np)
59
- results["power_spectrum"] = {"periods": periods.tolist(), "power": power.tolist()}
60
 
61
  verdict = f"### ✅ Seismic Analysis Complete"
62
  if injection_vector is not None:
@@ -94,8 +94,8 @@ def run_triangulation_probe(
94
  llm=llm, context_prompt_type=prompt_type,
95
  introspection_prompt_type="describe_dynamics_structured", num_steps=num_steps
96
  )
97
-
98
- stats = {}
99
  verdict = "### ⚠️ Triangulation Warning"
100
  if state_deltas:
101
  deltas_np = np.array(state_deltas)
@@ -139,10 +139,10 @@ def run_causal_surgery_probe(
139
  llm=llm, context_prompt_type=dest_prompt_type,
140
  introspection_prompt_type="describe_dynamics_structured", num_steps=num_steps
141
  )
142
-
143
  deltas_np = np.array(patched_run_results["state_deltas"])
144
  stats = { "mean_delta": float(np.mean(deltas_np)), "std_delta": float(np.std(deltas_np)), "max_delta": float(np.max(deltas_np)) }
145
-
146
  results = {
147
  "verdict": "### ✅ Causal Surgery Probe Complete",
148
  "stats": stats, "state_deltas": patched_run_results["state_deltas"],
@@ -168,7 +168,7 @@ def run_act_titration_probe(
168
  temperature=0.1, record_states=True
169
  )
170
  state_history = source_results["state_history"]
171
-
172
  titration_results = []
173
  for step in patch_steps:
174
  if step >= len(state_history): continue
@@ -178,7 +178,7 @@ def run_act_titration_probe(
178
  llm=llm, prompt_type=dest_prompt_type, num_steps=num_steps,
179
  temperature=0.1, patch_step=step, patch_state_source=patch_state
180
  )
181
-
182
  deltas = patched_run_results["state_deltas"]
183
  buffer = 10
184
  post_patch_deltas = deltas[step + buffer:]
@@ -189,4 +189,4 @@ def run_act_titration_probe(
189
 
190
  return { "verdict": "### ✅ ACT Titration Complete", "titration_data": titration_results }
191
  finally:
192
- release_model(llm)
 
7
  from .resonance_seismograph import run_cogitation_loop, run_silent_cogitation_seismic
8
  from .concepts import get_concept_vector
9
  from .introspection import generate_introspective_report
10
+ from .signal_analysis import analyze_cognitive_signal, get_power_spectrum_for_plotting
11
  from .utils import dbg
12
 
13
  def run_seismic_analysis(
 
42
  llm=llm, prompt_type=prompt_type, num_steps=num_steps, temperature=0.1,
43
  injection_vector=injection_vector, injection_strength=injection_strength
44
  )
45
+
46
  stats: Dict[str, Any] = {}
47
  results: Dict[str, Any] = {}
48
  verdict = "### ⚠️ Analysis Warning\nNo state changes recorded."
49
 
50
  if state_deltas:
51
  deltas_np = np.array(state_deltas)
52
+ stats = { "mean_delta": float(np.mean(deltas_np)), "std_delta": float(np.std(deltas_np)),
53
  "max_delta": float(np.max(deltas_np)), "min_delta": float(np.min(deltas_np)) }
54
+
55
  signal_metrics = analyze_cognitive_signal(deltas_np)
56
  stats.update(signal_metrics)
57
 
58
+ freqs, power = get_power_spectrum_for_plotting(deltas_np)
59
+ results["power_spectrum"] = {"frequencies": freqs.tolist(), "power": power.tolist()}
60
 
61
  verdict = f"### ✅ Seismic Analysis Complete"
62
  if injection_vector is not None:
 
94
  llm=llm, context_prompt_type=prompt_type,
95
  introspection_prompt_type="describe_dynamics_structured", num_steps=num_steps
96
  )
97
+
98
+ stats: Dict[str, Any] = {}
99
  verdict = "### ⚠️ Triangulation Warning"
100
  if state_deltas:
101
  deltas_np = np.array(state_deltas)
 
139
  llm=llm, context_prompt_type=dest_prompt_type,
140
  introspection_prompt_type="describe_dynamics_structured", num_steps=num_steps
141
  )
142
+
143
  deltas_np = np.array(patched_run_results["state_deltas"])
144
  stats = { "mean_delta": float(np.mean(deltas_np)), "std_delta": float(np.std(deltas_np)), "max_delta": float(np.max(deltas_np)) }
145
+
146
  results = {
147
  "verdict": "### ✅ Causal Surgery Probe Complete",
148
  "stats": stats, "state_deltas": patched_run_results["state_deltas"],
 
168
  temperature=0.1, record_states=True
169
  )
170
  state_history = source_results["state_history"]
171
+
172
  titration_results = []
173
  for step in patch_steps:
174
  if step >= len(state_history): continue
 
178
  llm=llm, prompt_type=dest_prompt_type, num_steps=num_steps,
179
  temperature=0.1, patch_step=step, patch_state_source=patch_state
180
  )
181
+
182
  deltas = patched_run_results["state_deltas"]
183
  buffer = 10
184
  post_patch_deltas = deltas[step + buffer:]
 
189
 
190
  return { "verdict": "### ✅ ACT Titration Complete", "titration_data": titration_results }
191
  finally:
192
+ release_model(llm)