AbstractIntegratedModule 0.4.4__tar.gz → 0.4.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 (16) hide show
  1. abstractintegratedmodule-0.4.5/AbstractIntegratedModule.cp313-win_amd64.pyd +0 -0
  2. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/AbstractIntegratedModule.cpython-310-aarch64-linux-gnu.so +0 -0
  3. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/AbstractIntegratedModule.cpython-312-x86_64-linux-gnu.so +0 -0
  4. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5/AbstractIntegratedModule.egg-info}/PKG-INFO +6 -2
  5. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/AbstractIntegratedModule.py +54 -28
  6. {abstractintegratedmodule-0.4.4/AbstractIntegratedModule.egg-info → abstractintegratedmodule-0.4.5}/PKG-INFO +6 -2
  7. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/README.md +5 -1
  8. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/setup.py +1 -1
  9. abstractintegratedmodule-0.4.4/AbstractIntegratedModule.cp313-win_amd64.pyd +0 -0
  10. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
  11. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
  12. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
  13. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
  14. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/MANIFEST.in +0 -0
  15. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/pyproject.toml +0 -0
  16. {abstractintegratedmodule-0.4.4 → abstractintegratedmodule-0.4.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 0.4.4
3
+ Version: 0.4.5
4
4
  Summary: Framework for Advanced Integrated Non-LLM AI Module library - Backend Framework for Non-LLM AI Agent Framework
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: Beta, 0.4.4.
45
+ - Development Stage: Beta, 0.4.5.
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.
@@ -582,9 +582,13 @@ B. [=] Advanced Prediction without Transformer, Only Specialized MLP + LSTM usin
582
582
 
583
583
  # small training with simple titles first
584
584
  main_model.train(titles, y)
585
+
586
+ # main_model.froze_learning = True
587
+ # prevent the model from training and make weights unchanged for static prediction.
585
588
 
586
589
  results, chosen_label, confidence = main_prediction.advanced_prediction_method(
587
590
  test_titles, label_map, example_rules,
591
+ X=None, y=None # you could create your own X and y samples and put it here (Optional)
588
592
  show_proba=False, top_k=3,
589
593
  use_transformer=True,
590
594
  return_attention=False,
@@ -7290,7 +7290,8 @@ class IntegratedPipeline:
7290
7290
  self.agreement = False
7291
7291
  self.external_peer_enabled = False
7292
7292
  self.autonomous = False
7293
- self.show_explainability_details = True
7293
+ self.show_explainability_details = True
7294
+ self.froze_learning = False
7294
7295
 
7295
7296
  self.temperature = 1.0
7296
7297
  self.transformer_lr = 0.1
@@ -9334,7 +9335,7 @@ class IntegratedPipeline:
9334
9335
  # (not too high that it shows unstability, not too low that it shows rigidity), high anisotropy correlates to a much complex non linearity that the model will have a hard time adjusting
9335
9336
  # higher LMR than AAC means the model is likely to be in a regime where training could lead to overfitting or divergence due to insufficient modelling capacity relative to the complexity of the data, especially if the confidence score is also low, indicating that the model is not currently confident in its predictions and may not benefit from further training on this data.
9336
9337
  unsuitable_tolerance = probs is not None or LMR > AAC
9337
- unsuitable_conditions = anisotropy > 0.85 or final_conf > confidence_threshold
9338
+ unsuitable_conditions = anisotropy > 0.85 or final_conf > confidence_threshold or self.froze_learning
9338
9339
  unsuitable_peer_request = probs is not None and self.peer_assistance_threshold > self.confidence_threshold
9339
9340
 
9340
9341
  if unsuitable_tolerance or unsuitable_conditions or unsuitable_peer_request:
@@ -9377,9 +9378,11 @@ class IntegratedPipeline:
9377
9378
  std_pool = np.std(sequence_inputs, axis=1)
9378
9379
  return np.concatenate([mean_pool, max_pool, std_pool], axis=-1)
9379
9380
 
9380
- def transformer_utilities(self, rules, datasets, X_raw, batch_size=2, min_signal=1e-3):
9381
+ def transformer_utilities(self, rules, datasets, X_raw, y_true=None, batch_size=2, min_signal=1e-3):
9381
9382
  self.text_encoder(datasets)
9382
- _, y_true = self.input_encoding(datasets)
9383
+ if y_true is None:
9384
+ _, y_true = self.input_encoding(datasets)
9385
+
9383
9386
  sequence_inputs = self.sequence_encoding(datasets)
9384
9387
  unsuitable_training = self.training_necessary_condition(sequence_inputs, X_raw)
9385
9388
  lr = self.model2.transformer_lr if self.model2 else self.transformer_lr
@@ -11473,7 +11476,7 @@ class PipelinePredictionManager:
11473
11476
  return titles, y, label_map
11474
11477
 
11475
11478
 
11476
- def regular_prediction_method(self, titles, label_map, rules, show_proba=False, top_k=3, batch_size=2,use_transformer=True):
11479
+ def regular_prediction_method(self, titles, label_map, rules, X=None, y=None, show_proba=False, top_k=3, batch_size=2,use_transformer=True):
11477
11480
  try:
11478
11481
  print(f"\n[🚀] Regular Prediction for labels with {len(titles)} titles...")
11479
11482
  self.pipeline.titles = titles
@@ -11482,8 +11485,13 @@ class PipelinePredictionManager:
11482
11485
  reverse_map = {v: k for k, v in label_map.items()}
11483
11486
  num_classes = len(label_map)
11484
11487
 
11485
- dataset, X = self.pipeline.data_preparation(titles, label_map)
11486
- _, y, _, _ = self.pipeline.mlp_training_features(rules, dataset)
11488
+ if X and y is None or X is None or y is None:
11489
+ print('[🔄] Creating automatic X samples because X is not provided manually.')
11490
+ dataset, X = self.pipeline.data_preparation(titles, label_map)
11491
+ _, y, _, _ = self.pipeline.mlp_training_features(rules, dataset)
11492
+ else:
11493
+ dataset, _ = self.pipeline.data_preparation(titles, label_map)
11494
+
11487
11495
  self.pipeline.transformer_utilities(rules, dataset, X, batch_size=batch_size)
11488
11496
  input_ids, _ = self.pipeline.input_encoding(dataset)
11489
11497
 
@@ -11751,7 +11759,11 @@ class PipelinePredictionManager:
11751
11759
  print(f"\n[⚠️] Final prediction is {chosen_label} with uncertain confidence: {confidence:.1%}. Consider collecting more data or adjusting the model.")
11752
11760
  else:
11753
11761
  print(f"\n[🎯] Final chosen label for input: {chosen_label} || Confidence: {confidence:.1%}")
11754
-
11762
+
11763
+ if results and results[0]['confidence'] > self.pipeline.confidence_threshold:
11764
+ results[0]['predicted'] = chosen_label
11765
+ results[0]['confidence'] = confidence
11766
+
11755
11767
  except Exception as e:
11756
11768
  print(f"[=] Error during prediction: {e}")
11757
11769
  results = []
@@ -11767,16 +11779,21 @@ class PipelinePredictionManager:
11767
11779
 
11768
11780
  return probs, pred
11769
11781
 
11770
- def robust_prediction(self, pipeline, titles, label_map, show_proba=True, top_k=3, batch_size=2):
11782
+ def robust_prediction(self, pipeline, titles, label_map, X_raw=None, y=None, show_proba=True, top_k=3, batch_size=2):
11771
11783
  self.pipeline.titles = titles
11772
11784
  self.pipeline.labels = label_map
11773
11785
 
11774
11786
  try:
11775
11787
 
11776
- datasets, X_raw = self.pipeline.data_preparation(titles, label_map)
11788
+ if X_raw and y is None or X_raw is None or y is None:
11789
+ print('[🔄] Creating automatic X samples because X is not provided manually.')
11790
+ datasets, X_raw = self.pipeline.data_preparation(titles, label_map)
11791
+ else:
11792
+ datasets, _ = self.pipeline.data_preparation(titles, label_map)
11793
+
11777
11794
  reverse_map = {v: k for k, v in label_map.items()}
11778
11795
 
11779
- self.pipeline.transformer_utilities(datasets, X_raw, batch_size=batch_size)
11796
+ self.pipeline.transformer_utilities(datasets, X_raw, y_true=y, batch_size=batch_size)
11780
11797
  input_datasets = self.pipeline.transformer_input_encoding(datasets)
11781
11798
  pred_probs = self.pipeline.predict_proba(input_datasets, X_raw, type='Hybrid')[0]
11782
11799
  pred_result = self.pipeline.hybrid_prediction(input_datasets, X_raw, batch_size=batch_size)
@@ -11894,7 +11911,6 @@ class PipelinePredictionManager:
11894
11911
 
11895
11912
  label = reverse_map.get(class_idx, f"unknown_{class_idx}")
11896
11913
 
11897
-
11898
11914
  result = {
11899
11915
  'title': title,
11900
11916
  'predicted': label,
@@ -11972,11 +11988,10 @@ class PipelinePredictionManager:
11972
11988
 
11973
11989
 
11974
11990
  def advanced_prediction_method(self, titles, label_map, rules,
11991
+ X=None, y=None,
11975
11992
  show_proba=False, top_k=3,
11976
- use_transformer=True,
11977
- return_attention=False,
11978
- save_results=True,
11979
- batch_size=2):
11993
+ use_transformer=True, return_attention=False,
11994
+ save_results=True, batch_size=2):
11980
11995
  try:
11981
11996
  eps = 1e-5
11982
11997
  trans_probs = None
@@ -11990,10 +12005,15 @@ class PipelinePredictionManager:
11990
12005
 
11991
12006
  self.pipeline.titles = titles
11992
12007
  self.pipeline.labels = label_map
11993
-
11994
- dataset, X = self.pipeline.data_preparation(titles, label_map)
11995
- _, y, _, _ = self.pipeline.mlp_training_features(rules, dataset)
11996
- self.pipeline.transformer_utilities(rules, dataset, X, batch_size=batch_size)
12008
+
12009
+ if X and y is None or X is None or y is None:
12010
+ print('[🔄] Creating automatic X samples because X is not provided manually.')
12011
+ dataset, X = self.pipeline.data_preparation(titles, label_map)
12012
+ _, y, _, _ = self.pipeline.mlp_training_features(rules, dataset)
12013
+ else:
12014
+ dataset, _ = self.pipeline.data_preparation(titles, label_map)
12015
+
12016
+ self.pipeline.transformer_utilities(rules, dataset, X, y_true=y, batch_size=batch_size)
11997
12017
  input_ids, _ = self.pipeline.input_encoding(dataset)
11998
12018
 
11999
12019
  if use_transformer and hasattr(self.pipeline, 'vocab') and self.pipeline.vocab:
@@ -12011,17 +12031,17 @@ class PipelinePredictionManager:
12011
12031
 
12012
12032
  # Get transformer predictions with attention
12013
12033
  if self.pipeline.anisotropy_measurement(input_ids) < self.pipeline.confidence_threshold:
12014
- print("⚡ Low anisotropy detected on input, relying on sequence encoding for input...")
12034
+ print("[] Low anisotropy detected on input, relying on sequence encoding for input...")
12015
12035
  sequence_ids = self.pipeline.sequence_encoding(dataset)
12016
12036
  use_embedded = True
12017
12037
  trans_probs, attn_weights = self.pipeline.model2.forward(sequence_ids, embedded=use_embedded)
12018
12038
  else:
12019
- print("⚡ Anisotropy above threshold, using standard input encoding for transformer...")
12039
+ print("[] Anisotropy above threshold, using standard input encoding for transformer...")
12020
12040
  trans_probs, attn_weights = self.pipeline.model2.forward(input_ids, embedded=use_embedded)
12021
12041
 
12022
12042
  else:
12023
- print("\n⚡ Running MLP-only predictions")
12024
- print("⚡ Note: Transformer not available, so Transformer results will be replaced with MLP results.")
12043
+ print("\n[] Running MLP-only predictions")
12044
+ print("[] Note: Transformer not available, so Transformer results will be replaced with MLP results.")
12025
12045
 
12026
12046
  if X is None or len(X) == 0 or isinstance(X, int) or (isinstance(X, np.ndarray) and X.size == 0):
12027
12047
  # Get MLP predictions
@@ -12382,7 +12402,7 @@ class PipelinePredictionManager:
12382
12402
 
12383
12403
  if use_robust_prediction:
12384
12404
  print("\n[⚡] Condition is poorly unviable to handle agreement. Using robust prediction method for better reliability.")
12385
- predicted_label, confidence = self.robust_prediction(self.pipeline, titles, label_map, show_proba=show_proba, top_k=top_k)
12405
+ predicted_label, confidence = self.robust_prediction(self.pipeline, titles, label_map, X_raw=X, y=y, show_proba=show_proba, top_k=top_k)
12386
12406
  if predicted_label is not None:
12387
12407
  print(f"\n[🎯] Robust prediction result: {predicted_label} with confidence {confidence:.1%}")
12388
12408
  return _, predicted_label, confidence
@@ -12462,9 +12482,15 @@ class PipelinePredictionManager:
12462
12482
  time.sleep(5)
12463
12483
 
12464
12484
  except Exception as e:
12465
- print(f"[= ! =] Error in advanced prediction method: {e}")
12466
- results, chosen_label, confidence = None, None, 0.0
12467
- time.sleep(5)
12485
+ print(f"[!] Error in advanced prediction method: {e}, Initiating regular prediction method...")
12486
+ try:
12487
+ results = self.regular_prediction_method(titles, label_map, rules, X=X, y=y, show_proba=False, top_k=3, batch_size=2,use_transformer=True)
12488
+ chosen_label = results[0]['predicted']
12489
+ confidence = results[0]['confidence']
12490
+ except Exception as error:
12491
+ print(f'[= ! =] Error in all prediction method: {error}')
12492
+ results, chosen_label, confidence = None, None, 0.0
12493
+ time.sleep(5)
12468
12494
 
12469
12495
  print('[=] Displaying Results....')
12470
12496
  correct, sec_correct = self.display_hybrid_results(results, top_k, verbose=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 0.4.4
3
+ Version: 0.4.5
4
4
  Summary: Framework for Advanced Integrated Non-LLM AI Module library - Backend Framework for Non-LLM AI Agent Framework
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: Beta, 0.4.4.
45
+ - Development Stage: Beta, 0.4.5.
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.
@@ -582,9 +582,13 @@ B. [=] Advanced Prediction without Transformer, Only Specialized MLP + LSTM usin
582
582
 
583
583
  # small training with simple titles first
584
584
  main_model.train(titles, y)
585
+
586
+ # main_model.froze_learning = True
587
+ # prevent the model from training and make weights unchanged for static prediction.
585
588
 
586
589
  results, chosen_label, confidence = main_prediction.advanced_prediction_method(
587
590
  test_titles, label_map, example_rules,
591
+ X=None, y=None # you could create your own X and y samples and put it here (Optional)
588
592
  show_proba=False, top_k=3,
589
593
  use_transformer=True,
590
594
  return_attention=False,
@@ -10,7 +10,7 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
10
10
  #### 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.
11
11
 
12
12
  ### Library Short Description:
13
- - Development Stage: Beta, 0.4.4.
13
+ - Development Stage: Beta, 0.4.5.
14
14
  - Maintainer: Micro-Novelty.
15
15
  - library Source-Code is Open-sourced on github.
16
16
  - Purpose: Specifically Designed for providing Non-LLM AI Agent Framework for edge Devices, Optimized for ARM64 architecture.
@@ -550,9 +550,13 @@ B. [=] Advanced Prediction without Transformer, Only Specialized MLP + LSTM usin
550
550
 
551
551
  # small training with simple titles first
552
552
  main_model.train(titles, y)
553
+
554
+ # main_model.froze_learning = True
555
+ # prevent the model from training and make weights unchanged for static prediction.
553
556
 
554
557
  results, chosen_label, confidence = main_prediction.advanced_prediction_method(
555
558
  test_titles, label_map, example_rules,
559
+ X=None, y=None # you could create your own X and y samples and put it here (Optional)
556
560
  show_proba=False, top_k=3,
557
561
  use_transformer=True,
558
562
  return_attention=False,
@@ -8,7 +8,7 @@ class BinaryDistribution(Distribution):
8
8
 
9
9
  setup(
10
10
  name="AbstractIntegratedModule",
11
- version="0.4.4",
11
+ version="0.4.5",
12
12
  description="Framework for Advanced Integrated Non-LLM AI Module library - Backend Framework for Non-LLM AI Agent Framework",
13
13
  long_description=open("README.md", encoding="utf-8").read(),
14
14
  long_description_content_type="text/markdown",