AbstractIntegratedModule 0.7.7__tar.gz → 0.7.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.
Files changed (23) hide show
  1. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/AbstractIntegratedModule.egg-info/PKG-INFO +5 -6
  2. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/AbstractIntegratedModule.py +104 -26
  3. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/AbstractOptimizedModules.c +200 -200
  4. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/PKG-INFO +5 -6
  5. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/README.md +4 -5
  6. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/setup.py +1 -1
  7. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
  8. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
  9. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
  10. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
  11. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/AbstractOptimizedModules.pyx +0 -0
  12. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/MANIFEST.in +0 -0
  13. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/abstract_model_storage/Cargo.toml +0 -0
  14. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/abstract_model_storage/pyproject.toml +0 -0
  15. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/abstract_model_storage/src/lib.rs +0 -0
  16. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
  17. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
  18. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
  19. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
  20. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
  21. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
  22. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/pyproject.toml +0 -0
  23. {abstractintegratedmodule-0.7.7 → abstractintegratedmodule-0.7.8}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 0.7.7
3
+ Version: 0.7.8
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.7.7 Official Release.
45
+ - Development Stage: 0.7.8 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.
@@ -66,11 +66,10 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
66
66
  - Robust Advanced prediction capabilities proven effective on ARM64 Using MLP + LSTM Architectures.
67
67
  - Transformer Modules Optimized using Cython, to reduce Memory overhead and Reduce CPU Usage, With Reduced Training Time.
68
68
  - Changelog:
69
- - v0.7.7:
69
+ - v0.7.8:
70
70
  - [=] New features:
71
- - Fixed shape handling fragility in batching predictions.
72
- - Ensuring proper number of classes during batcthing predictions to prevent shape error.
73
- - Fixed text encoder and encode function that can cause token mismatch.
71
+ - Fixed possible errors from inhomogenous shape during tokenizing arrays into a hash ID.
72
+ - fixed fragility where number of classes is not distributed well to sequence encoding function causing the model to use wrong number of classes.
74
73
 
75
74
 
76
75
  -----
@@ -4664,7 +4664,50 @@ class ModelStorage:
4664
4664
  return data
4665
4665
  except Exception as e:
4666
4666
  print(f'[!] Data cant be parsed due to: {e}')
4667
- pass
4667
+ s = s.replace('\n', '').replace('\r', '').replace('\t', '')
4668
+ s = ' '.join(s.split()).strip()
4669
+
4670
+ if not s:
4671
+ return s
4672
+
4673
+ # parsing as JSON array first
4674
+ if s.startswith('[') and s.endswith(']'):
4675
+ try:
4676
+ parsed = json.loads(s)
4677
+ if isinstance(parsed, list):
4678
+ return np.array(parsed, dtype=np.float32)
4679
+ except (json.JSONDecodeError, ValueError):
4680
+ pass
4681
+
4682
+ # Try parsing with ast.literal_eval
4683
+ try:
4684
+ parsed = ast.literal_eval(s)
4685
+ if isinstance(parsed, (list, tuple)):
4686
+ return np.array(parsed, dtype=np.float32)
4687
+ except (ValueError, SyntaxError, TypeError):
4688
+ pass
4689
+
4690
+ # parsing space-separated numbers
4691
+ if re.fullmatch(r'[\[\]\s\d\.\,\-\+E]+', s):
4692
+ parts = s.replace('[', ' ').replace(']', ' ').split()
4693
+ if parts:
4694
+ try:
4695
+ float_values = [float(x) for x in parts]
4696
+ return np.array(float_values, dtype=np.float32)
4697
+ except ValueError:
4698
+ pass
4699
+
4700
+ # Handle comma-separated values
4701
+ if ',' in s:
4702
+ cleaned = s.replace('[', '').replace(']', '').strip()
4703
+ parts = [p.strip() for p in cleaned.split(',') if p.strip()]
4704
+ try:
4705
+ float_values = [float(x) for x in parts]
4706
+ return np.array(float_values, dtype=np.float32)
4707
+ except ValueError:
4708
+ pass
4709
+
4710
+ return s
4668
4711
  else:
