AbstractIntegratedModule 0.4.1__tar.gz → 0.4.3__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.
- abstractintegratedmodule-0.4.3/AbstractIntegratedModule.cp313-win_amd64.pyd +0 -0
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/AbstractIntegratedModule.cpython-310-aarch64-linux-gnu.so +0 -0
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/AbstractIntegratedModule.cpython-312-x86_64-linux-gnu.so +0 -0
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3/AbstractIntegratedModule.egg-info}/PKG-INFO +4 -3
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/AbstractIntegratedModule.py +297 -42
- {abstractintegratedmodule-0.4.1/AbstractIntegratedModule.egg-info → abstractintegratedmodule-0.4.3}/PKG-INFO +4 -3
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/README.md +3 -2
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/setup.py +1 -1
- abstractintegratedmodule-0.4.1/AbstractIntegratedModule.cp313-win_amd64.pyd +0 -0
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/MANIFEST.in +0 -0
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/pyproject.toml +0 -0
- {abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/setup.cfg +0 -0
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AbstractIntegratedModule
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
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.
|
|
45
|
+
- Development Stage: Beta, 0.4.3.
|
|
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.
|
|
@@ -63,10 +63,11 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
|
|
|
63
63
|
- P2P Works efficiently in ARM64 Docker + QEMU, No conflicting socket and all prediction works efficiently.
|
|
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
|
+
- Robust Advanced prediction capabilities proven effective on ARM64 Using MLP + LSTM Architectures.
|
|
66
67
|
-----
|
|
67
68
|
|
|
68
69
|
<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" />
|
|
69
|
-
|
|
70
|
+
|
|
70
71
|
|
|
71
72
|
## [+] MANN Intro
|
|
72
73
|
[=] Memory augmented Neural network (MANN) is a neural network architecture coupled with an external, dynamic memory module, allowing it to store, retrieve, and update information similarly to a computer's RAM. Unlike traditional networks that store knowledge only in weight parameters, MANNs excel at fast learning, long-term dependency handling, and episodic recall, In IntegratedPipeline, Its memory is stored in a custom database inside your local machine, then later used for memory retrieval, transfered to the AI Dictionary where it can finnaly recall its memory when input condition matched with memory.
|
{abstractintegratedmodule-0.4.1 → abstractintegratedmodule-0.4.3}/AbstractIntegratedModule.py
RENAMED
|
@@ -2151,7 +2151,7 @@ class LSTMEngine:
|
|
|
2151
2151
|
class WeightedEnsemblePredictor:
|
|
2152
2152
|
def __init__(self, pipeline, distribution, memory_name):
|
|
2153
2153
|
self.pipeline = pipeline
|
|
2154
|
-
self.storage = ModelStorage(memory_name, db_path='activity_log.db')
|
|
2154
|
+
self.storage = ModelStorage(pipeline, memory_name, db_path='activity_log.db')
|
|
2155
2155
|
self.inference = distribution
|
|
2156
2156
|
self.query_node = QueryNode(pipeline, memory_name, self.storage)
|
|
2157
2157
|
|
|
@@ -3593,13 +3593,15 @@ class ExplainabilityModule:
|
|
|
3593
3593
|
|
|
3594
3594
|
# Model storage module that handles saving and loading of trained models, their versions, and associated metadata to a database for persistence and future retrieval.
|
|
3595
3595
|
class ModelStorage:
|
|
3596
|
-
def __init__(self, memory_name, db_path='activity_log.db'):
|
|
3596
|
+
def __init__(self, pipeline, memory_name, db_path='activity_log.db'):
|
|
3597
|
+
self.pipeline = pipeline
|
|
3597
3598
|
self.db_path = db_path
|
|
3598
3599
|
|
|
3599
3600
|
self.setup_storage_table()
|
|
3600
3601
|
self.setup_explainable_table()
|
|
3601
3602
|
self.setup_agent_table()
|
|
3602
3603
|
self.setup_node_table()
|
|
3604
|
+
self.setup_weight_table()
|
|
3603
3605
|
|
|
3604
3606
|
self.memory_name = memory_name
|
|
3605
3607
|
|
|
@@ -3868,6 +3870,51 @@ class ModelStorage:
|
|
|
3868
3870
|
conn.close()
|
|
3869
3871
|
|
|
3870
3872
|
|
|
3873
|
+
def setup_weight_table(self):
|
|
3874
|
+
try:
|
|
3875
|
+
try:
|
|
3876
|
+
db_path = self.get_database_path()
|
|
3877
|
+
conn = sqlite3.connect(db_path)
|
|
3878
|
+
except:
|
|
3879
|
+
conn = sqlite3.connect(self.db_path)
|
|
3880
|
+
|
|
3881
|
+
c = conn.cursor()
|
|
3882
|
+
|
|
3883
|
+
c.execute('''CREATE TABLE IF NOT EXISTS weight_storage
|
|
3884
|
+
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
3885
|
+
memory_name TEXT,
|
|
3886
|
+
model_type TEXT,
|
|
3887
|
+
weights TEXT,
|
|
3888
|
+
is_active INTEGER DEFAULT 0,
|
|
3889
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)''')
|
|
3890
|
+
|
|
3891
|
+
conn.commit()
|
|
3892
|
+
conn.close()
|
|
3893
|
+
print('|| Update Agent Saved to database! ')
|
|
3894
|
+
|
|
3895
|
+
except Exception as e:
|
|
3896
|
+
print(f'|| Cant Update Database: {e}')
|
|
3897
|
+
filepath = input('|| Insert Database filepath: ')
|
|
3898
|
+
if filepath:
|
|
3899
|
+
conn = sqlite3.connect(filepath)
|
|
3900
|
+
else:
|
|
3901
|
+
print('|| Skipping Database Modification...')
|
|
3902
|
+
pass
|
|
3903
|
+
c = conn.cursor()
|
|
3904
|
+
c.execute('''CREATE TABLE IF NOT EXISTS agent_attn_storage
|
|
3905
|
+
(id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
3906
|
+
memory_name TEXT,
|
|
3907
|
+
model_type TEXT,
|
|
3908
|
+
model_attn_data TEXT,
|
|
3909
|
+
model_target_pred TEXT,
|
|
3910
|
+
agent_id TEXT,
|
|
3911
|
+
is_active INTEGER DEFAULT 0,
|
|
3912
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)''')
|
|
3913
|
+
|
|
3914
|
+
|
|
3915
|
+
conn.commit()
|
|
3916
|
+
conn.close()
|
|
3917
|
+
|
|
3871
3918
|
def save_model_dict(self, memory_name, model_dict, type=None, model_type='mlp'):
|
|
3872
3919
|
try:
|
|
3873
3920
|
db_path = self.get_database_path()
|
|
@@ -4059,24 +4106,24 @@ class ModelStorage:
|
|
|
4059
4106
|
|
|
4060
4107
|
# Verify result is a dictionary before calling .items()
|
|
4061
4108
|
if verbose and result is not None:
|
|
4062
|
-
print(f"Retrieved memory: {name}")
|
|
4109
|
+
print(f"[=] Retrieved memory: {name}")
|
|
4063
4110
|
|
|
4064
4111
|
# ✅ SAFE: Check if result is a dict before iterating
|
|
4065
4112
|
if isinstance(result, dict):
|
|
4066
4113
|
for key, value in result.items():
|
|
4067
4114
|
self._print_memory_value(key, value)
|
|
4068
4115
|
else:
|
|
4069
|
-
print(f"
|
|
4070
|
-
print(f"
|
|
4116
|
+
print(f"[!] Result is not a dict: {type(result)}")
|
|
4117
|
+
print(f"[!] Result length: {len(result) if hasattr(result, '__len__') else 'N/A'}")
|
|
4071
4118
|
|
|
4072
4119
|
# Handle TwoPass verbose output
|
|
4073
4120
|
if verbose and data2 is not None and result2 is not None:
|
|
4074
|
-
print(f"Retrieved secondary memory: {name}_secondary")
|
|
4121
|
+
print(f"[=] Retrieved secondary memory: {name}_secondary")
|
|
4075
4122
|
if isinstance(result2, dict):
|
|
4076
4123
|
for key, value in result2.items():
|
|
4077
4124
|
self._print_memory_value(key, value)
|
|
4078
4125
|
else:
|
|
4079
|
-
print(f"
|
|
4126
|
+
print(f"[!] Secondary result is not a dict: {type(result2)}")
|
|
4080
4127
|
|
|
4081
4128
|
# ✅ ALWAYS return consistent types
|
|
4082
4129
|
if data2 is not None:
|
|
@@ -4106,6 +4153,7 @@ class ModelStorage:
|
|
|
4106
4153
|
else:
|
|
4107
4154
|
print(f" {key}: {type(value)}")
|
|
4108
4155
|
|
|
4156
|
+
|
|
4109
4157
|
def memory_retrieval(self, memory_name=None, type_func=None, verbose=False):
|
|
4110
4158
|
name = memory_name
|
|
4111
4159
|
|
|
@@ -4130,6 +4178,44 @@ class ModelStorage:
|
|
|
4130
4178
|
|
|
4131
4179
|
return result
|
|
4132
4180
|
|
|
4181
|
+
|
|
4182
|
+
def _load_weights(self, memory_name, type=None):
|
|
4183
|
+
try:
|
|
4184
|
+
try:
|
|
4185
|
+
db_path = self.get_database_path()
|
|
4186
|
+
conn = sqlite3.connect(db_path)
|
|
4187
|
+
except:
|
|
4188
|
+
conn = sqlite3.connect(self.db_path)
|
|
4189
|
+
|
|
4190
|
+
c = conn.cursor()
|
|
4191
|
+
|
|
4192
|
+
c.execute("""
|
|
4193
|
+
SELECT weights FROM weight_storage
|
|
4194
|
+
WHERE memory_name = ? AND is_active = 1
|
|
4195
|
+
""", (memory_name,))
|
|
4196
|
+
|
|
4197
|
+
result = c.fetchone()
|
|
4198
|
+
conn.close()
|
|
4199
|
+
|
|
4200
|
+
if result:
|
|
4201
|
+
return json.loads(result[0])
|
|
4202
|
+
except Exception as e:
|
|
4203
|
+
print(f'[!] Error handling Weight dict: {e}')
|
|
4204
|
+
return None
|
|
4205
|
+
|
|
4206
|
+
|
|
4207
|
+
def weight_retrieval(self, memory_name=None, type=None, verbose=False):
|
|
4208
|
+
name = memory_name
|
|
4209
|
+
|
|
4210
|
+
data = self._load_weights(memory_name, type=type)
|
|
4211
|
+
if data is None:
|
|
4212
|
+
print(f"[-] No Saved Weight found: {name}")
|
|
4213
|
+
return None
|
|
4214
|
+
|
|
4215
|
+
result = self._convertables_utility(name, data, None, type_func='firstpass', verbose=verbose)
|
|
4216
|
+
|
|
4217
|
+
return result
|
|
4218
|
+
|
|
4133
4219
|
def _load_node_dict(self, memory_name):
|
|
4134
4220
|
try:
|
|
4135
4221
|
try:
|
|
@@ -4185,8 +4271,81 @@ class ModelStorage:
|
|
|
4185
4271
|
|
|
4186
4272
|
except Exception as e:
|
|
4187
4273
|
print(f'[-] Cant save Node memory due to: {e}')
|
|
4188
|
-
pass
|
|
4274
|
+
pass
|
|
4275
|
+
|
|
4276
|
+
|
|
4277
|
+
def save_weights(self, memory_name, model_type=None):
|
|
4278
|
+
"""Save weights to database."""
|
|
4279
|
+
try:
|
|
4280
|
+
db_path = self.get_database_path()
|
|
4281
|
+
conn = sqlite3.connect(db_path)
|
|
4282
|
+
except:
|
|
4283
|
+
conn = sqlite3.connect(self.db_path)
|
|
4284
|
+
|
|
4285
|
+
c = conn.cursor()
|
|
4286
|
+
|
|
4287
|
+
weights = {
|
|
4288
|
+
'lstm_W' : self.pipeline.network_model.cell.W.tolist(),
|
|
4289
|
+
'lstm_b' : self.pipeline.network_model.cell.b.tolist(),
|
|
4290
|
+
'Wy' : self.pipeline.network_model.Wy.tolist() if self.pipeline.network_model.Wy is not None else None,
|
|
4291
|
+
'by' : self.pipeline.network_model.by.tolist(),
|
|
4292
|
+
'residual_mean': self.pipeline.lstm_engine.residual_mean,
|
|
4293
|
+
'residual_std' : self.pipeline.lstm_engine.residual_std,
|
|
4294
|
+
'quantiles' : {str(k): list(v)
|
|
4295
|
+
for k, v in self.pipeline.lstm_engine.quantiles.items()}
|
|
4296
|
+
if self.pipeline.lstm_engine.quantiles else {},
|
|
4297
|
+
'n_samples' : self.pipeline.lstm_engine.n_samples,
|
|
4298
|
+
'saved_at' : datetime.now().isoformat(),
|
|
4299
|
+
}
|
|
4300
|
+
|
|
4301
|
+
weight_json = json.dumps(weights, default=str)
|
|
4302
|
+
try:
|
|
4303
|
+
c.execute("""
|
|
4304
|
+
INSERT INTO weight_storage
|
|
4305
|
+
(memory_name, model_type, weights, is_active)
|
|
4306
|
+
VALUES (?, ?, ?, ?)
|
|
4307
|
+
""", (memory_name, model_type, weight_json, 1))
|
|
4308
|
+
|
|
4309
|
+
c.execute("""
|
|
4310
|
+
UPDATE weight_storage
|
|
4311
|
+
SET is_active = 0
|
|
4312
|
+
WHERE memory_name = ? AND id != last_insert_rowid()
|
|
4313
|
+
""", (memory_name,))
|
|
4314
|
+
|
|
4315
|
+
conn.commit()
|
|
4316
|
+
conn.close()
|
|
4317
|
+
|
|
4318
|
+
print('[||] Weights dictionary saved!')
|
|
4189
4319
|
|
|
4320
|
+
except Exception as e:
|
|
4321
|
+
print(f'[-] Cant save Weights due to: {e}')
|
|
4322
|
+
pass
|
|
4323
|
+
|
|
4324
|
+
def load_weights(self, memory_name):
|
|
4325
|
+
"""Load weights from database. Returns True if found."""
|
|
4326
|
+
result = self.weight_retrieval(memory_name)
|
|
4327
|
+
|
|
4328
|
+
if not result:
|
|
4329
|
+
print(f'[=] No saved weights for {memory_name}')
|
|
4330
|
+
return False
|
|
4331
|
+
|
|
4332
|
+
try:
|
|
4333
|
+
weights = result
|
|
4334
|
+
self.pipeline.network_model.cell.W = np.array(weights['lstm_W'])
|
|
4335
|
+
self.pipeline.network_model.cell.b = np.array(weights['lstm_b'])
|
|
4336
|
+
self.pipeline.network_model.Wy = np.array(weights['Wy']) if weights['Wy'] else None
|
|
4337
|
+
self.pipeline.network_model.by = np.array(weights['by'])
|
|
4338
|
+
self.pipeline.lstm_engine.residual_mean = weights.get('residual_mean', 0.0)
|
|
4339
|
+
self.pipeline.lstm_engine.residual_std = weights.get('residual_std', 1.0)
|
|
4340
|
+
self.pipeline.lstm_engine.n_samples = weights.get('n_samples', self.pipeline.lstm_engine.n_samples)
|
|
4341
|
+
self.pipeline.lstm_engine.quantiles = {float(k): tuple(v)
|
|
4342
|
+
for k, v in weights.get('quantiles', {}).items()}
|
|
4343
|
+
|
|
4344
|
+
print(f'[=] All Weights loaded for {memory_name} '
|
|
4345
|
+
f'(saved at {weights.get("saved_at", "unknown")})')
|
|
4346
|
+
except Exception as e:
|
|
4347
|
+
print(f'[!] Cant load any Weights due to: {e}')
|
|
4348
|
+
traceback.print_exc()
|
|
4190
4349
|
|
|
4191
4350
|
|
|
4192
4351
|
def load_transformer_dict(self, memory_name):
|
|
@@ -6271,7 +6430,7 @@ class AgentDistributedInference:
|
|
|
6271
6430
|
probs = self.handle_peer_uncertainty(probs, target_preds, self_attn_weights, attn_weights, input_ids)
|
|
6272
6431
|
else:
|
|
6273
6432
|
try:
|
|
6274
|
-
probs = self.process_peer_request(target_preds, self_attn_weights,
|
|
6433
|
+
probs = self.process_peer_request(probs, target_preds, self_attn_weights, input_ids)
|
|
6275
6434
|
|
|
6276
6435
|
except Exception as e:
|
|
6277
6436
|
print(f"[-] Error processing request: {e}, returning regular probs")
|
|
@@ -6403,7 +6562,7 @@ class AgentDistributedInference:
|
|
|
6403
6562
|
|
|
6404
6563
|
def process_peer_request(self, probs, target_preds, attn_weights, input_ids):
|
|
6405
6564
|
try:
|
|
6406
|
-
response_probs = self.pipeline.
|
|
6565
|
+
response_probs = self.pipeline._calibrate_probs(probs, target_preds, attn_weights, input_ids)
|
|
6407
6566
|
return response_probs
|
|
6408
6567
|
except Exception as e:
|
|
6409
6568
|
print(f"[-] Error in peer request_processing: {e}")
|
|
@@ -7087,19 +7246,19 @@ class IntegratedPipeline:
|
|
|
7087
7246
|
# Main component setup
|
|
7088
7247
|
self.standard_scaler = StandardScaler()
|
|
7089
7248
|
self.tfidf = TfidfVectorizer(max_features=70)
|
|
7090
|
-
self.storage = ModelStorage(memory_name, db_path='activity_log.db')
|
|
7091
|
-
self.distribution = AgentDistributedInference(self, self.storage, memory_name, port=self.port, use_async=use_async, secret_key=self.secret_key, ssl_cert_file=ssl_cert_file, ssl_key_file=ssl_key_file, shared_auth_token=self.shared_auth_token, predict_manager=self.manager)
|
|
7092
|
-
self.ensemble = WeightedEnsemblePredictor(self, self.distribution, memory_name)
|
|
7093
|
-
self.session_automation = CrossSessionAutomation(self)
|
|
7094
|
-
self.batcher = AutoBatcherAutomation(self)
|
|
7095
|
-
self.query_node = QueryNode(self, memory_name, self.storage)
|
|
7096
|
-
|
|
7097
7249
|
# LSTM __init__ setup
|
|
7098
7250
|
self.network_model = LSTMNetwork(self, input_size=self.input_size, hidden_size=self.hidden, output_size=self.output_size)
|
|
7099
7251
|
self.scrapper_model = LSTMEngine(self, self.network_model, dropout=self.dropout_rate, n_samples=50)
|
|
7100
7252
|
self.lstm_engine = None
|
|
7101
7253
|
self.lstm_n_samples = 0
|
|
7102
7254
|
|
|
7255
|
+
self.storage = ModelStorage(self, memory_name, db_path='activity_log.db')
|
|
7256
|
+
self.distribution = AgentDistributedInference(self, self.storage, memory_name, port=self.port, use_async=use_async, secret_key=self.secret_key, ssl_cert_file=ssl_cert_file, ssl_key_file=ssl_key_file, shared_auth_token=self.shared_auth_token, predict_manager=self.manager)
|
|
7257
|
+
self.ensemble = WeightedEnsemblePredictor(self, self.distribution, memory_name)
|
|
7258
|
+
self.session_automation = CrossSessionAutomation(self)
|
|
7259
|
+
self.batcher = AutoBatcherAutomation(self)
|
|
7260
|
+
self.query_node = QueryNode(self, memory_name, self.storage)
|
|
7261
|
+
|
|
7103
7262
|
self._agent_mode = os.environ.get('AGENT_MODE', 'single')
|
|
7104
7263
|
self._agent_port = int(os.environ.get('AGENT_PORT', 5555))
|
|
7105
7264
|
self._use_async = os.environ.get('USE_ASYNC_QUEUE', 'true').lower() == 'true'
|
|
@@ -9296,13 +9455,19 @@ class IntegratedPipeline:
|
|
|
9296
9455
|
self.initialize_fitting(X_raw_generation)
|
|
9297
9456
|
X = self.shape_adaptation(hybrid_X, input_dim)
|
|
9298
9457
|
|
|
9299
|
-
self.lstm_setup_inference(X, y)
|
|
9458
|
+
self.lstm_setup_inference(X, y)
|
|
9300
9459
|
self.initialize_model_(X, input_dim, n_classes)
|
|
9301
9460
|
self.model3.train(X, y, epochs=1000, lr=0.1)
|
|
9302
9461
|
|
|
9462
|
+
if self.lstm_engine:
|
|
9463
|
+
self.storage.save_weights(self.memory_name, model_type='Pipeline')
|
|
9464
|
+
|
|
9303
9465
|
print('🎉 All Model Trained!')
|
|
9304
9466
|
else:
|
|
9305
9467
|
print(f'[=] No suitable condition for training!')
|
|
9468
|
+
print('[=] Saving Weights for prediction')
|
|
9469
|
+
self.storage.load_weights(self.memory_name)
|
|
9470
|
+
|
|
9306
9471
|
pass
|
|
9307
9472
|
|
|
9308
9473
|
|
|
@@ -11905,6 +12070,15 @@ class PipelinePredictionManager:
|
|
|
11905
12070
|
print('[=] label_bins cache found!')
|
|
11906
12071
|
label_bins = self.pipeline.cache['label_bins']
|
|
11907
12072
|
lstm_probs, _ = self.pipeline.ensemble._get_lstm_probs(input_ids, X, label_bins=label_bins)
|
|
12073
|
+
else:
|
|
12074
|
+
lstm_probs = None
|
|
12075
|
+
|
|
12076
|
+
results = []
|
|
12077
|
+
attention_data = [] if return_attention else None
|
|
12078
|
+
|
|
12079
|
+
target_probs = self.pipeline.predict_proba(input_ids, X, type='Hybrid', embedded=True)
|
|
12080
|
+
target_probs = target_probs[:mlp_probs.shape[0], :mlp_probs.shape[1]]
|
|
12081
|
+
target_pred_indices = np.argmax(target_probs, axis=1)
|
|
11908
12082
|
|
|
11909
12083
|
results = []
|
|
11910
12084
|
attention_data = [] if return_attention else None
|
|
@@ -11927,15 +12101,16 @@ class PipelinePredictionManager:
|
|
|
11927
12101
|
mlp_confidence = mlp_probs[i][mlp_class_idx]
|
|
11928
12102
|
mlp_label = reverse_map.get(mlp_class_idx, f"unknown_{mlp_class_idx}")
|
|
11929
12103
|
|
|
11930
|
-
|
|
11931
|
-
|
|
11932
|
-
|
|
11933
|
-
|
|
12104
|
+
if lstm_probs is not None:
|
|
12105
|
+
lstm_pred_indices = np.argmax(lstm_probs, axis=1)
|
|
12106
|
+
lstm_class_idx = lstm_pred_indices[i]
|
|
12107
|
+
lstm_confidence = lstm_probs[i][lstm_class_idx]
|
|
12108
|
+
else:
|
|
12109
|
+
lstm_confidence = None
|
|
12110
|
+
|
|
12111
|
+
target_class_idx = target_pred_indices[i]
|
|
12112
|
+
target_confidence = target_probs[i][target_class_idx]
|
|
11934
12113
|
|
|
11935
|
-
if float(mlp_confidence) < self.pipeline.confidence_threshold:
|
|
11936
|
-
target_class_idx = target_pred_indices[i]
|
|
11937
|
-
target_confidence = target_probs[i][target_class_idx]
|
|
11938
|
-
|
|
11939
12114
|
# Transformer prediction and blending
|
|
11940
12115
|
if trans_probs is not None:
|
|
11941
12116
|
trans_probs_i = trans_probs[i]
|
|
@@ -11945,14 +12120,6 @@ class PipelinePredictionManager:
|
|
|
11945
12120
|
else:
|
|
11946
12121
|
trans_confidence = trans_probs_i[trans_class_idx]
|
|
11947
12122
|
|
|
11948
|
-
if lstm_probs is not None:
|
|
11949
|
-
lstm_probs_i = lstm_probs[i]
|
|
11950
|
-
lstm_class_idx = np.argmax(lstm_probs_i)
|
|
11951
|
-
if isinstance(lstm_probs_i, float):
|
|
11952
|
-
lstm_confidence = target_confidence
|
|
11953
|
-
else:
|
|
11954
|
-
lstm_confidence = lstm_probs_i[lstm_class_idx]
|
|
11955
|
-
|
|
11956
12123
|
trans_label = reverse_map.get(trans_class_idx, f"unknown_{trans_class_idx}")
|
|
11957
12124
|
|
|
11958
12125
|
calibration = self.pipeline._calibrate_probs(target_probs, target_pred_indices, attn_weights, input_ids)
|
|
@@ -12002,7 +12169,10 @@ class PipelinePredictionManager:
|
|
|
12002
12169
|
'index': int(final_class_idx),
|
|
12003
12170
|
'mlp_prediction': mlp_label,
|
|
12004
12171
|
'mlp_confidence': float(mlp_confidence),
|
|
12005
|
-
'models_agree': bool(agreement)
|
|
12172
|
+
'models_agree': bool(agreement),
|
|
12173
|
+
'sec_predicted': None,
|
|
12174
|
+
'sec_confidence': 0.0,
|
|
12175
|
+
'sec_index': None,
|
|
12006
12176
|
}
|
|
12007
12177
|
|
|
12008
12178
|
if trans_label is not None:
|
|
@@ -12062,8 +12232,6 @@ class PipelinePredictionManager:
|
|
|
12062
12232
|
if float(results[0]['confidence']) < self.pipeline.confidence_threshold:
|
|
12063
12233
|
verbose = True
|
|
12064
12234
|
|
|
12065
|
-
self.display_hybrid_results(results, top_k, verbose=verbose)
|
|
12066
|
-
|
|
12067
12235
|
chosen_label = results[0]['predicted'] if results else None
|
|
12068
12236
|
confidence = results[0]['confidence'] if results else None
|
|
12069
12237
|
if isinstance(chosen_label, int) or isinstance(chosen_label, np.integer):
|
|
@@ -12083,6 +12251,41 @@ class PipelinePredictionManager:
|
|
|
12083
12251
|
if not self.pipeline.autonomous and need_peer_condition:
|
|
12084
12252
|
print('|| Uncertain advanced prediction, requesting peer assistance if allowed...')
|
|
12085
12253
|
final_probs = self.pipeline._handle_distributed_connections(final_probs, attn_weights, input_ids, agreement)
|
|
12254
|
+
final_idx = final_probs[0].argmax()
|
|
12255
|
+
original_idx = final_idx
|
|
12256
|
+
|
|
12257
|
+
if final_idx > len(reverse_map):
|
|
12258
|
+
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
12259
|
+
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
12260
|
+
final_idx = int(final_idx)
|
|
12261
|
+
|
|
12262
|
+
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
12263
|
+
try:
|
|
12264
|
+
print(final_probs)
|
|
12265
|
+
confidence = float(final_probs[final_idx])
|
|
12266
|
+
except:
|
|
12267
|
+
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
12268
|
+
|
|
12269
|
+
elif self.pipeline.autonomous and need_peer_condition and attn_weights is not None:
|
|
12270
|
+
if agreement is None:
|
|
12271
|
+
agreement = False
|
|
12272
|
+
|
|
12273
|
+
print('[||] Iniating local peer output search in database for best output...')
|
|
12274
|
+
final_probs = self.pipeline.distribution._handle_peer_agent_request(final_probs, attn_weights, input_ids, type='DevicePeer', agreement=agreement)
|
|
12275
|
+
final_idx = final_probs[0].argmax()
|
|
12276
|
+
original_idx = final_idx
|
|
12277
|
+
|
|
12278
|
+
if final_idx > len(reverse_map):
|
|
12279
|
+
final_idx = int(np.argmax(final_probs[:len(reverse_map)-1]))
|
|
12280
|
+
print(f"[⚠️] Clamping {final_idx} → {final_idx}")
|
|
12281
|
+
final_idx = int(final_idx)
|
|
12282
|
+
|
|
12283
|
+
chosen_label = reverse_map.get(final_idx, f"unknown_{final_idx}")
|
|
12284
|
+
try:
|
|
12285
|
+
confidence = float(final_probs[final_idx])
|
|
12286
|
+
except:
|
|
12287
|
+
confidence = float(final_probs[0][len(reverse_map)-1]) if isinstance(final_probs[0], (float, int)) else 0.0
|
|
12288
|
+
|
|
12086
12289
|
|
|
12087
12290
|
elif not results[0].get('models_agree', True) and confidence > self.pipeline.confidence_threshold:
|
|
12088
12291
|
if final_confidence is not None and confidence < self.pipeline.confidence_threshold:
|
|
@@ -12222,11 +12425,56 @@ class PipelinePredictionManager:
|
|
|
12222
12425
|
else:
|
|
12223
12426
|
print(f"\n[🎯] Final chosen label for input: {chosen_label} || Confidence: {confidence:.1%}")
|
|
12224
12427
|
|
|
12428
|
+
try:
|
|
12429
|
+
consecutive_probs = self.pipeline.distribution._handle_peer_agent_request(target_probs, attn_weights, input_ids, type='DevicePeer', agreement=agreement)
|
|
12430
|
+
sec_final_idx = consecutive_probs[0].argmax()
|
|
12431
|
+
|
|
12432
|
+
if sec_final_idx > len(reverse_map):
|
|
12433
|
+
sec_final_idx = int(np.argmax(consecutive_probs[:len(reverse_map)-1]))
|
|
12434
|
+
print(f"[⚠️] Clamping {sec_final_idx} → {sec_final_idx}")
|
|
12435
|
+
sec_final_idx = int(sec_final_idx)
|
|
12436
|
+
|
|
12437
|
+
sec_chosen_label = reverse_map.get(sec_final_idx, f"unknown_{sec_final_idx}")
|
|
12438
|
+
try:
|
|
12439
|
+
sec_confidence = float(consecutive_probs[0][sec_final_idx])
|
|
12440
|
+
except:
|
|
12441
|
+
sec_confidence = float(consecutive_probs[0][len(reverse_map)-1]) if isinstance(consecutive_probs[0], (float, int)) else self.pipeline.confidence_threshold
|
|
12442
|
+
|
|
12443
|
+
print('========== Second Prediction Initiative ==========')
|
|
12444
|
+
print(f'[⚡] My Second Prediction: {sec_chosen_label}')
|
|
12445
|
+
print(f'[⚡] Confidence: {sec_confidence:.1%}')
|
|
12446
|
+
|
|
12447
|
+
results[0]['sec_predicted'] = sec_chosen_label
|
|
12448
|
+
results[0]['sec_confidence'] = sec_confidence
|
|
12449
|
+
results[0]['sec_index'] = sec_final_idx
|
|
12450
|
+
|
|
12451
|
+
if confidence > results[0]['confidence']:
|
|
12452
|
+
results[0]['predicted'] = chosen_label
|
|
12453
|
+
results[0]['confidence'] = confidence
|
|
12454
|
+
results[0]['index'] = final_idx
|
|
12455
|
+
except Exception as e:
|
|
12456
|
+
print(f'[!] Error initiating second prediction in Advaned prediction method: {e} ')
|
|
12457
|
+
|
|
12458
|
+
results[0]['sec_predicted'] = chosen_label
|
|
12459
|
+
results[0]['sec_confidence'] = confidence
|
|
12460
|
+
results[0]['sec_index'] = final_idx
|
|
12461
|
+
|
|
12462
|
+
time.sleep(5)
|
|
12463
|
+
|
|
12225
12464
|
except Exception as e:
|
|
12226
|
-
print(f"[
|
|
12227
|
-
traceback.print_exc()
|
|
12465
|
+
print(f"[= ! =] Error in advanced prediction method: {e}")
|
|
12228
12466
|
results, chosen_label, confidence = None, None, 0.0
|
|
12229
|
-
|
|
12467
|
+
time.sleep(5)
|
|
12468
|
+
|
|
12469
|
+
print('[=] Displaying Results....')
|
|
12470
|
+
correct, sec_correct = self.display_hybrid_results(results, top_k, verbose=True)
|
|
12471
|
+
if sec_chosen_label and sec_correct > correct:
|
|
12472
|
+
print(f'[⚡] Second Prediction: {sec_chosen_label} has higher accuracies, relying on: {sec_chosen_label} as final label.')
|
|
12473
|
+
chosen_label = sec_chosen_label # overrides previous chosen label if accuracy is higher
|
|
12474
|
+
if self.pipeline.autonomous and sec_confidence > self.pipeline.confidence_threshold:
|
|
12475
|
+
print(f'[⚡] Autonomous Prediction used second predicted label: {sec_chosen_label}')
|
|
12476
|
+
chosen_label = sec_chosen_label
|
|
12477
|
+
|
|
12230
12478
|
return results, chosen_label, confidence
|
|
12231
12479
|
|
|
12232
12480
|
|
|
@@ -12236,6 +12484,7 @@ class PipelinePredictionManager:
|
|
|
12236
12484
|
print("="*80)
|
|
12237
12485
|
|
|
12238
12486
|
correct = 0
|
|
12487
|
+
sec_correct = 0
|
|
12239
12488
|
total_with_expected = 0
|
|
12240
12489
|
|
|
12241
12490
|
for idx, result in enumerate(results):
|
|
@@ -12243,10 +12492,15 @@ class PipelinePredictionManager:
|
|
|
12243
12492
|
|
|
12244
12493
|
if result.get('expected'):
|
|
12245
12494
|
total_with_expected += 1
|
|
12246
|
-
status = "
|
|
12247
|
-
|
|
12495
|
+
status = ": ✅" if result['predicted'] == result['expected'] else ": ❌"
|
|
12496
|
+
sec_status = ": ✅" if result['sec_predicted'] == result['expected'] else ": ❌"
|
|
12497
|
+
print(f"[=] First Expectation: {result['expected']} || Model Answer: {status}")
|
|
12498
|
+
print(f"[=] Second Expectation: {result['expected']} || Model Answer: {sec_status}")
|
|
12499
|
+
|
|
12248
12500
|
if result['predicted'] == result['expected']:
|
|
12249
12501
|
correct += 1
|
|
12502
|
+
if result['sec_predicted'] == result['expected']:
|
|
12503
|
+
sec_correct += 1
|
|
12250
12504
|
|
|
12251
12505
|
# Agreement indicator
|
|
12252
12506
|
agree_symbol = "✓" if result.get('models_agree', True) else "⚠️"
|
|
@@ -12269,6 +12523,7 @@ class PipelinePredictionManager:
|
|
|
12269
12523
|
accuracy = correct / total_with_expected
|
|
12270
12524
|
print(f"\n📊 Accuracy: {correct}/{total_with_expected} = {accuracy:.1%}")
|
|
12271
12525
|
|
|
12526
|
+
return correct, sec_correct
|
|
12272
12527
|
|
|
12273
12528
|
class ConsecutivePeerAgent:
|
|
12274
12529
|
"""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AbstractIntegratedModule
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
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.
|
|
45
|
+
- Development Stage: Beta, 0.4.3.
|
|
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.
|
|
@@ -63,10 +63,11 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
|
|
|
63
63
|
- P2P Works efficiently in ARM64 Docker + QEMU, No conflicting socket and all prediction works efficiently.
|
|
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
|
+
- Robust Advanced prediction capabilities proven effective on ARM64 Using MLP + LSTM Architectures.
|
|
66
67
|
-----
|
|
67
68
|
|
|
68
69
|
<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" />
|
|
69
|
-
|
|
70
|
+
|
|
70
71
|
|
|
71
72
|
## [+] MANN Intro
|
|
72
73
|
[=] Memory augmented Neural network (MANN) is a neural network architecture coupled with an external, dynamic memory module, allowing it to store, retrieve, and update information similarly to a computer's RAM. Unlike traditional networks that store knowledge only in weight parameters, MANNs excel at fast learning, long-term dependency handling, and episodic recall, In IntegratedPipeline, Its memory is stored in a custom database inside your local machine, then later used for memory retrieval, transfered to the AI Dictionary where it can finnaly recall its memory when input condition matched with memory.
|
|
@@ -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.
|
|
13
|
+
- Development Stage: Beta, 0.4.3.
|
|
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.
|
|
@@ -31,10 +31,11 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
|
|
|
31
31
|
- P2P Works efficiently in ARM64 Docker + QEMU, No conflicting socket and all prediction works efficiently.
|
|
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
|
+
- Robust Advanced prediction capabilities proven effective on ARM64 Using MLP + LSTM Architectures.
|
|
34
35
|
-----
|
|
35
36
|
|
|
36
37
|
<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" />
|
|
37
|
-
|
|
38
|
+
|
|
38
39
|
|
|
39
40
|
## [+] MANN Intro
|
|
40
41
|
[=] Memory augmented Neural network (MANN) is a neural network architecture coupled with an external, dynamic memory module, allowing it to store, retrieve, and update information similarly to a computer's RAM. Unlike traditional networks that store knowledge only in weight parameters, MANNs excel at fast learning, long-term dependency handling, and episodic recall, In IntegratedPipeline, Its memory is stored in a custom database inside your local machine, then later used for memory retrieval, transfered to the AI Dictionary where it can finnaly recall its memory when input condition matched with memory.
|
|
@@ -8,7 +8,7 @@ class BinaryDistribution(Distribution):
|
|
|
8
8
|
|
|
9
9
|
setup(
|
|
10
10
|
name="AbstractIntegratedModule",
|
|
11
|
-
version="0.4.
|
|
11
|
+
version="0.4.3",
|
|
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",
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|