AbstractIntegratedModule 0.5.0__tar.gz → 0.5.1__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.5.1/AbstractIntegratedModule.cp313-win_amd64.pyd +0 -0
  2. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/AbstractIntegratedModule.cpython-310-aarch64-linux-gnu.so +0 -0
  3. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/AbstractIntegratedModule.cpython-312-x86_64-linux-gnu.so +0 -0
  4. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1/AbstractIntegratedModule.egg-info}/PKG-INFO +7 -2
  5. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/AbstractIntegratedModule.py +171 -24
  6. {abstractintegratedmodule-0.5.0/AbstractIntegratedModule.egg-info → abstractintegratedmodule-0.5.1}/PKG-INFO +7 -2
  7. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/README.md +6 -1
  8. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/setup.py +1 -1
  9. abstractintegratedmodule-0.5.0/AbstractIntegratedModule.cp313-win_amd64.pyd +0 -0
  10. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
  11. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
  12. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
  13. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
  14. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/MANIFEST.in +0 -0
  15. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/pyproject.toml +0 -0
  16. {abstractintegratedmodule-0.5.0 → abstractintegratedmodule-0.5.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Framework for Advanced Integrated Non-LLM AI Module library - 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: Beta, 0.5.0.
45
+ - Development Stage: Beta, 0.5.1.
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.
@@ -64,6 +64,11 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
64
64
  - AWE setup Proven Efficient on Hard-uncontrolled dataset such as Activity Recognition from the given Database.
65
65
  - LSTM is Optimized efficiently for scarce data with AWE method.
66
66
  - Robust Advanced prediction capabilities proven effective on ARM64 Using MLP + LSTM Architectures.
67
+ - Changelog:
68
+ - v0.5.1:
69
+ [=] New features:
70
+ - Added new dynamic gate for Transformer Fixed and dynamic switching condition.
71
+ - Added Capabilities for the Model to save the Transformer weights as binaries in local SQlite database.
67
72
  -----
68
73
 
69
74
  <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" />
@@ -40,7 +40,7 @@ import hmac
40
40
  import aiohttp
41
41
  import psutil
42
42
  from sklearn.preprocessing import StandardScaler
43
-
43
+ import io
44
44
 
45
45
  # initial Setup logging for AgentDistributedInference and ModelStorage class logger and security logger
46
46
  logger = logging.getLogger(__name__)
@@ -3942,15 +3942,13 @@ class ModelStorage:
3942
3942
  print('|| Skipping Database Modification...')
3943
3943
  pass
3944
3944
  c = conn.cursor()
3945
- c.execute('''CREATE TABLE IF NOT EXISTS agent_attn_storage
3946
- (id INTEGER PRIMARY KEY AUTOINCREMENT,
3945
+ c.execute('''CREATE TABLE IF NOT EXISTS weight_storage
3946
+ (id INTEGER PRIMARY KEY AUTOINCREMENT,
3947
3947
  memory_name TEXT,
3948
3948
  model_type TEXT,
3949
- model_attn_data TEXT,
3950
- model_target_pred TEXT,
3951
- agent_id TEXT,
3949
+ weights TEXT,
3952
3950
  is_active INTEGER DEFAULT 0,
3953
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)''')
3951
+ created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)''')
3954
3952
 
3955
3953
 
3956
3954
  conn.commit()
@@ -4352,16 +4350,142 @@ class ModelStorage:
4352
4350
  SET is_active = 0
4353
4351
  WHERE memory_name = ? AND id != last_insert_rowid()
4354
4352
  """, (memory_name,))
4353
+
4354
+ c.execute("""
4355
+ DELETE FROM weight_storage
4356
+ WHERE memory_name = ?
4357
+ AND model_type = 'Pipeline'
4358
+ AND is_active = 0
4359
+ """, (memory_name,))
4355
4360
 
4356
4361
  conn.commit()
4357
4362
  conn.close()
4358
4363
 
4359
- print('[||] Weights dictionary saved!')
4364
+ self.save_transformer_weights(memory_name)
4365
+ print('[||] All Weights dictionary saved!')
4360
4366
 
4361
4367
  except Exception as e:
4362
4368
  print(f'[-] Cant save Weights due to: {e}')
4363
4369
  pass
4364
-
4370
+
4371
+
4372
+ def save_transformer_weights(self, memory_name: str):
4373
+ """Save transformer weights as compressed binary blob."""
4374
+ tf = self.pipeline.model2
4375
+
4376
+ try:
4377
+ db_path = self.get_database_path()
4378
+ conn = sqlite3.connect(db_path)
4379
+ except:
4380
+ conn = sqlite3.connect(self.db_path)
4381
+
4382
+ c = conn.cursor()
4383
+
4384
+ buf = io.BytesIO()
4385
+ np.savez_compressed(buf,
4386
+ token_embedding = tf.token_embedding,
4387
+ pos_embedding = tf.pos_embedding,
4388
+ W_q = tf.W_q,
4389
+ W_k = tf.W_k,
4390
+ W_v = tf.W_v,
4391
+ W_q_fixed = tf.W_q_fixed,
4392
+ W_k_fixed = tf.W_k_fixed,
4393
+ W_v_fixed = tf.W_v_fixed,
4394
+ W_o = tf.W_o,
4395
+ ffn1 = tf.ffn1,
4396
+ ffn2 = tf.ffn2,
4397
+ ln1_scale = tf.ln1_scale,
4398
+ ln1_shift = tf.ln1_shift,
4399
+ ln2_scale = tf.ln2_scale,
4400
+ ln2_shift = tf.ln2_shift,
4401
+ output = tf.output,
4402
+ output_bias = tf.output_bias
4403
+ )
4404
+ binary_data = buf.getvalue()
4405
+
4406
+ try:
4407
+ c.execute("""
4408
+ INSERT INTO weight_storage
4409
+ (memory_name, model_type, weights, is_active)
4410
+ VALUES (?, ?, ?, ?)
4411
+ """, (memory_name, 'transformer',
4412
+ sqlite3.Binary(binary_data), 1))
4413
+
4414
+ c.execute("""
4415
+ UPDATE weight_storage SET is_active = 0
4416
+ WHERE memory_name = ?
4417
+ AND model_type = 'transformer'
4418
+ AND id != last_insert_rowid()
4419
+ """, (memory_name,))
4420
+
4421
+ c.execute("""
4422
+ DELETE FROM weight_storage
4423
+ WHERE memory_name = ?
4424
+ AND model_type = 'transformer'
4425
+ AND is_active = 0
4426
+ """, (memory_name,))
4427
+
4428
+ conn.commit()
4429
+ print('[||] Transformer weights saved!')
4430
+
4431
+ except Exception as e:
4432
+ print(f'[!] Transformer weight save failed: {e}')
4433
+ conn.rollback()
4434
+ finally:
4435
+ conn.close()
4436
+
4437
+ def load_transformer_weights(self, memory_name: str) -> bool:
4438
+ try:
4439
+ db_path = self.get_database_path()
4440
+ conn = sqlite3.connect(db_path)
4441
+ except:
4442
+ conn = sqlite3.connect(self.db_path)
4443
+
4444
+ c = conn.cursor()
4445
+
4446
+ try:
4447
+ c.execute("""
4448
+ SELECT weights FROM weight_storage
4449
+ WHERE memory_name = ? AND model_type = 'transformer' AND is_active = 1
4450
+ ORDER BY id DESC LIMIT 1
4451
+ """, (memory_name,))
4452
+ row = c.fetchone()
4453
+ if not row:
4454
+ print(f'[=] No saved transformer weights for {memory_name}')
4455
+ return False
4456
+
4457
+ buf = io.BytesIO(bytes(row[0]))
4458
+ data = np.load(buf, allow_pickle=False)
4459
+
4460
+ t = self.pipeline.model2
4461
+ t.token_embedding = data['token_embedding']
4462
+ t.pos_embedding = data['pos_embedding']
4463
+ t.W_q = data['W_q']
4464
+ t.W_k = data['W_k']
4465
+ t.W_v = data['W_v']
4466
+ t.W_q_fixed = data['W_q_fixed']
4467
+ t.W_k_fixed = data['W_k_fixed']
4468
+ t.W_v_fixed = data['W_v_fixed']
4469
+ t.W_o = data['W_o']
4470
+ t.ffn1 = data['ffn1']
4471
+ t.ffn2 = data['ffn2']
4472
+ t.ln1_scale = data['ln1_scale']
4473
+ t.ln1_shift = data['ln1_shift']
4474
+ t.ln2_scale = data['ln2_scale']
4475
+ t.ln2_shift = data['ln2_shift']
4476
+ t.output = data['output']
4477
+ t.output_bias = data['output_bias']
4478
+
4479
+ print(f'[||] Transformer weights loaded!')
4480
+ return True
4481
+
4482
+ except Exception as e:
4483
+ print(f'[!] Transformer weight load failed: {e}')
4484
+ return False
4485
+ finally:
4486
+ conn.close()
4487
+
4488
+
4365
4489
  def load_weights(self, memory_name):
4366
4490
  """Load weights from database. Returns True if found."""
4367
4491
  result = self.weight_retrieval(memory_name)
@@ -4381,9 +4505,14 @@ class ModelStorage:
4381
4505
  self.pipeline.lstm_engine.n_samples = weights.get('n_samples', self.pipeline.lstm_engine.n_samples)
4382
4506
  self.pipeline.lstm_engine.quantiles = {float(k): tuple(v)
4383
4507
  for k, v in weights.get('quantiles', {}).items()}
4384
-
4385
- print(f'[=] All Weights loaded for {memory_name} '
4386
- f'(saved at {weights.get("saved_at", "unknown")})')
4508
+
4509
+ tf_loaded = self.load_transformer_weights(memory_name)
4510
+
4511
+ print(f'[=] Transformer weights loaded: {tf_loaded}')
4512
+ if tf_loaded:
4513
+ print(f'[=] All Weights loaded for {memory_name} '
4514
+ f'(saved at {weights.get("saved_at", "unknown")})')
4515
+
4387
4516
  except Exception as e:
4388
4517
  print(f'[!] Cant load any Weights due to: {e}')
4389
4518
  traceback.print_exc()
@@ -7305,6 +7434,7 @@ class IntegratedPipeline:
7305
7434
  self.hidden = 32
7306
7435
  self.output_size = 1
7307
7436
  self.dropout_rate = 0.1
7437
+ self.transformer_training_epochs = 100
7308
7438
 
7309
7439
  # Main component setup
7310
7440
  self.standard_scaler = StandardScaler()
@@ -7365,6 +7495,7 @@ class IntegratedPipeline:
7365
7495
  self.temporary_id = []
7366
7496
 
7367
7497
  self.final_conf_score = 0.0
7498
+ self.timeout = 120
7368
7499
  self.confidence_threshold = 0.45
7369
7500
  self.peer_assistance_threshold = 0.0
7370
7501
  self.agent_id = random.randint(0, 10000)
@@ -9501,16 +9632,30 @@ class IntegratedPipeline:
9501
9632
 
9502
9633
  if not unsuitable_training:
9503
9634
  print(f'🚀 Training Transformer with {len(sequence_inputs)} Samples: ')
9504
- conditional_anisotropy = self.anisotropy_measurement(sequence_inputs)
9505
- if conditional_anisotropy >= self.confidence_threshold:
9506
- print('[+] Dynamic Backward')
9635
+
9636
+ x_conditional_anisotropy = self.anisotropy_measurement(sequence_inputs)
9637
+ s_conditional_anisotropy = self.anisotropy_measurement(X_raw)
9638
+
9639
+ AME_x = self.AME_Encoder(X_raw)
9640
+ AME_s = self.AME_Encoder(sequence_inputs)
9641
+ AMR_x = 1.0 / (1.0 + np.exp(-AME_x))
9642
+ AMR_s = 1.0 / (1.0 + np.exp(-AME_s))
9643
+
9644
+ AMR_ratio = AMR_x / (AMR_s + min_signal)
9645
+ anisotropy_ratio = x_conditional_anisotropy / (s_conditional_anisotropy + min_signal)
9646
+
9647
+ dynamic_complex_environment = (anisotropy_ratio < 0.5 and
9648
+ AMR_ratio < 0.5)
9649
+
9650
+ if dynamic_complex_environment:
9651
+ print('[+] Dynamic Backward for Transformer Initiated')
9507
9652
  mode = 'dynamic_backward'
9508
9653
  else:
9509
- print('[-] Fixed Backward')
9654
+ print('[=] Fixed Backward for Transformer initiated')
9510
9655
  mode = 'fixed_backward'
9511
9656
 
9512
9657
  if self.use_transformer:
9513
- self.model2.train(sequence_inputs, y_true, epochs=100, mode=mode, lr=lr, embedded=True, batch_size=batch_size)
9658
+ self.model2.train(sequence_inputs, y_true, epochs=self.transformer_training_epochs, mode=mode, lr=lr, embedded=True, batch_size=batch_size)
9514
9659
 
9515
9660
  X_raw_generation, y, n_classes, input_dim = self.mlp_training_features(rules, datasets)
9516
9661
  X_raw_features = self.tfidf.transform(X_raw_generation).toarray()
@@ -9576,7 +9721,7 @@ class IntegratedPipeline:
9576
9721
 
9577
9722
  if self.lstm_engine:
9578
9723
  self.storage.save_weights(self.memory_name, model_type='Pipeline')
9579
-
9724
+
9580
9725
  print('🎉 All Model Trained!')
9581
9726
  else:
9582
9727
  print(f'[=] No suitable condition for training!')
@@ -11015,7 +11160,9 @@ class PipelineAsyncManager:
11015
11160
 
11016
11161
  except asyncio.TimeoutError:
11017
11162
  raise FutureTimeoutError(f"[-] Advanced prediction timed out after {timeout}s")
11018
-
11163
+ except Exception as e:
11164
+ print(f'[!] Error in asynchronous advanced prediction: {e}')
11165
+
11019
11166
  # ============ ADMIN FUNCTIONS (with authentication) ============
11020
11167
 
11021
11168
  def _initialize_bootstrap_security(self):
@@ -11233,7 +11380,7 @@ class PipelineAsyncManager:
11233
11380
  if not self.pipeline.intents:
11234
11381
  advanced_result = self.predict(
11235
11382
  text,
11236
- timeout=120,
11383
+ timeout=self.pipeline.timeout,
11237
11384
  retries=None,
11238
11385
  api_key=api_key,
11239
11386
  client_ip=client_ip,
@@ -11247,7 +11394,7 @@ class PipelineAsyncManager:
11247
11394
  print('[=] Initiating Batch prediction for multiple texts...')
11248
11395
  results = self.predict_batch(
11249
11396
  texts=texts,
11250
- timeout=120,
11397
+ timeout=self.pipeline.timeout,
11251
11398
  api_key=api_key)
11252
11399
 
11253
11400
  print("========📊 PREDICTION RESULTS============")
@@ -13334,7 +13481,7 @@ class CohesiveAgentDeployment:
13334
13481
  # This runs in a thread pool via asyncio.to_thread
13335
13482
  return self.async_manager.predict(
13336
13483
  texts=texts,
13337
- timeout=120,
13484
+ timeout=self.pipeline.timeout,
13338
13485
  retries=None,
13339
13486
  api_key=api_key,
13340
13487
  client_ip=client_ip,
@@ -13667,7 +13814,7 @@ class CohesiveAgentDeployment:
13667
13814
 
13668
13815
  result = await asyncio.wait_for(
13669
13816
  self.predict_with_peers(texts, api_key, method, disable_sync=disable_sync),
13670
- timeout=120.0
13817
+ timeout=self.pipeline.timeout
13671
13818
  )
13672
13819
 
13673
13820
  # Check if result is valid
@@ -14543,7 +14690,7 @@ def initiate_prediction_usage(pipeline, manager, predict_wrapper, test_titles, l
14543
14690
  texts = {'test_titles': test_titles, 'label_map': label_map, 'rules': rules, "X":X, "y":y,'use_transformer': True}
14544
14691
  regular_predict = wrapper.predict(
14545
14692
  texts=texts,
14546
- timeout=120,
14693
+ timeout=pipeline.timeout,
14547
14694
  retries=None,
14548
14695
  api_key=api_key,
14549
14696
  client_ip=None)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Framework for Advanced Integrated Non-LLM AI Module library - 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: Beta, 0.5.0.
45
+ - Development Stage: Beta, 0.5.1.
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.
@@ -64,6 +64,11 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
64
64
  - AWE setup Proven Efficient on Hard-uncontrolled dataset such as Activity Recognition from the given Database.
65
65
  - LSTM is Optimized efficiently for scarce data with AWE method.
66
66
  - Robust Advanced prediction capabilities proven effective on ARM64 Using MLP + LSTM Architectures.
67
+ - Changelog:
68
+ - v0.5.1:
69
+ [=] New features:
70
+ - Added new dynamic gate for Transformer Fixed and dynamic switching condition.
71
+ - Added Capabilities for the Model to save the Transformer weights as binaries in local SQlite database.
67
72
  -----
68
73
 
69
74
  <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" />
@@ -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.5.0.
13
+ - Development Stage: Beta, 0.5.1.
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.
@@ -32,6 +32,11 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
32
32
  - AWE setup Proven Efficient on Hard-uncontrolled dataset such as Activity Recognition from the given Database.
33
33
  - LSTM is Optimized efficiently for scarce data with AWE method.
34
34
  - Robust Advanced prediction capabilities proven effective on ARM64 Using MLP + LSTM Architectures.
35
+ - Changelog:
36
+ - v0.5.1:
37
+ [=] New features:
38
+ - Added new dynamic gate for Transformer Fixed and dynamic switching condition.
39
+ - Added Capabilities for the Model to save the Transformer weights as binaries in local SQlite database.
35
40
  -----
36
41
 
37
42
  <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" />
@@ -11,7 +11,7 @@ with open("README.md", encoding="utf-8") as f:
11
11
 
12
12
  setup(
13
13
  name="AbstractIntegratedModule",
14
- version="0.5.0",
14
+ version="0.5.1",
15
15
  description="Framework for Advanced Integrated Non-LLM AI Module library - Backend Framework For Non-LLM AI Agent",
16
16
  long_description=long_description,
17
17
  long_description_content_type="text/markdown",