4669
4712
  # Clean the string
4670
4713
  s = s.replace('\n', '').replace('\r', '').replace('\t', '')
@@ -9601,7 +9644,7 @@ class IntegratedPipeline:
9601
9644
  if self.manager:
9602
9645
  model_classes = len(self.manager.label_map)
9603
9646
  if self.vocab:
9604
- raise Warning()
9647
+ raise Warning("[!] Model Classes is still None, using amount of vocab as number of clasess")
9605
9648
  model_classes = len(self.vocab)
9606
9649
  else:
9607
9650
  try:
@@ -10468,7 +10511,12 @@ class IntegratedPipeline:
10468
10511
  return X_adapted
10469
10512
 
10470
10513
  def AME_Encoder(self, x):
10471
- X = np.asarray(x)
10514
+ try:
10515
+ X = np.asarray(x)
10516
+ except:
10517
+ raise Warning('[!] X samples has inhomogenous shape, normalizing to prevent corruption.')
10518
+ flat_data = [item for sublist in x for item in sublist]
10519
+ X = np.asarray(flat_data, dtype=np.int32)
10472
10520
 
10473
10521
  if isinstance(X, (str, np.str_)):
10474
10522
  clean_str = str(X).replace('[', '').replace(']', '')
@@ -10737,7 +10785,7 @@ class IntegratedPipeline:
10737
10785
 
10738
10786
  return unsuitable_training
10739
10787
 
10740
- def sequence_encoding(self, datasets, max_len=32):
10788
+ def sequence_encoding(self, datasets, label_map=None, max_len=32):
10741
10789
  input_sequences = []
10742
10790
 
10743
10791
  if datasets:
@@ -10745,7 +10793,7 @@ class IntegratedPipeline:
10745
10793
  if not self.model2:
10746
10794
  intents = [d[1] for d in datasets]
10747
10795
  intent_to_id = {intent:i for i, intent in enumerate(sorted(set(intents)))}
