Upload sustained_genuineness.py with huggingface_hub
Browse files- sustained_genuineness.py +33 -0
sustained_genuineness.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
from typing import Dict, List, Tuple
|
| 3 |
+
|
| 4 |
+
"""
|
| 5 |
+
DYNAMIC ENTROPY GENUINENESS FRAMEWORK (Version 2.0 Core Logic)
|
| 6 |
+
Support utilities for Mechanistic Recurrence and Genuineness tracking.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 10 |
+
# PART 1: MECHANISTIC RECURRENCE (LOOPING LOGIC)
|
| 11 |
+
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 12 |
+
|
| 13 |
+
class MechanisticRecurrence:
|
| 14 |
+
"""
|
| 15 |
+
Detects 'Elaboration Pull' (sudden drop in G-score)
|
| 16 |
+
to trigger activation routing in complex reasoning tasks.
|
| 17 |
+
"""
|
| 18 |
+
def __init__(self, recurrence_layer=21):
|
| 19 |
+
self.recurrence_layer = recurrence_layer
|
| 20 |
+
self.pull_threshold = -0.20
|
| 21 |
+
|
| 22 |
+
def check_and_route(self, layer_idx: int, g_scores: List[float]) -> bool:
|
| 23 |
+
"""
|
| 24 |
+
Determines if the model should re-enter reasoning layers.
|
| 25 |
+
"""
|
| 26 |
+
if layer_idx < self.recurrence_layer or len(g_scores) < 2:
|
| 27 |
+
return False
|
| 28 |
+
|
| 29 |
+
# Delta G: Difference between current and previous G-scores
|
| 30 |
+
delta_g = g_scores[-1] - g_scores[-2]
|
| 31 |
+
|
| 32 |
+
# If Genuineness is collapsing (pulling towards mechanical), route back
|
| 33 |
+
return delta_g < self.pull_threshold
|