AbstractIntegratedModule 0.9.0__tar.gz → 0.9.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-0.9.0 → abstractintegratedmodule-0.9.2}/AbstractIntegratedModule.egg-info/PKG-INFO +5 -7
  2. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/AbstractIntegratedModule.py +70 -29
  3. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/AbstractOptimizedModules.c +200 -200
  4. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/PKG-INFO +5 -7
  5. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/README.md +4 -6
  6. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/setup.py +1 -1
  7. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
  8. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
  9. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
  10. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
  11. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/AbstractOptimizedModules.pyx +0 -0
  12. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/MANIFEST.in +0 -0
  13. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/abstract_model_storage/Cargo.toml +0 -0
  14. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/abstract_model_storage/pyproject.toml +0 -0
  15. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/abstract_model_storage/src/lib.rs +0 -0
  16. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
  17. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
  18. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
  19. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
  20. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
  21. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
  22. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/pyproject.toml +0 -0
  23. {abstractintegratedmodule-0.9.0 → abstractintegratedmodule-0.9.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 0.9.0
3
+ Version: 0.9.2
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.0 Official Release.
45
+ - Development Stage: 0.9.2 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.
@@ -80,12 +80,10 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
80
80
  - Transformer Optimized using Cython, to reduce Memory overhead and Reduce CPU Usage, With Reduced Training Time.
81
81
  ______________
82
82
  - Changelog:
83
- - v0.9.0:
83
+ - v0.9.2:
84
84
  - [=] New features:
85
- - Ensemble method prediction is now secondary after conditions are met, and no longers acts as the Main prediction flow, Single pass (One Model) prediction now governs the Main prediction for long term stability and determinism in its learning capability.
86
- - Modifed advanced prediction to use single pass prediction as its main prediction method, ensemble prediction will be triggered when conditions are met.
87
- - Modifed advanced batch prediction to use single pass prediction for faster and more reliable prediction method.
88
- - added robustness for input ids handling.
85
+ - Replace ensemble fallback in advanced batch prediction with calibration method between Transformer and MLP models.
86
+ - fixed wrong argument type in hybrid prediction method in advanced prediction method.
89
87
 
90
88
  ____________
91
89
  <img width="1280" height="600" alt="WhatsApp Image 2026-05-27 at 07 16 32" src="https://github.com/user-attachments/assets/4b58a556-45a3-419b-96fd-9c1b76cac574" />
@@ -10152,6 +10152,7 @@ class IntegratedPipeline:
10152
10152
  """
10153
10153
  Process a single chunk - core batch logic with memory gate.
10154
10154
  """
10155
+ use_embedded = False
10155
10156
  chunk_probs = self._batch_model_memory_gate(chunk_ids, chunk_X)
10156
10157
 
10157
10158
  num_classes = self._get_num_classes()
@@ -10177,7 +10178,13 @@ class IntegratedPipeline:
10177
10178
  )
10178
10179
  else:
10179
10180
  fresh_probs = self.model3.forward(fresh_X)
10180
- fresh_trans_probs, _ = self.model2.forward(fresh_ids, embedded=False)
10181
+
10182
+ try:
10183
+ fresh_trans_probs, _ = self.model2.forward(fresh_ids, embedded=False)
10184
+ except:
10185
+ use_embedded = True
10186
+ fresh_trans_probs, _ = self.model2.forward(fresh_ids, embedded=True)
10187
+
10181
10188
  fresh_mlp_confidence = fresh_probs.max(axis=1, keepdims=True)
10182
10189
  fresh_trans_confidence = fresh_trans_probs.max(axis=1, keepdims=True)
10183
10190
 
@@ -10187,10 +10194,9 @@ class IntegratedPipeline:
10187
10194
  fresh_probs = fresh_trans_probs.copy()
10188
10195
 
10189
10196
  if np.std(fresh_probs) < 0.3 or np.mean(fresh_probs) < 0.3:
10190
- fresh_probs, _ = self.ensemble.predict_ensemble(
10197
+ fresh_probs = self.predict_proba(
10191
10198
  fresh_ids, fresh_X,
10192
- np.zeros((len(fresh_ids), num_classes)),
10193
- method='dynamic', embedded=False
10199
+ type='Hybrid', embedded=use_embedded
10194
10200
  )
10195
10201
 
10196
10202
 
@@ -10324,7 +10330,7 @@ class IntegratedPipeline:
10324
10330
  return result[0]
10325
10331
 
10326
10332
 
10327
- def _batch_hybrid_prediction(self, batch_input_ids, batch_X_raw, y_true):
10333
+ def _batch_hybrid_prediction(self, batch_input_ids, batch_X_raw, y_true, embedded=True):
10328
10334
  print('[+] Initiating hybrid prediction batching...')
10329
10335
 
10330
10336
  num_classes = self._get_num_classes()
@@ -10337,6 +10343,10 @@ class IntegratedPipeline:
10337
10343
  fresh_probs = None # FIX 1 — explicit init, no UnboundLocalError
10338
10344
 
10339
10345
  needs_prediction = [i for i, p in enumerate(batch_probs) if p is None]
10346
+ need_ensemble = (
10347
+ len(batch_input_ids) > 100 and
10348
+ len(batch_X_raw) > 100
10349
+ )
10340
10350
 
10341
10351
  if needs_prediction:
10342
10352
  fresh_input_ids = batch_input_ids[needs_prediction]
@@ -10350,10 +10360,33 @@ class IntegratedPipeline:
10350
10360
  else:
10351
10361
  fresh_y_true = np.zeros((len(needs_prediction), num_classes))
10352
10362
 
10353
- fresh_probs, details = self.ensemble.predict_ensemble(
10354
- fresh_input_ids, fresh_X_raw, fresh_y_true,
10355
- method='dynamic', embedded=False
10356
- )
10363
+ if need_ensemble:
10364
+ fresh_probs, _ = self.ensemble.predict_ensemble(
10365
+ fresh_input_ids, fresh_X_raw,
10366
+ np.zeros((len(fresh_input_ids), num_classes)),
10367
+ method='dynamic', embedded=embedded
10368
+ )
10369
+ else:
10370
+ fresh_probs = self.model3.forward(fresh_X_raw)
10371
+ try:
10372
+ fresh_trans_probs, _ = self.model2.forward(fresh_input_ids, embedded=False)
10373
+ except:
10374
+ fresh_trans_probs, _ = self.model2.forward(fresh_input_ids, embedded=embedded)
10375
+
10376
+ fresh_mlp_confidence = fresh_probs.max(axis=1, keepdims=True)
10377
+ fresh_trans_confidence = fresh_trans_probs.max(axis=1, keepdims=True)
10378
+
10379
+ if fresh_mlp_confidence >= fresh_trans_confidence:
10380
+ fresh_probs = fresh_probs.copy()
10381
+ else:
10382
+ fresh_probs = fresh_trans_probs.copy()
10383
+
10384
+ if np.std(fresh_probs) < 0.3 or np.mean(fresh_probs) < 0.3:
10385
+ fresh_probs, _ = self.ensemble.predict_ensemble(
10386
+ fresh_input_ids, fresh_X_raw,
10387
+ np.zeros((len(fresh_input_ids), num_classes)),
10388
+ method='dynamic', embedded=embedded
10389
+ )
10357
10390
 
10358
10391
  # validate fresh_probs shape before assignment
10359
10392
  fresh_probs = np.asarray(fresh_probs)
@@ -10536,9 +10569,15 @@ class IntegratedPipeline:
10536
10569
 
10537
10570
  def hybrid_prediction(self, rules, input_ids, dataset):
10538
10571
  X, y, _, _ = self.feature_generation(rules, dataset)
10572
+ if isinstance(input_ids, list):
10573
+ try:
10574
+ input_ids = np.asarray(input_ids)
10575
+ except Exception as e:
10576
+ input_ids = self._safe_to_2d_float(input_ids)
10577
+
10539
10578
  if len(input_ids.shape) == 2 and input_ids.shape[0] > 1:
10540
10579
  # this is batch mode version
10541
- return self._batch_hybrid_prediction(input_ids, X, y)
10580
+ return self._batch_hybrid_prediction(input_ids, X, y, embedded=embedded)
10542
10581
 
10543
10582
  probs = self.model_memory_gate(input_ids, X)
10544
10583
 
@@ -13826,7 +13865,7 @@ class PipelineAsyncManager:
13826
13865
  except (KeyError, IndexError):
13827
13866
  final_idx = None
13828
13867
 
13829
- print(f'[=+=] Local single advanced prediction: {result}')
13868
+ print(f'[=+=] Local single advanced prediction: {result.get("predicted", "N/A") if isinstance(result, dict) else result} With confidence: {confidence if confidence is not None else "N/A"}')
13830
13869
  print('[=] Initiating batch prediction...')
13831
13870
 
13832
13871
  results = self.predict_batch(
@@ -14599,8 +14638,8 @@ class PipelinePredictionManager:
14599
14638
  # Only recalibrate if models disagreed AND we have valid results
14600
14639
  if results and not results[0].get('models_agree', True):
14601
14640
  print("\n[⚠️] Disagreement detected between MLP and Transformer predictions. Using calibrated probabilities for final decision.")
14602
- calibrated_probs = self.pipeline.hybrid_prediction(input_ids, X, batch_size=batch_size)
14603
-
14641
+ calibrated_probs = self.pipeline.hybrid_prediction(rules, input_ids, dataset)
14642
+
14604
14643
  if calibrated_probs is not None and len(calibrated_probs) > 0:
14605
14644
  final_idx = int(np.argmax(calibrated_probs[:num_classes]))
14606
14645
  if final_idx > len(reverse_map):
@@ -14630,14 +14669,7 @@ class PipelinePredictionManager:
14630
14669
 
14631
14670
  return results
14632
14671
 
14633
- def hybrid_model_prediction(self, datasets, X_raw, batch_size=2):
14634
- self.pipeline.transformer_utilities(datasets, X_raw, batch_size=batch_size)
14635
- input_datasets = self.pipeline.transformer_input_encoding([i[0] for i in datasets])
14636
14672
 
14637
- probs = self.model.predict_proba(input_datasets, X_raw, type='Hybrid')[0]
14638
- pred = self.model.hybrid_prediction(input_datasets, X_raw)
14639
-
14640
- return probs, pred
14641
14673
 
14642
14674
  def robust_prediction(self, pipeline, titles, label_map, X_raw=None, y=None, show_proba=True, top_k=3, batch_size=2):
14643
14675
  self.pipeline.titles = titles
@@ -14861,6 +14893,10 @@ class PipelinePredictionManager:
14861
14893
  anisotropy = None
14862
14894
  final_class_idx = None
14863
14895
  AME = None
14896
+ use_embedded = False
14897
+
14898
+ if titles is None or label_map is None or rules is None:
14899
+ raise ValueError("[!] Titles, label_map, and rules must be provided for all prediction methods!")
14864
14900
 
14865
14901
  print("\n[🚀] Starting Advanced Hybrid Prediction Method")
14866
14902
 
@@ -14881,7 +14917,6 @@ class PipelinePredictionManager:
14881
14917
  input_ids, _ = self.pipeline.input_encoding(dataset)
14882
14918
 
14883
14919
  if use_transformer and hasattr(self.pipeline, 'vocab') and self.pipeline.vocab:
14884
- use_embedded = False
14885
14920
  print("\n[🔄] Running dual predictions (MLP + Transformer)")
14886
14921
 
14887
14922
  input_ids_list = []
@@ -14909,6 +14944,7 @@ class PipelinePredictionManager:
14909
14944
  print("\n[⚡] Running MLP-only predictions")
14910
14945
  print("[⚡] Note: Transformer not available, so Transformer results will be replaced with MLP results.")
14911
14946
  anisotropy = self.pipeline.anisotropy_measurement(X) if X is not None else self.pipeline.confidence_threshold
14947
+
14912
14948
  AME = self.pipeline.model2.AME_Encoder(X) if X is not None else self.pipeline.confidence_threshold
14913
14949
 
14914
14950
  if X is None or len(X) == 0 or isinstance(X, int) or (isinstance(X, np.ndarray) and X.size == 0):
@@ -14975,7 +15011,11 @@ class PipelinePredictionManager:
14975
15011
  print(f'[!] Similarity: {cached['similarity']} is low, Cannot pick label due to low certainty, Initiating advanced prediction...')
14976
15012
  else:
14977
15013
  print('[=] No verified output from cache available that matched samples, starting advanced prediction...')
14978
- target_probs = self.pipeline.predict_proba(input_ids, X, type='Hybrid', embedded=True)
15014
+ try:
15015
+ target_probs = self.pipeline.predict_proba(input_ids, X, type='Hybrid', embedded=True)
15016
+ except:
15017
+ target_probs = self.pipeline.predict_proba(input_ids, X, type='Hybrid', embedded=False)
15018
+
14979
15019
  target_probs = target_probs[:mlp_probs.shape[0], :mlp_probs.shape[1]]
14980
15020
  target_probs = self.pipeline.model3.continuos_predictive_correction(self, target_probs, mlp_pred_indices)
14981
15021
 
@@ -15120,13 +15160,13 @@ class PipelinePredictionManager:
15120
15160
  final_probs = mlp_probs[i]
15121
15161
  final_probs = self.calibration_penalized_check(final_probs, mlp_class_idx)
15122
15162
 
15123
- final_class_idx = mlp_class_idx
15124
- final_confidence = mlp_confidence[0] if isinstance(mlp_confidence, np.ndarray) else mlp_confidence
15163
+ final_class_idx = target_class_idx
15164
+ final_confidence = target_confidence[0] if isinstance(target_confidence, np.ndarray) else target_confidence
15125
15165
  if isinstance(final_confidence, np.ndarray) or isinstance(final_confidence, list):
15126
15166
  final_confidence = np.max(final_confidence)
15127
15167
 
15128
15168
  trans_label = None
15129
- trans_confidence = None
15169
+ trans_confidence = 0.0
15130
15170
  agreement = False
15131
15171
 
15132
15172
  final_label = reverse_map.get(final_class_idx, f"unknown_{final_class_idx}")
@@ -15266,7 +15306,7 @@ class PipelinePredictionManager:
15266
15306
  if final_confidence is not None and confidence < self.pipeline.confidence_threshold:
15267
15307
  print("\n[⚠️] Low confidence detected, but both models don't agree. Using calibrated probabilities for final decision to ensure robustness.")
15268
15308
  final_probs = self.pipeline.hybrid_prediction(rules, input_ids, dataset)
15269
-
15309
+
15270
15310
  final_idx = final_probs[0].argmax()
15271
15311
  original_idx = final_idx
15272
15312
 
@@ -15277,7 +15317,7 @@ class PipelinePredictionManager:
15277
15317
  else:
15278
15318
  print('[🎯] Stable confidence established, But both Models doesnt Agree, Re-evaluating...')
15279
15319
  final_probs = self.pipeline.hybrid_prediction(rules, input_ids, dataset)
15280
-
15320
+
15281
15321
  final_idx = final_probs[0].argmax()
15282
15322
  original_idx = final_idx
15283
15323
  if final_idx > len(reverse_map):
@@ -15294,8 +15334,8 @@ class PipelinePredictionManager:
15294
15334
  if self.pipeline.use_transformer and need_ensemble_method:
15295
15335
  print("\n[⚠️] Uncertain confidence and disagreement detected. Using ensemble method for final decision.")
15296
15336
  input_forward = sequence_ids if sequence_ids is not None else input_ids
15297
- final_probs, details = self.pipeline.ensemble.predict_ensemble(input_forward, X, y, method='dynamic', embedded=True)
15298
-
15337
+ final_probs, details = self.pipeline.ensemble.predict_ensemble(input_forward, X, y, method='dynamic', embedded=use_embedded)
15338
+
15299
15339
  final_idx = final_probs[0].argmax()
15300
15340
  original_idx = final_idx
15301
15341
 
@@ -15311,6 +15351,7 @@ class PipelinePredictionManager:
15311
15351
  confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
15312
15352
  else:
15313
15353
  final_probs = self.calibration_penalized_check(final_probs, target_pred_indices[0])
15354
+
15314
15355
  final_idx = final_probs[0].argmax() if final_probs is not None else target_probs[0].argmax()
15315
15356
 
15316
15357
  original_idx = final_idx