AbstractIntegratedModule 0.9.4__tar.gz → 0.9.5__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-0.9.4 → abstractintegratedmodule-0.9.5}/AbstractIntegratedModule.egg-info/PKG-INFO +2 -2
  2. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/AbstractIntegratedModule.py +71 -18
  3. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/AbstractOptimizedModules.c +200 -200
  4. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/PKG-INFO +2 -2
  5. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/README.md +1 -1
  6. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/setup.py +1 -1
  7. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
  8. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
  9. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
  10. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
  11. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/AbstractOptimizedModules.pyx +0 -0
  12. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/MANIFEST.in +0 -0
  13. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/abstract_model_storage/Cargo.toml +0 -0
  14. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/abstract_model_storage/pyproject.toml +0 -0
  15. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/abstract_model_storage/src/lib.rs +0 -0
  16. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
  17. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
  18. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
  19. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
  20. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
  21. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
  22. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/pyproject.toml +0 -0
  23. {abstractintegratedmodule-0.9.4 → abstractintegratedmodule-0.9.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 0.9.4
3
+ Version: 0.9.5
4
4
  Summary: Library for Advanced Integrated Non-LLM AI Models - Optimized Backend Framework For Non-LLM AI Agent
5
5
  Author: Micro-Novelty
6
6
  Author-email: hernikpuspita5@gmail.com
@@ -42,7 +42,7 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
42
42
  #### Note: The README here you are reading is a direct copy from my README Repository, to download the necessary files, you can visit my Repository with the provided link above.
43
43
 
44
44
  ### Library Short Description:
45
- - Development Stage: 0.9.4 Official Release.
45
+ - Development Stage: 0.9.5 Official Release.
46
46
  - Maintainer: Micro-Novelty.
47
47
  - library Source-Code is Open-sourced on github.
48
48
  - Purpose: Specifically Designed for providing Non-LLM AI Agent Framework for edge Devices, Optimized for ARM64 architecture.
@@ -586,11 +586,15 @@ class Activation:
586
586
  @staticmethod
587
587
  def softmax(x):
588
588
  if _OPT_AVAILABLE:
589
- return optimized_softmax_2d(np.asarray(x, dtype=np.float64))
589
+ output = optimized_softmax_2d(np.asarray(x, dtype=np.float64))
590
+ return output
591
+
590
592
  # numerical stability
591
593
  if x.ndim > 1:
592
594
  exp_x = np.exp(x - np.max(x, axis=1, keepdims=True))
593
- return exp_x / np.sum(exp_x, axis=1, keepdims=True)
595
+ normalized = exp_x / np.sum(exp_x, axis=1, keepdims=True)
596
+ return normalized
597
+
594
598
  else:
595
599
  exp_x = np.exp(x - np.max(x, keepdims=True))
596
600
  return exp_x / np.sum(exp_x, keepdims=True)
@@ -598,7 +602,7 @@ class Activation:
598
602
  class Loss:
599
603
  @staticmethod
600
604
  def categorical_crossentropy(y_true, y_pred):
601
- eps = 1e-9
605
+ eps = 1e-5
602
606
  y_true = np.asarray(y_true, dtype=np.float64)
603
607
  y_pred = np.asarray(y_pred, dtype=np.float64)
604
608
 
@@ -637,6 +641,7 @@ class Loss:
637
641
 
638
642
  @staticmethod
639
643
  def softmax_crossentropy_derivative(y_true, y_pred):
644
+ eps = 1e-5
640
645
  y_true = np.asarray(y_true, dtype=np.float64)
641
646
  y_pred = np.asarray(y_pred, dtype=np.float64)
642
647
 
@@ -661,6 +666,7 @@ class Loss:
661
666
  return np.zeros((1, 1))
662
667
 
663
668
  cross_ent = (y_pred - y_true) / y_true.shape[0]
669
+
664
670
  return cross_ent
665
671
 
666
672
 
@@ -1713,7 +1719,7 @@ class Dense:
1713
1719
 
1714
1720
  return x
1715
1721
 
1716
- def multi_modal_linear_transformation(self, x):
1722
+ def multi_modal_linear_transformation(self, x, perf_score):
1717
1723
  x = self._sanitize_string_chars(x)
1718
1724
 
1719
1725
  if len(x.shape) > 1 and x.shape[1] != self.W.shape[0]:
@@ -1755,16 +1761,16 @@ class Dense:
1755
1761
  except:
1756
1762
  subnet_B = self.b[:sub_z.shape[0]]
1757
1763
 
1758
- z = sub_z + subnet_B
1764
+ z = (sub_z + subnet_B) * perf_score
1759
1765
 
1760
1766
  return z
1761
1767
 
1762
1768
 
1763
- def forward(self, x):
1769
+ def forward(self, x, perf_score):
1764
1770
 
1765
1771
  x = self._sanitize_string_chars(x)
1766
1772
  self.x = x
1767
- self.z = self.multi_modal_linear_transformation(x)
1773
+ self.z = self.multi_modal_linear_transformation(x, perf_score)
1768
1774
 
1769
1775
  if self.activation:
1770
1776
  self.a = self.activation(self.z)
@@ -1797,6 +1803,7 @@ class Dense:
1797
1803
  class SoftmaxOutput:
1798
1804
  def forward(self, x):
1799
1805
  self.out = Activation.softmax(x)
1806
+
1800
1807
  return self.out
1801
1808
 
1802
1809
  def backward(self, dL_dZ):
@@ -1831,17 +1838,47 @@ class MLP:
1831
1838
  def add(self, layer):
1832
1839
  self.layers.append(layer)
1833
1840
 
1834
- def focused_forward(self, x):
1841
+ def focused_forward(self, x, AME=None, anisotropy=None):
1842
+ performance_score = self.performance_calculation(x, AME=AME, anisotropy=anisotropy)
1843
+
1835
1844
  for layer in self.feed_layers:
1836
- x = layer.forward(np.asarray(x, dtype=np.float64))
1845
+ x = layer.forward(np.asarray(x, dtype=np.float64), performance_score)
1837
1846
 
1838
1847
  return self.softmax.forward(x)
1839
1848
 
1840
- def forward(self, x):
1849
+ def performance_calculation(self, x, AME=None, anisotropy=None):
1850
+ eps = 1e-5
1851
+ standard_low_error_mean = eps
1852
+ standard_pred_quality = eps
1853
+
1854
+ if AME is None and anisotropy is None:
1855
+ AME = self.AME_Encoder(x)
1856
+ anisotropy = self.anisotropy_measurement(x)
1857
+
1858
+ gate_uncertain = (AME * anisotropy) + eps / 4
1859
+ gate_certainty = (1.0 - AME) + eps / 4
1860
+ if self.error_counts is not None and self.pred_counts is not None:
1861
+ standard_low_error_mean = (1.0 - np.mean(self.error_counts) + eps / 4)
1862
+ standard_pred_quality = np.mean(self.pred_counts) + eps / 4
1863
+
1864
+ performance_score = (gate_uncertain + gate_certainty +
1865
+ standard_low_error_mean + standard_pred_quality)
1866
+
1867
+ if np.isnan(performance_score) or np.isinf(performance_score):
1868
+ performance_score = 0.5
1869
+
1870
+ return performance_score
1871
+
1872
+ def forward(self, x, AME=None, anisotropy=None):
1873
+ eps = 1e-5
1874
+ performance_score = self.performance_calculation(x, AME=AME, anisotropy=anisotropy)
1875
+
1841
1876
  for layer in self.layers:
1842
- x = layer.forward(x)
1843
-
1844
- return self.softmax.forward(x)
1877
+ x = layer.forward(x, performance_score)
1878
+
1879
+ output = self.softmax.forward(x)
1880
+
1881
+ return output
1845
1882
 
1846
1883
  def _sanitize_string_chars(self, x):
1847
1884
  if isinstance(x, (str, np.str_)):
@@ -2038,14 +2075,15 @@ class MLP:
2038
2075
 
2039
2076
  AME = self.AME_Encoder(X)
2040
2077
  anisotropy = self.anisotropy_measurement(X)
2078
+
2041
2079
  focused_fit_condition = len(self.feed_layers) > 0 and anisotropy > 0.25 and AME > 0.25
2042
2080
  print(f'[+] Focused fit condition: {focused_fit_condition} || Anisotropy: {self.anisotropy_measurement(X):.4f} || AME: {self.AME_Encoder(X):.4f}')
2043
2081
 
2044
2082
  for epoch in range(epochs):
2045
2083
  if not focused_fit_condition:
2046
- y_pred = self.forward(X)
2084
+ y_pred = self.forward(X, AME=AME, anisotropy=anisotropy)
2047
2085
  else:
2048
- y_pred = self.focused_forward(X)
2086
+ y_pred = self.focused_forward(X, AME=AME, anisotropy=anisotropy)
2049
2087
 
2050
2088
  y_pred, y_true = self.adapt_predict_shape(y_pred, y)
2051
2089
  loss = Loss.categorical_crossentropy(y_true, y_pred)
@@ -8815,6 +8853,7 @@ class IntegratedPipeline:
8815
8853
  self.transformer_training_epochs = 100
8816
8854
  self.max_size = 500
8817
8855
  self.error_decay = 0.85
8856
+ self.performance_result = 1.0
8818
8857
 
8819
8858
  # Main component setup
8820
8859
  self.standard_scaler = StandardScaler()
@@ -10548,6 +10587,8 @@ class IntegratedPipeline:
10548
10587
  )
