AbstractIntegratedModule 1.1.1__tar.gz → 1.1.2__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.
Files changed (23) hide show
  1. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/AbstractIntegratedModule.egg-info/PKG-INFO +1 -1
  2. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/AbstractIntegratedModule.py +85 -36
  3. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/AbstractOptimizedModules.c +200 -200
  4. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/PKG-INFO +1 -1
  5. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/README.md +5 -5
  6. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/pyproject.toml +1 -1
  7. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/setup.py +1 -1
  8. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
  9. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
  10. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
  11. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
  12. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/AbstractOptimizedModules.pyx +0 -0
  13. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/MANIFEST.in +0 -0
  14. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/abstract_model_storage/Cargo.toml +0 -0
  15. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/abstract_model_storage/pyproject.toml +0 -0
  16. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/abstract_model_storage/src/lib.rs +0 -0
  17. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
  18. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
  19. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
  20. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
  21. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
  22. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
  23. {abstractintegratedmodule-1.1.1 → abstractintegratedmodule-1.1.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 1.1.1
3
+ Version: 1.1.2
4
4
  Summary: Integrated Pipeline with Specialized Non-LLM AI Agent Framework for ARM64 architecture
5
5
  Author: Micro-Novelty
6
6
  Author-email: Micro-Novelty <hernikpuspita5@gmail.com>
@@ -21,6 +21,7 @@ from collections import defaultdict
21
21
  import hashlib
22
22
  import ssl
23
23
  import os
24
+ import glob
24
25
  import asyncio
25
26
  import queue
26
27
  import threading
@@ -1567,6 +1568,7 @@ class Transformer:
1567
1568
  acc = float(np.mean(preds == true))
1568
1569
 
1569
1570
  return loss, acc
1571
+
1570
1572
 
1571
1573
  def _sanitize_string_chars(self, x):
1572
1574
  if isinstance(x, (str, np.str_)):
@@ -2035,8 +2037,10 @@ class MLP:
2035
2037
  # re adapt shape of pred_counts and error_counts if they don't match prob shape
2036
2038
  if self.pred_counts.shape != prob.shape:
2037
2039
  self.pred_counts = np.zeros_like(prob)
2040
+ self.pred_counts *= decay
2038
2041
  if self.error_counts.shape != prob.shape:
2039
2042
  self.error_counts = np.zeros_like(prob)
2043
+ self.error_counts *= decay
2040
2044
 
2041
2045
  except Exception as e:
2042
2046
  print(f'[!] Cant check and calibrate probs based on penalty due to: {e}')
@@ -3900,9 +3904,6 @@ class CrossSessionAutomation:
3900
3904
  print(f"✅ Session imported! Total memories: {len(self.pipeline.memory)}")
3901
3905
 
3902
3906
  def sync_with_another_device(self, device_ip, port=5000):
3903
- import socket
3904
- import pickle
3905
-
3906
3907
  # Export current session
3907
3908
  temp_file = self.export_session(f"sync_{self.session_id}")
3908
3909
 
@@ -3920,8 +3921,6 @@ class CrossSessionAutomation:
3920
3921
 
3921
3922
 
3922
3923
  def list_sessions(self, name):
3923
- import glob
3924
-
3925
3924
  sessions = glob.glob(f"{name}*.json")
3926
3925
 
3927
3926
  print(f"\n📚 Available Sessions: {sessions}")
@@ -4268,7 +4267,7 @@ class ExplainabilityModule:
4268
4267
  if not self.learned_from_feedback:
4269
4268
  return
4270
4269
 
4271
- print(f"\n🔄 Consolidating {len(self.learned_from_feedback)} supervised memories...")
4270
+ print(f"\n[🔄] Consolidating {len(self.learned_from_feedback)} supervised memories...")
4272
4271
 
4273
4272
  # Extract all supervised examples
4274
4273
  texts = [m['input'] for m in self.learned_from_feedback]
@@ -4524,7 +4523,7 @@ class ExplainabilityModule:
4524
4523
 
4525
4524
  def _compute_anisotropy(self, attn_weights):
4526
4525
  if attn_weights is None or len(attn_weights) == 0:
4527
- return 0.5
4526
+ return self.pipeline.confidence_threshold
4528
4527
 
4529
4528
  try:
4530
4529
 
@@ -4538,7 +4537,7 @@ class ExplainabilityModule:
4538
4537
  return np.std(val) / (np.mean(val) + 1e-8)
4539
4538
 
4540
4539
  except:
4541
- return 0.5
4540
+ return self.pipeline.confidence_threshold
4542
4541
 
4543
4542
  def _compute_attention_quality(self, attn_weights):
4544
4543
  eps = 1e-5
@@ -4569,9 +4568,9 @@ class ExplainabilityModule:
4569
4568
 
4570
4569
  quality = norm_entropy * (1.0 - AMR) + avg_max * AMR + norm_var * AMR
4571
4570
  return np.clip(quality, 0, 1)
4572
- except:
4573
- print("[-] Error occurred while computing attention quality.")
4574
- AMR = 0.1
4571
+ except Exception as e:
4572
+ print(f"[-] Error occurred while computing attention quality: {e}")
4573
+ AMR = self.pipeline.confidence_threshold
4575
4574
  if attn_weights is not None:
4576
4575
  print(f"[-] Attention weights shape: {attn_weights.shape}")
4577
4576
  AME = self.AME_Encoder(attn_weights)
@@ -4681,19 +4680,19 @@ class ExplainabilityModule:
4681
4680
  d1 = self.decision_history[idx1]
4682
4681
  d2 = self.decision_history[idx2]
4683
4682
 
4684
- comparison.append(f"🔄 Decision Comparison")
4683
+ comparison.append(f"🔄 Ensemble Decision Comparison")
4685
4684
  comparison.append("====================================")
4686
4685
 
4687
- comparison.append("[<] Earlier Decision:")
4686
+ comparison.append("[<] Ensemble Earlier Decision:")
4688
4687
  comparison.append(f"[+] Input: {d1['input']}")
4689
4688
  comparison.append(f"[+] Detail Focus: {d1['prediction']} ({d1['confidence']:.1%})")
4690
4689
 
4691
- comparison.append("🧠 Later Decision:")
4690
+ comparison.append("🧠 Ensemble Later Decision:")
4692
4691
  comparison.append(f"[=] Input: {d2['input']}")
4693
4692
  comparison.append(f"[=] Detail Focus: {d2['prediction']} ({d2['confidence']:.1%})")
4694
4693
 
4695
- comparison.append("🔬 Learning Progress: ")
4696
- comparison.append(f"• Confidence {'increased' if d2['confidence'] > d1['confidence'] else 'decreased'} from {d1['confidence']} to {d2['confidence']}")
4694
+ comparison.append("🔬 Ensemble Learning Progress: ")
4695
+ comparison.append(f"• Confidence {'increased' if d2['confidence'] > d1['confidence'] else 'decreased'} from {d1['confidence']:.1%} to {d2['confidence']:.1%}")
4697
4696
  comparison.append(f"• The model is becoming {'more' if d2['confidence'] > d1['confidence'] else 'less'} certain")
4698
4697
 
4699
4698
  return '\n'.join(comparison)
@@ -4710,9 +4709,9 @@ class ExplainabilityModule:
4710
4709
 
4711
4710
  # Check transformer confidence
4712
4711
  if details['transformer']['confidence'] > 0.8:
4713
- factors.append(f"✅ Transformer is confident ({details['transformer']['confidence']}) with focused attention")
4712
+ factors.append(f"✅ Transformer is confident ({details['transformer']['confidence']:.1%}) with focused attention")
4714
4713
  elif details['transformer']['confidence'] < 0.5:
4715
- factors.append(f"🤔 Transformer is uncertain ({details['transformer']['confidence']}) due to scattered attention")
4714
+ factors.append(f"🤔 Transformer is uncertain with uncertainty up to: ({details['transformer']['confidence']:.1%}), due to scattered attention")
4716
4715
 
4717
4716
  # Check agreement
4718
4717
  if details['agreement']:
@@ -4722,9 +4721,9 @@ class ExplainabilityModule:
4722
4721
 
4723
4722
  # Attention quality
4724
4723
  if details.get('attention_quality', 0) > 0.7:
4725
- factors.append(f"[✅] High attention quality ({details['attention_quality']}) indicates clear consistent patterns!")
4724
+ factors.append(f"[✅] High attention quality: ({details['attention_quality']:.1%}) indicates clear consistent patterns!")
4726
4725
  elif details.get('attention_quality', 0) < 0.3:
4727
- factors.append(f"[-] Low Attention Quality! : ({details['attention_quality']}) Indicates noisy unnecessary patterns on seen data!")
4726
+ factors.append(f"[-] Low Attention Quality: ({details['attention_quality']:.1%}) Indicates inconsistent and ambiguous patterns on seen data!")
4728
4727
 
4729
4728
  return '\n'.join(factors)
4730
4729
 
@@ -9178,6 +9177,7 @@ class QueryNode:
9178
9177
 
9179
9178
  return self.permission
9180
9179
 
9180
+
9181
9181
  def _connect_with_peer(self, node):
9182
9182
  node_id = id(node)
9183
9183
 
@@ -9207,6 +9207,7 @@ class QueryNode:
9207
9207
 
9208
9208
  return self.permission
9209
9209
 
9210
+
9210
9211
  def _adjust_trust(self, node_id, delta):
9211
9212
  """
9212
9213
  trust that actually evolves. EMA-style bounded adjustment.
@@ -9215,6 +9216,7 @@ class QueryNode:
9215
9216
  updated = float(np.clip(current + delta, 0.0, 1.0))
9216
9217
  self._trust_scores[node_id] = updated
9217
9218
 
9219
+
9218
9220
  def _identify_node(self, node):
9219
9221
  eps = 1e-5
9220
9222
  node_id = id(node)
@@ -9238,6 +9240,7 @@ class QueryNode:
9238
9240
  ) + eps
9239
9241
  return False
9240
9242
 
9243
+
9241
9244
  def _node_safety_check(self, node):
9242
9245
  node_id = id(node)
9243
9246
  trust = self._trust_scores.get(node_id, self._default_trust)
@@ -12093,9 +12096,15 @@ class IntegratedPipeline:
12093
12096
  if 0 <= mlp_target < n_classes and i < calibrated.shape[0]:
12094
12097
  if mlp_target_int is None:
12095
12098
  mlp_target_int = int(mlp_target.flat[0])
12096
- calibrated[i, mlp_target_int] = min(
12097
- calibrated[i, mlp_target_int] * (1.5 * (1.0 - abstract_score)), 0.95
12098
- )
12099
+
12100
+ if len(calibrated.shape) >= 2:
12101
+ calibrated[i, mlp_target_int] = min(
12102
+ calibrated[i, mlp_target_int] * (1.5 * (1.0 - abstract_score)), 0.95
12103
+ )
12104
+ else:
12105
+ calibrated[mlp_target_int] = min(
12106
+ calibrated[mlp_target_int] * (1.5 * (1.0 - abstract_score)), 0.95
12107
+ )
12099
12108
 
12100
12109
  if i <= len(calibrated):
12101
12110
  try:
@@ -17162,6 +17171,42 @@ class PipelinePredictionManager:
17162
17171
 
17163
17172
  return X_train, X_val, y_train, y_val
17164
17173
 
17174
+ def _compute_need_ensemble_method(self, anisotropy, AME, error_counts,
17175
+ anisotropy_threshold=0.3,
17176
+ ame_threshold=0.3,
17177
+ error_threshold=0.3,
17178
+ min_signals_required=1):
17179
+ """
17180
+ Ensemble fallback is a safety net — it should trigger if ANY
17181
+ single strong risk signal fires, not only when all signals
17182
+ happen to align simultaneously. Uses max() over error_counts
17183
+ so a single persistently-wrong class triggers assistance even
17184
+ when most other classes are healthy.
17185
+ """
17186
+ signals = []
17187
+
17188
+ if anisotropy is not None and anisotropy > anisotropy_threshold:
17189
+ signals.append(f'anisotropy={anisotropy:.3f}')
17190
+
17191
+ if AME is not None and AME > ame_threshold:
17192
+ signals.append(f'AME={AME:.3f}')
17193
+
17194
+ if error_counts is not None and len(error_counts) > 0:
17195
+ # FIX — max, not mean: catches localized single-class failure
17196
+ # that a flat average would dilute away
17197
+ worst_class_idx = int(np.argmax(error_counts))
17198
+ max_error = float(error_counts[worst_class_idx])
17199
+ if max_error > error_threshold:
17200
+ signals.append(f'error_rate(class={worst_class_idx}, '
17201
+ f'value={max_error:.2f})')
17202
+
17203
+ need_ensemble = len(signals) >= min_signals_required
17204
+
17205
+ if need_ensemble:
17206
+ print(f'[=] Ensemble method triggered by: {", ".join(signals)}')
17207
+
17208
+ return need_ensemble
17209
+
17165
17210
  def advanced_prediction_method(self, titles=None, label_map=None, rules=None,
17166
17211
  X=None, y=None,
17167
17212
  show_proba=False, top_k=3,
@@ -17190,6 +17235,7 @@ class PipelinePredictionManager:
17190
17235
  X_gen = None
17191
17236
  sec_chosen_label = None
17192
17237
  sec_confidence = 0.0
17238
+ final_confidence = 0.0
17193
17239
 
17194
17240
  correct = 0
17195
17241
  sec_correct= 0
@@ -17234,7 +17280,7 @@ class PipelinePredictionManager:
17234
17280
 
17235
17281
  if 0 in X.shape:
17236
17282
  print(f"[⚠️] Warning: X has zero samples in the total shapes, X shapes: {X.shape}. Creating an empty array with shape (1, n_features) for processing..")
17237
- X = np.empty((1, X.shape[1])) # Create an empty array with shape (1, n_features)
17283
+ X = np.empty((1, X.shape[1])) # Created an empty array with shape (1, n_features)
17238
17284
  X = X.reshape(1, -1) # Reshape to (1, n_features) if empty but has features
17239
17285
 
17240
17286
  X_train, X_val, y_train, y_val = self._prepare_train_val_split(
@@ -17371,7 +17417,7 @@ class PipelinePredictionManager:
17371
17417
  if hasattr(self.pipeline.mlp, 'predict_proba'):
17372
17418
  mlp_probs = self.pipeline.model3.predict_proba(X)
17373
17419
  else:
17374
- logits = self.pipeline.mlp.forward(X)
17420
+ logits = self.pipeline.model3.forward(X)
17375
17421
  mlp_probs = self.pipeline._softmax(logits)
17376
17422
 
17377
17423
  # Validate all MLP predictions at once
@@ -17393,7 +17439,6 @@ class PipelinePredictionManager:
17393
17439
  if sequence_ids is not None:
17394
17440
  print("\n[🔍] Using sequence encoding for transformer input due to low anisotropy.")
17395
17441
  input_ids = sequence_ids.copy()
17396
-
17397
17442
  # verify samples for accurate answer from cache
17398
17443
  print('[🔍] Verifying Samples for possible predicted output in cache for accurate answer...')
17399
17444
  cached = self.pipeline.accurate_cache_lookup.lookup(
@@ -17439,12 +17484,13 @@ class PipelinePredictionManager:
17439
17484
  else:
17440
17485
  lstm_probs = None
17441
17486
 
17442
- need_ensemble_method = (
17443
- anisotropy > 0.3 and
17444
- AME is not None and
17445
- AME > 0.3 and
17446
- np.mean(self.error_counts) > 0.3
17447
- )
17487
+
17488
+ threshold = 0.5 + (self.pipeline.confidence_threshold + np.mean(self.error_counts)) / 2
17489
+ need_ensemble_method = self._compute_need_ensemble_method(anisotropy, AME, self.error_counts,
17490
+ anisotropy_threshold=threshold,
17491
+ ame_threshold=threshold,
17492
+ error_threshold=threshold,
17493
+ min_signals_required=1)
17448
17494
 
17449
17495
  results = []
17450
17496
  attention_data = [] if return_attention else None
@@ -17757,7 +17803,7 @@ class PipelinePredictionManager:
17757
17803
  if not results[0].get('models_agree', True) and self.pipeline.use_transformer:
17758
17804
  trans_confidence = results[0].get('trans_confidence', 1e-8)
17759
17805
  confidence = (confidence + trans_confidence / 2) + 1e-5
17760
- print(f'[=] Calibrating confidence around: {confidence:.1%} Due to disagreement between Transformer and MLP.')
17806
+ print(f'[=] Calibrating confidence around: {confidence:.1%}')
17761
17807
 
17762
17808
  if isinstance(chosen_label, str) and chosen_label.startswith("unknown") or float(confidence) < self.pipeline.confidence_threshold:
17763
17809
  if chosen_label is None or chosen_label.startswith('unknown'):
@@ -18034,7 +18080,7 @@ class PipelinePredictionManager:
18034
18080
  print(f"[!] Error in advanced prediction method: {e}, Initiating regular prediction method...")
18035
18081
  traceback.print_exc()
18036
18082
  try:
18037
- results = self.regular_prediction_method(titles=titles, label_map=label_map, rules=rules, X=X, y=y, show_proba=False, top_k=3, batch_size=2, use_transformer=True)
18083
+ results = self.regular_prediction_method(titles=titles, label_map=label_map, rules=rules, X=X, y=y, show_proba=False, top_k=3, batch_size=2, use_transformer=self.pipeline.use_transformer)
18038
18084
  chosen_label = results[0]['predicted']
18039
18085
  confidence = results[0]['confidence']
18040
18086
  except Exception as error:
@@ -18075,7 +18121,7 @@ class PipelinePredictionManager:
18075
18121
  self.pred_counts *= decay
18076
18122
 
18077
18123
  if final_probs is None:
18078
- print('[!] Warning final probabilities is None! returning the probabilities...')
18124
+ print('[!] Warning final probabilities is None! returning the None probabilities...')
18079
18125
  return final_probs
18080
18126
 
18081
18127
  try:
@@ -18109,12 +18155,15 @@ class PipelinePredictionManager:
18109
18155
  prob_sum = final_probs.sum()
18110
18156
  if prob_sum > 1e-8:
18111
18157
  final_probs /= prob_sum
18112
-
18158
+
18113
18159
  # re adapt shape of pred_counts and error_counts if they don't match prob shape
18114
18160
  if self.pred_counts.shape != final_probs.shape:
18115
18161
  self.pred_counts = np.zeros_like(final_probs)
18162
+ self.pred_counts *= decay
18116
18163
  if self.error_counts.shape != final_probs.shape:
18117
18164
  self.error_counts = np.zeros_like(final_probs)
18165
+ self.error_counts *= decay
18166
+
18118
18167
 
18119
18168
  except Exception as e:
18120
18169
  print(f'[!] Cant check and calibrate probs based on penalty due to: {e}')