AbstractIntegratedModule 0.7.1__tar.gz → 0.7.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.7.1 → abstractintegratedmodule-0.7.3}/AbstractIntegratedModule.egg-info/PKG-INFO +5 -5
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/AbstractIntegratedModule.egg-info/SOURCES.txt +2 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/AbstractIntegratedModule.py +128 -89
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/AbstractOptimizedModules.c +752 -192
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/PKG-INFO +5 -5
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/README.md +4 -4
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/abstract_model_storage/Cargo.toml +2 -1
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/abstract_model_storage/src/lib.rs +141 -0
- abstractintegratedmodule-0.7.3/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +5 -0
- abstractintegratedmodule-0.7.3/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +5 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/setup.py +1 -1
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/AbstractOptimizedModules.pyx +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/MANIFEST.in +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/abstract_model_storage/pyproject.toml +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/pyproject.toml +0 -0
- {abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AbstractIntegratedModule
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
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.
|
|
45
|
+
- Development Stage: 0.7.3 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.
|
|
@@ -65,16 +65,16 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
|
|
|
65
65
|
- Robust Advanced prediction capabilities proven effective on ARM64 Using MLP + LSTM Architectures.
|
|
66
66
|
- Transformer Modules Optimized using Cython, to reduce Memory overhead and Reduce CPU Usage, With Reduced Training Time.
|
|
67
67
|
- Changelog:
|
|
68
|
-
- v0.7.
|
|
68
|
+
- v0.7.3:
|
|
69
69
|
- [=] New features:
|
|
70
|
-
- Added Rust specific compiled binary for handling complex weight matrices.
|
|
71
|
-
- added specific optimized weight saving handling with rust optimization.
|
|
72
70
|
- Adding Optimization and refinements, especially bug fixes in:
|
|
73
71
|
- IntegratedPipeline lstm samples creating
|
|
74
72
|
- IntegratedPipeline shape adaptation
|
|
75
73
|
- IntegratedPipeline probability calibration
|
|
76
74
|
- IntegratedPipeline auto generate labels text
|
|
77
75
|
- IntegratedPipeline MLP samples generation.
|
|
76
|
+
- Added New specific module in Rust for Parsing JSON values with reduced memory lookup overhead.
|
|
77
|
+
- Fixed bug where number of classes can be None in edge cases.
|
|
78
78
|
|
|
79
79
|
-----
|
|
80
80
|
|
|
@@ -15,6 +15,8 @@ abstract_model_storage/Cargo.toml
|
|
|
15
15
|
abstract_model_storage/pyproject.toml
|
|
16
16
|
abstract_model_storage/src/lib.rs
|
|
17
17
|
abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs
|
|
18
|
+
abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs
|
|
18
19
|
abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs
|
|
19
20
|
abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs
|
|
21
|
+
abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs
|
|
20
22
|
abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs
|
{abstractintegratedmodule-0.7.1 → abstractintegratedmodule-0.7.3}/AbstractIntegratedModule.py
RENAMED
|
@@ -4117,14 +4117,14 @@ class ModelStorage:
|
|
|
4117
4117
|
db_filename= self.db_path
|
|
4118
4118
|
if getattr(sys, 'frozen', False):
|
|
4119
4119
|
application_path = sys._MEIPASS
|
|
4120
|
-
print(f"Running as EXE, temp path: {application_path}")
|
|
4120
|
+
print(f"[🔄] Running as EXE, temp path: {application_path}")
|
|
4121
4121
|
else:
|
|
4122
4122
|
application_path = os.path.dirname(os.path.abspath(__file__))
|
|
4123
|
-
print(f"Running as script, path: {application_path}")
|
|
4123
|
+
print(f"[🔄] Running as script, path: {application_path}")
|
|
4124
4124
|
|
|
4125
4125
|
db_path = os.path.join(application_path, db_filename)
|
|
4126
|
-
print(f"Looking for database at: {db_path}")
|
|
4127
|
-
print(f"Database exists: {os.path.exists(db_path)}")
|
|
4126
|
+
print(f"[🔄] Looking for database at: {db_path}")
|
|
4127
|
+
print(f"[✅] Database exists: {os.path.exists(db_path)}")
|
|
4128
4128
|
|
|
4129
4129
|
return db_path
|
|
4130
4130
|
|
|
@@ -4426,41 +4426,51 @@ class ModelStorage:
|
|
|
4426
4426
|
|
|
4427
4427
|
serializable_dict = self._prepare_for_serialization(model_dict)
|
|
4428
4428
|
model_json = json.dumps(serializable_dict, default=str)
|
|
4429
|
-
if type == 'Transformer':
|
|
4430
|
-
try:
|
|
4431
|
-
c.execute("""
|
|
4432
|
-
INSERT INTO model_attn_storage
|
|
4433
|
-
(memory_name, model_type, model_data, is_active)
|
|
4434
|
-
VALUES (?, ?, ?, ?)
|
|
4435
|
-
""", (memory_name, model_type, model_json, 1))
|
|
4436
|
-
|
|
4437
|
-
c.execute("""
|
|
4438
|
-
UPDATE model_attn_storage
|
|
4439
|
-
SET is_active = 0
|
|
4440
|
-
WHERE memory_name = ? AND id != last_insert_rowid()
|
|
4441
|
-
""", (memory_name,))
|
|
4442
4429
|
|
|
4430
|
+
if _RUST_MODULE_AVAILABLE:
|
|
4431
|
+
try:
|
|
4432
|
+
wc.save_pipelines_dict(self.db_path, memory_name,
|
|
4433
|
+
model_type, model_json)
|
|
4434
|
+
print('[=] Pipelines dictionary saved using Rust module!')
|
|
4443
4435
|
except Exception as e:
|
|
4444
|
-
print(f'[
|
|
4445
|
-
|
|
4436
|
+
print(f'[!] Cant save Pipelines dictionary due to: {e}')
|
|
4437
|
+
|
|
4446
4438
|
else:
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
|
|
4451
|
-
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4439
|
+
if type == 'Transformer':
|
|
4440
|
+
try:
|
|
4441
|
+
c.execute("""
|
|
4442
|
+
INSERT INTO model_attn_storage
|
|
4443
|
+
(memory_name, model_type, model_data, is_active)
|
|
4444
|
+
VALUES (?, ?, ?, ?)
|
|
4445
|
+
""", (memory_name, model_type, model_json, 1))
|
|
4446
|
+
|
|
4447
|
+
c.execute("""
|
|
4448
|
+
UPDATE model_attn_storage
|
|
4449
|
+
SET is_active = 0
|
|
4450
|
+
WHERE memory_name = ? AND id != last_insert_rowid()
|
|
4451
|
+
""", (memory_name,))
|
|
4459
4452
|
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4453
|
+
except Exception as e:
|
|
4454
|
+
print(f'[-] Cant save model memory due to: {e}')
|
|
4455
|
+
pass
|
|
4456
|
+
else:
|
|
4457
|
+
try:
|
|
4458
|
+
c.execute("""
|
|
4459
|
+
INSERT INTO model_storage
|
|
4460
|
+
(memory_name, model_type, model_data, is_active)
|
|
4461
|
+
VALUES (?, ?, ?, ?)
|
|
4462
|
+
""", (memory_name, model_type, model_json, 1))
|
|
4463
|
+
|
|
4464
|
+
c.execute("""
|
|
4465
|
+
UPDATE model_storage
|
|
4466
|
+
SET is_active = 0
|
|
4467
|
+
WHERE memory_name = ? AND id != last_insert_rowid()
|
|
4468
|
+
""", (memory_name,))
|
|
4469
|
+
|
|
4470
|
+
except Exception as e:
|
|
4471
|
+
print(f'[-] Cant save model memory due to: {e}')
|
|
4472
|
+
pass
|
|
4473
|
+
|
|
4464
4474
|
conn.commit()
|
|
4465
4475
|
model_id = c.lastrowid
|
|
4466
4476
|
conn.close()
|
|
@@ -4479,33 +4489,48 @@ class ModelStorage:
|
|
|
4479
4489
|
|
|
4480
4490
|
def load_model_dict(self, memory_name):
|
|
4481
4491
|
conn = None
|
|
4482
|
-
|
|
4492
|
+
if _RUST_MODULE_AVAILABLE:
|
|
4483
4493
|
try:
|
|
4484
|
-
|
|
4485
|
-
|
|
4486
|
-
|
|
4494
|
+
num_classes = self.pipeline._get_num_classes() or 0
|
|
4495
|
+
cleaned_json = wc.load_and_validate_model_dict(
|
|
4496
|
+
self.db_path, memory_name, num_classes
|
|
4497
|
+
)
|
|
4498
|
+
if cleaned_json is None:
|
|
4499
|
+
return None
|
|
4500
|
+
data = json.loads(cleaned_json)
|
|
4501
|
+
# the heavy JSON parse + basic schema check already done in Rust
|
|
4502
|
+
validation = self._validate_and_repair(data, memory_name)
|
|
4503
|
+
return validation
|
|
4504
|
+
except Exception as e:
|
|
4505
|
+
print(f'[!] Rust load_model_dict failed: {e}')
|
|
4506
|
+
else:
|
|
4507
|
+
try:
|
|
4508
|
+
try:
|
|
4509
|
+
conn = sqlite3.connect(self.db_path)
|
|
4510
|
+
except:
|
|
4511
|
+
conn = sqlite3.connect(self.get_database_path())
|
|
4487
4512
|
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4513
|
+
c = conn.cursor()
|
|
4514
|
+
c.execute("""
|
|
4515
|
+
SELECT model_data FROM model_storage
|
|
4516
|
+
WHERE memory_name = ? AND is_active = 1
|
|
4517
|
+
ORDER BY id DESC LIMIT 1
|
|
4518
|
+
""", (memory_name,))
|
|
4494
4519
|
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4520
|
+
result = c.fetchone()
|
|
4521
|
+
if not result:
|
|
4522
|
+
return None
|
|
4498
4523
|
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4524
|
+
data = json.loads(result[0])
|
|
4525
|
+
data = self._validate_and_repair(data, memory_name)
|
|
4526
|
+
return data # actually return data
|
|
4502
4527
|
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4528
|
+
except Exception as e:
|
|
4529
|
+
print(f'[!] Error loading model dict: {e}')
|
|
4530
|
+
return None
|
|
4531
|
+
finally:
|
|
4532
|
+
if conn:
|
|
4533
|
+
conn.close()
|
|
4509
4534
|
|
|
4510
4535
|
|
|
4511
4536
|
def _validate_and_repair(self, data, memory_name=None):
|
|
@@ -5423,31 +5448,7 @@ class ModelStorage:
|
|
|
5423
5448
|
print(f"✅ Integrated pipeline '{pipeline_name}' saved")
|
|
5424
5449
|
return model_id
|
|
5425
5450
|
|
|
5426
|
-
|
|
5427
|
-
class Message:
|
|
5428
|
-
# Enhanced message with better tracking and retry logic for async processing
|
|
5429
|
-
id: str
|
|
5430
|
-
type: str
|
|
5431
|
-
sender: str
|
|
5432
|
-
recipient: str
|
|
5433
|
-
payload: Any
|
|
5434
|
-
timestamp: datetime
|
|
5435
|
-
priority: MessagePriority = MessagePriority.NORMAL
|
|
5436
|
-
callback: Optional[Callable] = None
|
|
5437
|
-
retry_count: int = 0
|
|
5438
|
-
max_retries: int = 3
|
|
5439
|
-
timeout: float = 30.0
|
|
5440
|
-
created_at: float = field(default_factory=time.time)
|
|
5441
|
-
|
|
5442
|
-
@property
|
|
5443
|
-
def age(self) -> float:
|
|
5444
|
-
# Age of message in seconds.
|
|
5445
|
-
return time.time() - self.created_at
|
|
5446
|
-
|
|
5447
|
-
@property
|
|
5448
|
-
def is_expired(self) -> bool:
|
|
5449
|
-
# Check if message has expired.
|
|
5450
|
-
return self.age > self.timeout
|
|
5451
|
+
|
|
5451
5452
|
|
|
5452
5453
|
class AsyncMessageQueue:
|
|
5453
5454
|
# async message queue handler.
|
|
@@ -8346,7 +8347,7 @@ class IntegratedPipeline:
|
|
|
8346
8347
|
texts = [d[0] for d in datasets]
|
|
8347
8348
|
intents = [d[1] for d in datasets]
|
|
8348
8349
|
intent_to_id = {intent:i for i, intent in enumerate(sorted(set(intents)))}
|
|
8349
|
-
num_classes =
|
|
8350
|
+
num_classes = self._get_num_classes()
|
|
8350
8351
|
labels = [intent_to_id[i] for i in intents]
|
|
8351
8352
|
|
|
8352
8353
|
reverse_map = {}
|
|
@@ -9458,7 +9459,7 @@ class IntegratedPipeline:
|
|
|
9458
9459
|
# primary source — actual model output dimension
|
|
9459
9460
|
if hasattr(self, 'model2') and self.model2:
|
|
9460
9461
|
model_classes = self.model2.output.shape[1]
|
|
9461
|
-
|
|
9462
|
+
if hasattr(self, 'mlp') and self.mlp.layers:
|
|
9462
9463
|
model_classes = self.mlp.layers[-1].b.shape[1]
|
|
9463
9464
|
|
|
9464
9465
|
# cross-check against label_map if provided
|
|
@@ -9467,18 +9468,33 @@ class IntegratedPipeline:
|
|
|
9467
9468
|
if model_classes is not None and label_classes != model_classes:
|
|
9468
9469
|
print(f'[⚠️] num_classes mismatch: model={model_classes} '
|
|
9469
9470
|
f'label_map={label_classes} — using model output as source of truth')
|
|
9470
|
-
|
|
9471
|
+
if model_classes is None:
|
|
9471
9472
|
model_classes = label_classes
|
|
9472
9473
|
|
|
9473
9474
|
# cross-check against mlp_probs if provided
|
|
9474
|
-
|
|
9475
|
+
elif mlp_probs is not None:
|
|
9475
9476
|
probs_classes = mlp_probs.shape[1] if mlp_probs.ndim > 1 else len(mlp_probs[0])
|
|
9476
9477
|
if model_classes is not None and probs_classes != model_classes:
|
|
9477
9478
|
print(f'[⚠️] num_classes mismatch: model={model_classes} '
|
|
9478
9479
|
f'mlp_probs={probs_classes} — using model output as source of truth')
|
|
9479
|
-
|
|
9480
|
+
if model_classes is None:
|
|
9480
9481
|
model_classes = probs_classes
|
|
9481
9482
|
|
|
9483
|
+
# Dangerous Fallbacks (some of This may corrupt predictions)
|
|
9484
|
+
if model_classes is None:
|
|
9485
|
+
if self.manager:
|
|
9486
|
+
model_classes = len(self.manager.label_map)
|
|
9487
|
+
if self.vocab:
|
|
9488
|
+
raise Warning()
|
|
9489
|
+
model_classes = len(self.vocab)
|
|
9490
|
+
else:
|
|
9491
|
+
try:
|
|
9492
|
+
model_classes = 1 # Fallback if everything else Fails.
|
|
9493
|
+
raise Warning('[!] All Possible Methods of getting Number of classes fails! This may corrupt possible prediction downstream, Consider restart prediction and initialized models correctly with correct samples and label map!')
|
|
9494
|
+
except:
|
|
9495
|
+
model_classes = 1
|
|
9496
|
+
pass
|
|
9497
|
+
|
|
9482
9498
|
return model_classes
|
|
9483
9499
|
|
|
9484
9500
|
|
|
@@ -9910,6 +9926,13 @@ class IntegratedPipeline:
|
|
|
9910
9926
|
|
|
9911
9927
|
if isinstance(input_ids, list):
|
|
9912
9928
|
input_ids = np.array(input_ids)
|
|
9929
|
+
|
|
9930
|
+
try:
|
|
9931
|
+
target_preds = np.asarray(target_preds).ravel().astype(int)
|
|
9932
|
+
except (TypeError, ValueError) as e:
|
|
9933
|
+
print(f'[!] target_preds could not be coerced to int array: '
|
|
9934
|
+
f'type={type(target_preds)} error={e}')
|
|
9935
|
+
return calibrated # return uncalibrated
|
|
9913
9936
|
|
|
9914
9937
|
n_classes = probs.shape[1] if probs.ndim > 1 else probs.shape[0]
|
|
9915
9938
|
batch_size = len(target_preds)
|
|
@@ -9950,10 +9973,26 @@ class IntegratedPipeline:
|
|
|
9950
9973
|
temp = float(np.clip(np.mean(temp), 1e-5, 5.0))
|
|
9951
9974
|
temperature_accum.append(temp)
|
|
9952
9975
|
|
|
9976
|
+
try:
|
|
9977
|
+
mlp_target_int = int(mlp_target)
|
|
9978
|
+
except (TypeError, ValueError) as e:
|
|
9979
|
+
print(f'[!] mlp_target coercion failed at i={i}: '
|
|
9980
|
+
f'type={type(mlp_target)} value={mlp_target} error={e}')
|
|
9981
|
+
continue
|
|
9982
|
+
|
|
9983
|
+
# also guard against array type slipping through
|
|
9984
|
+
if isinstance(mlp_target, np.ndarray):
|
|
9985
|
+
if mlp_target.size == 1:
|
|
9986
|
+
mlp_target_int = int(mlp_target.flat[0])
|
|
9987
|
+
print(f'[!] mlp_target was ndarray, extracted scalar: {mlp_target_int}')
|
|
9988
|
+
else:
|
|
9989
|
+
print(f'[!] mlp_target was multi-element array {mlp_target.shape} at i={i} — skipping')
|
|
9990
|
+
continue
|
|
9991
|
+
|
|
9953
9992
|
# bounds guard before indexing
|
|
9954
9993
|
if 0 <= mlp_target < n_classes and i < calibrated.shape[0]:
|
|
9955
|
-
calibrated[i,
|
|
9956
|
-
calibrated[i,
|
|
9994
|
+
calibrated[i, mlp_target_int] = min(
|
|
9995
|
+
calibrated[i, mlp_target_int] * (1.5 * (1.0 - abstract_score)), 0.95
|
|
9957
9996
|
)
|
|
9958
9997
|
|
|
9959
9998
|
row_sum = calibrated[i].sum()
|