10549
10588
  else:
10550
10589
  fresh_probs = self.model3.forward(fresh_X)
10590
+ performance_result = self.model3.performance_calculation(fresh_X)
10591
+ self.performance_result = performance_result
10551
10592
 
10552
10593
  try:
10553
10594
  fresh_trans_probs, _ = self.model2.forward(fresh_ids, embedded=False)
@@ -14328,11 +14369,13 @@ class PipelineAsyncManager:
14328
14369
  def advanced_batch_prediction(self, test_titles, label_map, rules,
14329
14370
  X=None, y=None, api_key=None, client_ip=None):
14330
14371
  try:
14372
+ eps = 1e-5
14331
14373
  attn_weights = None
14332
14374
  final_idx = None
14333
14375
  attn_weight_rate = None
14334
14376
  confidence = None
14335
14377
  chosen_label = None
14378
+ performance_score = self.pipeline.performance_result
14336
14379
 
14337
14380
  reverse_label_map = {v: k for k, v in label_map.items()}
14338
14381
  n_classes = len(label_map)
@@ -14437,6 +14480,8 @@ class PipelineAsyncManager:
14437
14480
  predicted_index, f"class_{predicted_index}"
14438
14481
  )
14439
14482
  pred_conf = float(probs[predicted_index])
14483
+ if pred_conf > 0.8:
14484
+ pred_conf = (pred_conf + performance_score) + eps / 2
14440
14485
 
