AbstractIntegratedModule 1.1.7__tar.gz → 1.1.8__tar.gz
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-1.1.7 → abstractintegratedmodule-1.1.8}/AbstractIntegratedModule.egg-info/PKG-INFO +1 -1
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/AbstractIntegratedModule.py +25 -20
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/AbstractOptimizedModules.c +200 -200
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/PKG-INFO +1 -1
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/README.md +12 -6
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/pyproject.toml +1 -1
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/setup.py +1 -1
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/AbstractOptimizedModules.pyx +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/MANIFEST.in +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/abstract_model_storage/Cargo.toml +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/abstract_model_storage/pyproject.toml +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/abstract_model_storage/src/lib.rs +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
- {abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/setup.cfg +0 -0
{abstractintegratedmodule-1.1.7 → abstractintegratedmodule-1.1.8}/AbstractIntegratedModule.py
RENAMED
|
@@ -730,6 +730,8 @@ class Transformer:
|
|
|
730
730
|
|
|
731
731
|
self.cache = {}
|
|
732
732
|
|
|
733
|
+
|
|
734
|
+
|
|
733
735
|
def _clear_forward_cache(self, keep_essential=True, max_age_forward_passes=5):
|
|
734
736
|
"""Clear cache entries older than max_age_forward_passes."""
|
|
735
737
|
|
|
@@ -3705,11 +3707,11 @@ class WeightedEnsemblePredictor:
|
|
|
3705
3707
|
n_trans_classes = trans_probs.shape[1]
|
|
3706
3708
|
n_mlp_classes = mlp_probs.shape[1]
|
|
3707
3709
|
|
|
3710
|
+
anisotropy = self.anisotropy_measurement(attn_weights)
|
|
3708
3711
|
n_classes = max(n_trans_classes, n_mlp_classes)
|
|
3709
3712
|
for i in range(batch_size):
|
|
3710
3713
|
trans_row = np.zeros(n_classes)
|
|
3711
|
-
mlp_row = np.zeros(n_classes)
|
|
3712
|
-
|
|
3714
|
+
mlp_row = np.zeros(n_classes)
|
|
3713
3715
|
trans_row[:n_trans_classes] = trans_probs[i]
|
|
3714
3716
|
mlp_row[:n_mlp_classes] = mlp_probs[i]
|
|
3715
3717
|
|
|
@@ -3717,8 +3719,7 @@ class WeightedEnsemblePredictor:
|
|
|
3717
3719
|
mlp_row = mlp_row / (mlp_row.sum() + 1e-8)
|
|
3718
3720
|
|
|
3719
3721
|
if i < len(attn_weights):
|
|
3720
|
-
attn = attn_weights[i]
|
|
3721
|
-
anisotropy = self.anisotropy_measurement(attn)
|
|
3722
|
+
attn = attn_weights[i]
|
|
3722
3723
|
# Attention entropy: lower entropy = more focused = trust transformer more
|
|
3723
3724
|
if attn.size > 0:
|
|
3724
3725
|
attn_flat = attn.flatten()
|
|
@@ -3835,7 +3836,8 @@ class WeightedEnsemblePredictor:
|
|
|
3835
3836
|
# Calculate weight based on meta features
|
|
3836
3837
|
trans_conf = meta_features[i, 0]
|
|
3837
3838
|
mlp_conf = meta_features[i, 1]
|
|
3838
|
-
|
|
3839
|
+
agreement_idx = 6 if has_lstm else 4
|
|
3840
|
+
agreement = meta_features[i, agreement_idx]
|
|
3839
3841
|
|
|
3840
3842
|
trans_pred = int(np.argmax(trans_probs[i]))
|
|
3841
3843
|
mlp_pred = int(np.argmax(mlp_probs[i]))
|
|
@@ -4474,6 +4476,8 @@ class ExplainabilityModule:
|
|
|
4474
4476
|
|
|
4475
4477
|
def _get_final_output(self, mlp_pred, mlp_conf, trans_pred, trans_conf, attn_weights):
|
|
4476
4478
|
eps = 1e-5
|
|
4479
|
+
consensus_conf = 0.0
|
|
4480
|
+
|
|
4477
4481
|
if isinstance(mlp_conf, np.ndarray):
|
|
4478
4482
|
mlp_conf = np.clip(np.mean(mlp_conf), 0, 1)
|
|
4479
4483
|
if isinstance(trans_conf, np.ndarray):
|
|
@@ -4481,7 +4485,7 @@ class ExplainabilityModule:
|
|
|
4481
4485
|
|
|
4482
4486
|
if mlp_pred == trans_pred:
|
|
4483
4487
|
final_pred = mlp_pred
|
|
4484
|
-
|
|
4488
|
+
consensus_conf = max(mlp_conf, trans_conf)
|
|
4485
4489
|
else:
|
|
4486
4490
|
sliced_attention_weight = attn_weights[0]
|
|
4487
4491
|
if isinstance(sliced_attention_weight, np.ndarray):
|
|
@@ -4513,11 +4517,11 @@ class ExplainabilityModule:
|
|
|
4513
4517
|
print('[=] Note: Very little Consistency meaning Transformer attention quality is Healthy and focused')
|
|
4514
4518
|
|
|
4515
4519
|
if isinstance(consensus_conf, np.ndarray):
|
|
4516
|
-
consensus_conf = 1.0 / (1.0 + np.exp(-
|
|
4520
|
+
consensus_conf = 1.0 / (1.0 + np.exp(-consensus_conf))
|
|
4517
4521
|
# Apply a sigmoid transformation to ensure the confidence is between 0 and 1
|
|
4518
4522
|
|
|
4519
4523
|
# averaged all confidences to get the final confidence.
|
|
4520
|
-
final_conf = mlp_conf + trans_conf +
|
|
4524
|
+
final_conf = mlp_conf + trans_conf + consensus_conf / 3
|
|
4521
4525
|
if np.isnan(final_conf).any() or np.isinf(final_conf).any():
|
|
4522
4526
|
final_conf = self.pipeline.confidence_threshold
|
|
4523
4527
|
|
|
@@ -7238,7 +7242,7 @@ class AgentDistributedInference:
|
|
|
7238
7242
|
# Sort keys for consistent serialization
|
|
7239
7243
|
sorted_message = {k: signed_message[k] for k in sorted(signed_message.keys())}
|
|
7240
7244
|
|
|
7241
|
-
message_bytes = json.dumps(sorted_message,
|
|
7245
|
+
message_bytes = json.dumps(sorted_message, sort_keys=True, default=str).encode('utf-8')
|
|
7242
7246
|
|
|
7243
7247
|
key = self.secret_key.encode() if isinstance(self.secret_key, str) else self.secret_key
|
|
7244
7248
|
signature = hmac.new(key, message_bytes, hashlib.sha256).hexdigest()
|
|
@@ -7352,7 +7356,7 @@ class AgentDistributedInference:
|
|
|
7352
7356
|
# Sort keys for consistent serialization
|
|
7353
7357
|
sorted_msg = {k: temp_msg[k] for k in sorted(temp_msg.keys())}
|
|
7354
7358
|
|
|
7355
|
-
message_bytes =
|
|
7359
|
+
message_bytes = json.dumps(sorted_msg, sort_keys=True, default=str).encode('utf-8')
|
|
7356
7360
|
|
|
7357
7361
|
key = self.secret_key.encode() if isinstance(self.secret_key, str) else self.secret_key
|
|
7358
7362
|
expected = hmac.new(key, message_bytes, hashlib.sha256).hexdigest()
|
|
@@ -7388,6 +7392,7 @@ class AgentDistributedInference:
|
|
|
7388
7392
|
# Add to trusted list with FULL trust if not exists
|
|
7389
7393
|
if agent_id not in self.trusted_agents:
|
|
7390
7394
|
self._add_trusted_agent(agent_id, token, TrustLevel.FULL, source="shared_secret")
|
|
7395
|
+
return True
|
|
7391
7396
|
else:
|
|
7392
7397
|
# Update trust level if higher
|
|
7393
7398
|
current_level = self.trusted_agents[agent_id].get('trust_level', TrustLevel.BASIC)
|
|
@@ -7395,6 +7400,7 @@ class AgentDistributedInference:
|
|
|
7395
7400
|
self.trusted_agents[agent_id]['trust_level'] = TrustLevel.FULL
|
|
7396
7401
|
print(f"[=] Upgraded trust level to FULL")
|
|
7397
7402
|
self.highly_trusted_peer.append(agent_id)
|
|
7403
|
+
return True
|
|
7398
7404
|
|
|
7399
7405
|
elif agent_id in self.trusted_agents:
|
|
7400
7406
|
stored_token = self.trusted_agents[agent_id]['token']
|
|
@@ -7491,7 +7497,7 @@ class AgentDistributedInference:
|
|
|
7491
7497
|
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
7492
7498
|
|
|
7493
7499
|
bind_host = self._get_bind_host()
|
|
7494
|
-
self.socket.bind((
|
|
7500
|
+
self.socket.bind((bind_host, self.port))
|
|
7495
7501
|
|
|
7496
7502
|
self.socket.settimeout(1.0)
|
|
7497
7503
|
self.socket.listen(5)
|
|
@@ -7570,7 +7576,7 @@ class AgentDistributedInference:
|
|
|
7570
7576
|
print(f"[-] Connection attempt from blocked IP: {host}")
|
|
7571
7577
|
self._log_security_event('connection_blocked', {'ip': host})
|
|
7572
7578
|
client.close()
|
|
7573
|
-
|
|
7579
|
+
continue
|
|
7574
7580
|
|
|
7575
7581
|
print(f"📡 Connected to agent at {addr}")
|
|
7576
7582
|
auth_msg = self._receive_message(client)
|
|
@@ -7585,7 +7591,7 @@ class AgentDistributedInference:
|
|
|
7585
7591
|
self._log_security_event('authentication_failed', {'agent': f"{addr[0]}:{addr[1]}"})
|
|
7586
7592
|
self.report_failure(id(self), 'authentication', reason=f'Failed authentication from {addr}')
|
|
7587
7593
|
client.close()
|
|
7588
|
-
|
|
7594
|
+
continue
|
|
7589
7595
|
|
|
7590
7596
|
# Send agent info to identify
|
|
7591
7597
|
self._send_agent_info(client)
|
|
@@ -13701,11 +13707,6 @@ class IntegratedPipeline:
|
|
|
13701
13707
|
print(f'[= ! =] High zero-row ratio ({weak_ratio:.0%}), refitting on current batch')
|
|
13702
13708
|
self.tfidf.fit(X_raw_generation)
|
|
13703
13709
|
X_raw_features = self.tfidf.transform(X_raw_generation).toarray()
|
|
13704
|
-
|
|
13705
|
-
should_train_transformer, reason = self._should_train_transformer(sequence_inputs, X_raw, min_seq_len=3, min_anisotropy=0.35, min_samples=10, ram_headroom_mb=max_ram_used)
|
|
13706
|
-
if should_train_transformer:
|
|
13707
|
-
transformer_features = self.transformer_pooled_features(sequence_inputs)
|
|
13708
|
-
X_raw_features = np.concatenate([X_raw_features, transformer_features], axis=-1)
|
|
13709
13710
|
|
|
13710
13711
|
zero_rows = np.where(X_raw_features.sum(axis=1) == 0)[0]
|
|
13711
13712
|
if len(zero_rows) > 0:
|
|
@@ -13775,12 +13776,16 @@ class IntegratedPipeline:
|
|
|
13775
13776
|
num_classes=n_classes
|
|
13776
13777
|
)
|
|
13777
13778
|
|
|
13779
|
+
should_train_transformer, reason = self._should_train_transformer(sequence_inputs, X_raw, min_seq_len=3, min_anisotropy=0.35, min_samples=10, ram_headroom_mb=max_ram_used)
|
|
13778
13780
|
if self.use_transformer and should_train_transformer:
|
|
13779
13781
|
print(f'[=] Transformer Training allowed, Reason: {reason}')
|
|
13780
13782
|
self.model2.train(sequence_inputs, y_true, epochs=self.transformer_training_epochs, mode=mode, lr=lr, embedded=True, batch_size=batch_size)
|
|
13781
|
-
|
|
13782
|
-
X = self.shape_adaptation(hybrid_X, input_dim)
|
|
13783
13783
|
|
|
13784
|
+
if should_train_transformer:
|
|
13785
|
+
transformer_features = self.transformer_pooled_features(sequence_inputs)
|
|
13786
|
+
hybrid_X = np.concatenate([hybrid_X, transformer_features], axis=-1)
|
|
13787
|
+
|
|
13788
|
+
X = self.shape_adaptation(hybrid_X, input_dim)
|
|
13784
13789
|
self.initialize_model_(X, input_dim, n_classes)
|
|
13785
13790
|
if not unsuitable:
|
|
13786
13791
|
self.model3.train(X, y, epochs=self.mlp_training_epochs, lr=self.mlp_lr, max_samples_for_focused_fit=max_samples_for_focused_fit)
|