10748
- num_classes = self._get_num_classes()
10796
+ num_classes = self._get_num_classes(label_map=label_map)
10749
10797
  self.model2 = Transformer(
10750
10798
  vocab_size=len(self.vocab),
10751
10799
  d_model=32,
@@ -10775,12 +10823,12 @@ class IntegratedPipeline:
10775
10823
  std_pool = np.std(sequence_inputs, axis=1)
10776
10824
  return np.concatenate([mean_pool, max_pool, std_pool], axis=-1)
10777
10825
 
10778
- def transformer_utilities(self, rules, datasets, X_raw, y_true=None, batch_size=2, min_signal=1e-3):
10826
+ def transformer_utilities(self, rules, datasets, X_raw, label_map=None, y_true=None, batch_size=2, min_signal=1e-3):
10779
10827
  self.text_encoder(datasets)
10780
10828
  if y_true is None:
10781
10829
  _, y_true = self.input_encoding(datasets)
10782
10830
 
10783
- sequence_inputs = self.sequence_encoding(datasets)
10831
+ sequence_inputs = self.sequence_encoding(datasets, label_map=label_map)
10784
10832
  unsuitable_training = self.training_necessary_condition(sequence_inputs, X_raw)
10785
10833
  lr = self.model2.transformer_lr if self.model2 else self.transformer_lr
10786
10834
 
@@ -11042,12 +11090,36 @@ class AccurateAnswerCache:
11042
11090
  return None
11043
11091
 
11044
11092
  def _hash_ids(self, input_ids):
11045
- """Fast hash of token ids order-sensitive, exact match only."""
11046
- ids = np.asarray(input_ids, dtype=np.int32).ravel()
11093
+ # Recursively flatten any nested list structure
11094
+ def flatten(x):
11095
+ for item in x:
11096
+ if isinstance(item, (list, tuple)):
11097
+ yield from flatten(item)
11098
+ else:
11099
+ yield item
11100
+
11101
+ if isinstance(input_ids, (list, tuple)):
11102
+ flat_ids = list(flatten(input_ids))
11103
+ else:
11104
+ flat_ids = input_ids # already a flat array/tensor
11105
+
11106
+ ids = np.asarray(flat_ids, dtype='<i4')
11047
11107
  return hashlib.md5(ids.tobytes()).hexdigest()
11048
11108
 
11049
11109
  def _make_key(self, x_mlp):
11050
- x = np.asarray(x_mlp, dtype=np.float64).ravel()
11110
+ def flatten(x):
11111
+ for item in x:
11112
+ if isinstance(item, (list, tuple)):
11113
+ yield from flatten(item)
11114
+ else:
11115
+ yield item
11116
+
11117
+ if isinstance(x_mlp, (list, tuple)):
11118
+ flat_x = list(flatten(x_mlp))
11119
+ else:
11120
+ flat_x = x_mlp # already a flat array/tensor
11121
+
11122
+ x = np.asarray(flat_x, dtype='<i4').ravel()
11051
11123
  return hashlib.md5(x.tobytes()).hexdigest()
11052
11124
 
11053
11125
  def _evict_lru(self):
@@ -13672,7 +13744,7 @@ class PipelinePredictionManager:
13672
13744
  input_ids_list.append(np.array(ids))
13673
13745
 
13674
13746
  input_ids = np.array(input_ids_list)
13675
- sequence_ids = self.pipeline.sequence_encoding(dataset)
13747
+ sequence_ids = self.pipeline.sequence_encoding(dataset, label_map=label_map)
13676
13748
  if X is not None:
13677
13749
  anisotropy = self.pipeline.anisotropy_measurement(X)
13678
13750
  else:
@@ -14103,11 +14175,13 @@ class PipelinePredictionManager:
14103
14175
  final_idx = int(final_idx)
14104
14176
 
14105
14177
  chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
14106
- try:
14107
- confidence = float(final_probs[0][final_idx])
14108
- except:
14109
- confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
14110
-
14178
+ if final_probs is not None:
14179
+ try:
14180
+ confidence = float(final_probs[0][final_idx])
14181
+ except:
14182
+ confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
14183
+ else:
14184
+ final_probs = target_probs.copy()
14111
14185
  else:
14112
14186
  print("\n[🎯] Using initial Regular final prediction as final decision.")
14113
14187
  final_idx = final_probs[0].argmax()
@@ -14152,18 +14226,22 @@ class PipelinePredictionManager:
14152
14226
  if isinstance(sec_confidence, (np.ndarray, list)):
14153
14227
  sec_confidence = np.mean(sec_confidence)
14154
14228
 
14155
- print('========== Second Prediction Initiative ==========')
14156
- print(f'[⚡] My Second Prediction: {sec_chosen_label}')
14157
- print(f'[⚡] Confidence: {sec_confidence:.1%}')
14229
+ if 'sec_predicted' in results:
14230
+ print('========== Second Prediction Initiative ==========')
14231
+ print(f'[⚡] My Second Prediction: {sec_chosen_label}')
14232
+ print(f'[⚡] Confidence: {sec_confidence:.1%}')
14158
14233
 
14159
- results[0]['sec_predicted'] = sec_chosen_label
14160
- results[0]['sec_confidence'] = sec_confidence
14161
- results[0]['sec_index'] = sec_final_idx
14234
+ results[0]['sec_predicted'] = sec_chosen_label
14235
+ results[0]['sec_confidence'] = sec_confidence
14236
+ results[0]['sec_index'] = sec_final_idx
14237
+
14238
+ if confidence > results[0]['confidence']:
14239
+ results[0]['predicted'] = chosen_label
14240
+ results[0]['confidence'] = confidence
14241
+ results[0]['index'] = final_idx
14242
+ else:
14243
+ print('[!] No prediction in results cache are found!')
14162
14244
 
14163
- if confidence > results[0]['confidence']:
14164
- results[0]['predicted'] = chosen_label
14165
- results[0]['confidence'] = confidence
14166
- results[0]['index'] = final_idx
14167
14245
  except Exception as e:
14168
14246
  print(f'[!] Error initiating second prediction in Advanced prediction method: {e} ')
14169
14247