14441
14486
  top_3_indices = np.argsort(probs)[-3:][::-1]
14442
14487
  top_3 = [
@@ -15690,6 +15735,7 @@ class PipelinePredictionManager:
15690
15735
  X_gen = None
15691
15736
  correct = 0
15692
15737
  sec_correct= 0
15738
+ performance_score = self.pipeline.performance_result
15693
15739
 
15694
15740
  if label_map is None:
15695
15741
  raise ValueError("[!] label_map must be provided for all prediction methods!")
@@ -16304,9 +16350,11 @@ class PipelinePredictionManager:
16304
16350
  try:
16305
16351
  confidence = float(final_probs[0][final_idx])
16306
16352
  except:
16307
- confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
16353
+ confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
16354
+
16308
16355
  else:
16309
16356
  final_probs = target_probs.copy()
16357
+
16310
16358
  else:
16311
16359
  print("\n[🎯] Using initial Regular final prediction as final decision.")
16312
16360
  final_idx = final_probs[0].argmax()
@@ -16317,11 +16365,14 @@ class PipelinePredictionManager:
16317
16365
  final_idx = int(final_idx)
16318
16366
 
16319
16367
  chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
16368
+
16320
16369
  try:
16321
16370
  confidence = float(final_probs[0][final_idx])
16322
16371
  except:
16323
16372
  confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
16324
-
16373
+
16374
+ if confidence > 0.8:
16375
+ confidence = (confidence + performance_score) / 2
16325
16376
 
16326
16377
  if isinstance(chosen_label, str) and chosen_label.startswith("unknown") or float(confidence) < self.pipeline.confidence_threshold:
16327
16378
  if chosen_label.startswith("unknown"):
@@ -16351,7 +16402,9 @@ class PipelinePredictionManager:
16351
16402
  confidence = np.mean(confidence)
16352
16403
  if isinstance(sec_confidence, (np.ndarray, list)):
16353
16404
  sec_confidence = np.mean(sec_confidence)
16354
-
16405
+
16406
+ if sec_confidence > 0.8:
16407
+ sec_confidence = (sec_confidence + performance_score) + eps / 2
16355
16408
 
16356
16409
  if 'sec_predicted' in results and results['sec_predicted'] is None and sec_chosen_label:
16357
16410
  print('========== Second Prediction Initiative ==========')