AbstractIntegratedModule 0.1.5__py3-none-any.whl → 0.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- AbstractIntegratedModule.py +22 -18
- {abstractintegratedmodule-0.1.5.dist-info → abstractintegratedmodule-0.1.7.dist-info}/METADATA +1043 -1010
- abstractintegratedmodule-0.1.7.dist-info/RECORD +5 -0
- abstractintegratedmodule-0.1.5.dist-info/RECORD +0 -7
- abstractintegratedmodule-0.1.5.dist-info/licenses/LICENSE.txt +0 -21
- abstractintegratedmodule-0.1.5.dist-info/licenses/LICENSE.txt:Zone.Identifier +0 -0
- {abstractintegratedmodule-0.1.5.dist-info → abstractintegratedmodule-0.1.7.dist-info}/WHEEL +0 -0
- {abstractintegratedmodule-0.1.5.dist-info → abstractintegratedmodule-0.1.7.dist-info}/top_level.txt +0 -0
AbstractIntegratedModule.py
CHANGED
|
@@ -1783,6 +1783,7 @@ class WeightedEnsemblePredictor:
|
|
|
1783
1783
|
# the wrong row is applied. Flagged in code review.
|
|
1784
1784
|
batch_size = trans_probs.shape[0]
|
|
1785
1785
|
n_classes = trans_probs.shape[1]
|
|
1786
|
+
threshold_feature = 0.1 + self.pipeline.confidence_threshold
|
|
1786
1787
|
|
|
1787
1788
|
n_trans_classes = trans_probs.shape[1]
|
|
1788
1789
|
n_mlp_classes = mlp_probs.shape[1]
|
|
@@ -1816,13 +1817,16 @@ class WeightedEnsemblePredictor:
|
|
|
1816
1817
|
features.append(np.std(attn))
|
|
1817
1818
|
features.append(np.max(attn))
|
|
1818
1819
|
else:
|
|
1819
|
-
features.extend([
|
|
1820
|
+
features.extend([threshold_feature, threshold_feature])
|
|
1820
1821
|
else:
|
|
1821
|
-
features.extend([
|
|
1822
|
+
features.extend([threshold_feature, threshold_feature])
|
|
1822
1823
|
|
|
1823
1824
|
meta_features.append(features)
|
|
1824
1825
|
|
|
1825
|
-
meta_features = np.array(meta_features)
|
|
1826
|
+
meta_features = np.array(meta_features)
|
|
1827
|
+
featured_AME = self.pipeline.AME_Encoder(meta_features)
|
|
1828
|
+
AME_sigmoid = 1.0 / (1.0 + np.exp(-featured_AME))
|
|
1829
|
+
|
|
1826
1830
|
ensemble = np.zeros_like(trans_probs)
|
|
1827
1831
|
|
|
1828
1832
|
for i in range(batch_size):
|
|
@@ -1832,7 +1836,7 @@ class WeightedEnsemblePredictor:
|
|
|
1832
1836
|
agreement = meta_features[i, 4]
|
|
1833
1837
|
|
|
1834
1838
|
# Boost weight when models agree
|
|
1835
|
-
base_weight =
|
|
1839
|
+
base_weight = threshold_feature + AME_sigmoid * agreement
|
|
1836
1840
|
|
|
1837
1841
|
# Adjust based on relative confidence
|
|
1838
1842
|
if trans_conf > mlp_conf:
|
|
@@ -1852,7 +1856,7 @@ class WeightedEnsemblePredictor:
|
|
|
1852
1856
|
def calibrate_weights(self, input_ids, X_mlp, y_true, step=3):
|
|
1853
1857
|
print("\n🔧 Calibrating ensemble weights...")
|
|
1854
1858
|
|
|
1855
|
-
best_weight = 0.
|
|
1859
|
+
best_weight = 0.1 + self.pipeline.confidence_threshold
|
|
1856
1860
|
best_accuracy = 0
|
|
1857
1861
|
|
|
1858
1862
|
# Try different weights
|
|
@@ -4065,7 +4069,7 @@ class AgentDistributedInference:
|
|
|
4065
4069
|
# Security: Audit log
|
|
4066
4070
|
self.security_log = []
|
|
4067
4071
|
|
|
4068
|
-
self.enable_ssl =
|
|
4072
|
+
self.enable_ssl = False # Set to True to enable SSL encryption
|
|
4069
4073
|
# i provided basic cert file and key since there are other layered security other than ssl, and also due to infrequent external connections.
|
|
4070
4074
|
self.ssl_cert_file = ssl_cert_file
|
|
4071
4075
|
self.ssl_key_file = ssl_key_file
|
|
@@ -4307,7 +4311,7 @@ class AgentDistributedInference:
|
|
|
4307
4311
|
signature = hmac.new(key, message_bytes, hashlib.sha256).hexdigest()
|
|
4308
4312
|
|
|
4309
4313
|
print(f'|| Signing message with: {len(message)} total of size, with signature: {signature}')
|
|
4310
|
-
logger.info(f"[=] Signing message: {len(message)}
|
|
4314
|
+
logger.info(f"[=] Signing message: {len(message)}")
|
|
4311
4315
|
return signature
|
|
4312
4316
|
|
|
4313
4317
|
|
|
@@ -4316,7 +4320,7 @@ class AgentDistributedInference:
|
|
|
4316
4320
|
# Verify signature - with timestamp in message
|
|
4317
4321
|
|
|
4318
4322
|
# Create a copy without the signature field
|
|
4319
|
-
print(f'|| Verifying message signature total: {len(message)}
|
|
4323
|
+
print(f'|| Verifying message signature total: {len(message)}')
|
|
4320
4324
|
temp_msg = {k: v for k, v in message.items() if k != 'signature'}
|
|
4321
4325
|
|
|
4322
4326
|
if 'timestamp' in temp_msg and isinstance(temp_msg['timestamp'], str):
|
|
@@ -4336,7 +4340,7 @@ class AgentDistributedInference:
|
|
|
4336
4340
|
|
|
4337
4341
|
result = hmac.compare_digest(expected, signature)
|
|
4338
4342
|
|
|
4339
|
-
print(f'[=] Comparing result
|
|
4343
|
+
print(f'[=] Comparing result...')
|
|
4340
4344
|
print(f'|| Signature verification result: {result}')
|
|
4341
4345
|
logger.info(f"[-] Signature verification result: {result}")
|
|
4342
4346
|
|
|
@@ -4576,12 +4580,9 @@ class AgentDistributedInference:
|
|
|
4576
4580
|
self._log_security_event('connection_blocked', {'ip': host})
|
|
4577
4581
|
return None
|
|
4578
4582
|
|
|
4579
|
-
#
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
else:
|
|
4583
|
-
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
4584
|
-
|
|
4583
|
+
# Socket creation
|
|
4584
|
+
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
|
4585
|
+
|
|
4585
4586
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, 1024 * 1024) # 1MB
|
|
4586
4587
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_SNDBUF, 1024 * 1024) # 1MB
|
|
4587
4588
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
|
|
@@ -4591,7 +4592,10 @@ class AgentDistributedInference:
|
|
|
4591
4592
|
sock.settimeout(self.connection_timeout)
|
|
4592
4593
|
print(f'[==] Connecting to {host}:{port}...')
|
|
4593
4594
|
sock.connect((host, port))
|
|
4594
|
-
|
|
4595
|
+
|
|
4596
|
+
if self.enable_ssl and self.ssl_context:
|
|
4597
|
+
sock = self.ssl_context.wrap_socket(sock, server_hostname=host)
|
|
4598
|
+
print('[==] Socket Connected with SSL Provided!')
|
|
4595
4599
|
|
|
4596
4600
|
# ========== SEND AUTHENTICATION FIRST ==========
|
|
4597
4601
|
# Send agent info and token BEFORE receiving
|
|
@@ -10819,7 +10823,7 @@ class PipelinePredictionManager:
|
|
|
10819
10823
|
]
|
|
10820
10824
|
|
|
10821
10825
|
# Transformer top predictions
|
|
10822
|
-
if trans_probs:
|
|
10826
|
+
if trans_probs is not None:
|
|
10823
10827
|
if trans_probs.ndim > 1:
|
|
10824
10828
|
trans_probs = trans_probs[i][:num_classes] if num_classes > 0 else trans_probs[i]
|
|
10825
10829
|
else:
|
|
@@ -11088,7 +11092,7 @@ class ConsecutivePeerAgent:
|
|
|
11088
11092
|
# Verify message signature
|
|
11089
11093
|
expected = self._sign_message({k: v for k, v in message.items() if k != 'signature'})
|
|
11090
11094
|
|
|
11091
|
-
print(f'[ConsecutivePeerAgent] Comparing Signature
|
|
11095
|
+
print(f'[ConsecutivePeerAgent] Comparing Signature and verfiying...')
|
|
11092
11096
|
return hmac.compare_digest(expected, signature)
|
|
11093
11097
|
|
|
11094
11098
|
def _send_message(self, sock: socket.socket, message: dict) -> bool:
|