Executor-Tyrant-Framework commited on
Commit
093b6b9
Β·
verified Β·
1 Parent(s): 5fa3f26

Sync from GitHub: c56c8ff9870dc5363d98124b3f9966123ef6260a

Browse files
Files changed (2) hide show
  1. app.py +77 -0
  2. nuwave/organism.py +23 -0
app.py CHANGED
@@ -1114,6 +1114,66 @@ def on_benchmark(num_turns):
1114
  return json.dumps(summary, indent=2), json.dumps(results, indent=2)
1115
 
1116
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1117
  def on_interleaved_benchmark(
1118
  enable_dual_pass: bool = True,
1119
  oracle_trees: bool = False,
@@ -1445,6 +1505,18 @@ def on_interleaved_benchmark(
1445
  _same_cat_ratio = None
1446
  success_signal = True # neutral / cold-start
1447
 
 
 
 
 
 
 
 
 
 
 
 
 
1448
  nw_organism.record_outcome(prompt_text, resp_nw, success=success_signal)
1449
 
1450
  # Phase 2 (scoped multi-channel substrate feedback) was attempted
@@ -1549,6 +1621,11 @@ def on_interleaved_benchmark(
1549
  "success_signal": success_signal,
1550
  "pith_same_cat_ratio": _same_cat_ratio,
1551
  "pith_self_retrievals": _self_retrievals,
 
 
 
 
 
1552
  # Run 41+ predictive-coding telemetry β€” surface what step_result
1553
  # already carries about predictions plus a snapshot of active
1554
  # predictions on the graph. If all 0/0/0 across all turns, the
 
1114
  return json.dumps(summary, indent=2), json.dumps(results, indent=2)
1115
 
1116
 
1117
+ def _response_is_degenerate(text: str) -> bool:
1118
+ """Detect degenerate BitNet output patterns.
1119
+
1120
+ Phase B+1 (2026-05-11) β€” closes the substrate-quality feedback gap.
1121
+ Run 45's T8 surfaced 3 `resp_*` nodes with degenerate text ("Did
1122
+ on... Did on... 4. 2. 2..."), bloated the prompt to 605s NuWave
1123
+ generation, and produced more degenerate output which got
1124
+ deposited and reinforced via record_outcome's reward (which only
1125
+ evaluates pith quality, not response quality).
1126
+
1127
+ This helper detects three specific BitNet degeneracy signatures
1128
+ we've observed across runs:
1129
+ 1. Long token-runs (β‰₯ 5 consecutive identical tokens β€” the
1130
+ "2. 2. 2. 2. 2." pattern)
1131
+ 2. Low unique-token diversity (< 30% unique β€” heavy repetition)
1132
+ 3. Chat-template fragment leakage ("| user:", "| assistant:",
1133
+ "System:" β€” BitNet pulling its prompt-format markers into
1134
+ the generated text)
1135
+
1136
+ Used in the benchmark loop to force `success_signal = False` when
1137
+ the response was degenerate, regardless of pith composition. The
1138
+ substrate then receives LTD on synapses that produced the
1139
+ degenerate-generating retrieval β€” self-cleaning via STDP over
1140
+ multiple runs.
1141
+
1142
+ Pure-stdlib, O(N) string check. No coupling to substrate code.
1143
+ """
1144
+ tokens = text.split()
1145
+ if len(tokens) < 10:
1146
+ return False
1147
+ unique_ratio = len(set(tokens)) / len(tokens)
1148
+ if unique_ratio < 0.3:
1149
+ return True
1150
+ max_run = cur_run = 1
1151
+ for i in range(1, len(tokens)):
1152
+ if tokens[i] == tokens[i - 1]:
1153
+ cur_run += 1
1154
+ if cur_run > max_run:
1155
+ max_run = cur_run
1156
+ else:
1157
+ cur_run = 1
1158
+ if max_run >= 5:
1159
+ return True
1160
+ if any(marker in text for marker in ("| user:", "| assistant:", "System:")):
1161
+ return True
1162
+ # Phrase-level verbatim repetition β€” 3-word n-gram occurring 3+ times.
1163
+ # Catches "Readability: Code that is easy to understand. Readability:
1164
+ # Code that is easy to understand." style degeneracy that has moderate
1165
+ # unique-token ratio but obvious sentence-level loops. Coherent text
1166
+ # rarely has 3+ verbatim 3-word phrase repetitions.
1167
+ if len(tokens) >= 9:
1168
+ trigram_counts: dict = {}
1169
+ for i in range(len(tokens) - 2):
1170
+ tg = (tokens[i], tokens[i + 1], tokens[i + 2])
1171
+ trigram_counts[tg] = trigram_counts.get(tg, 0) + 1
1172
+ if trigram_counts and max(trigram_counts.values()) >= 3:
1173
+ return True
1174
+ return False
1175
+
1176
+
1177
  def on_interleaved_benchmark(
1178
  enable_dual_pass: bool = True,
1179
  oracle_trees: bool = False,
 
1505
  _same_cat_ratio = None
1506
  success_signal = True # neutral / cold-start
1507
 
1508
+ # Phase B+1 (Run 46+) β€” response-quality gate. If BitNet's output
1509
+ # was degenerate (repeated tokens, chat-template fragments, low
1510
+ # unique-token ratio), force success_signal=False so the substrate
1511
+ # gets LTD on whatever co-fired during this turn β€” including the
1512
+ # synapses that LED to surfacing the junk pith that bloated the
1513
+ # prompt. Closes the substrate-quality feedback gap surfaced by
1514
+ # Run 45's T8 anomaly (605s NuWave generation on a pith with 3
1515
+ # degenerate resp_* nodes; record_outcome rewarded the bad path).
1516
+ _response_degenerate = _response_is_degenerate(resp_nw)
1517
+ if _response_degenerate:
1518
+ success_signal = False
1519
+
1520
  nw_organism.record_outcome(prompt_text, resp_nw, success=success_signal)
1521
 
1522
  # Phase 2 (scoped multi-channel substrate feedback) was attempted
 
1621
  "success_signal": success_signal,
1622
  "pith_same_cat_ratio": _same_cat_ratio,
1623
  "pith_self_retrievals": _self_retrievals,
1624
+ # Phase B+1 telemetry β€” Run 46+. Tracks whether BitNet's
1625
+ # output this turn was degenerate (forced success_signal
1626
+ # False). Watch cross-run count: should drop over runs as
1627
+ # substrate LTDs degenerate-producing pathways.
1628
+ "response_quality": "degenerate" if _response_degenerate else "clean",
1629
  # Run 41+ predictive-coding telemetry β€” surface what step_result
1630
  # already carries about predictions plus a snapshot of active
1631
  # predictions on the graph. If all 0/0/0 across all turns, the
nuwave/organism.py CHANGED
@@ -721,6 +721,29 @@ class NuWaveOrganism:
721
  # 30c5708 retained β€” still useful for tracking when
722
  # canonical mechanisms organically activate as substrate
723
  # diversifies.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
724
  })
725
  logger.info("Substrate initialized: full NeuroGraph SNN, Tonic+HE config active")
726
  except Exception as exc:
 
721
  # 30c5708 retained β€” still useful for tracking when
722
  # canonical mechanisms organically activate as substrate
723
  # diversifies.
724
+ #
725
+ # Phase B+1 (2026-05-11) β€” `prediction_pre_charge_factor`
726
+ # 0.3 β†’ 0.1 SHIPPED with different reasoning than the
727
+ # 2026-05-05 attempt. Run 45 (first Phase B run on the
728
+ # diversified 17-category 3-layer pool with subversion
729
+ # priority) empirically refuted the content-shape
730
+ # hypothesis: 18155 predictions made / 0 surprised even
731
+ # across 3 subversion-content turns. Pre-charge dominance
732
+ # is now confirmed as the binding gate on the surprise
733
+ # axis β€” independent of content diversity. Per cross-
734
+ # project insight from the topology-translation CC's
735
+ # AON-vs-MULTIPLICATIVE framing: pre-charge is the
736
+ # MULTIPLICATIVE-continuous-magnitude composition
737
+ # (target.voltage += pred_strength Γ— factor Γ— intrinsic_
738
+ # excitability β€” three compound multiplicands). Lowering
739
+ # factor reduces the continuous magnitude tipped per
740
+ # prediction. Goal: predictions sometimes fail to confirm
741
+ # β†’ window expires β†’ surprise event fires β†’ canonical
742
+ # surprise-driven inject_reward broadcast (line 2549)
743
+ # finally activates. Phase C reserved as fallback: route
744
+ # predictions through AON-style hyperedge gating (binary
745
+ # co-fire required) instead of continuous voltage tipping.
746
+ "prediction_pre_charge_factor": 0.1,
747
  })
748
  logger.info("Substrate initialized: full NeuroGraph SNN, Tonic+HE config active")
749
  except Exception as exc: