AbstractIntegratedModule 0.9.6__tar.gz → 0.9.7__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.9.6 → abstractintegratedmodule-0.9.7}/AbstractIntegratedModule.egg-info/PKG-INFO +2 -2
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/AbstractIntegratedModule.py +75 -31
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/AbstractOptimizedModules.c +200 -200
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/PKG-INFO +2 -2
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/README.md +1 -1
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/setup.py +1 -1
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/AbstractOptimizedModules.pyx +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/MANIFEST.in +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/abstract_model_storage/Cargo.toml +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/abstract_model_storage/pyproject.toml +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/abstract_model_storage/src/lib.rs +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/pyproject.toml +0 -0
- {abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AbstractIntegratedModule
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.7
|
|
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.9.
|
|
45
|
+
- Development Stage: 0.9.7 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.
|
{abstractintegratedmodule-0.9.6 → abstractintegratedmodule-0.9.7}/AbstractIntegratedModule.py
RENAMED
|
@@ -1950,10 +1950,7 @@ class MLP:
|
|
|
1950
1950
|
|
|
1951
1951
|
if isinstance(self.pred_counts[c], (int, float)) and self.pred_counts[c] > 0:
|
|
1952
1952
|
error_rate = self.error_counts[c] / (self.pred_counts[c] + 1e-8)
|
|
1953
|
-
|
|
1954
|
-
# error_rate=0.0 → multiplier=1.0 (no change)
|
|
1955
|
-
# error_rate=0.5 → multiplier≈0.67
|
|
1956
|
-
# error_rate=1.0 → multiplier≈0.5
|
|
1953
|
+
|
|
1957
1954
|
reputation = 1.0 / (1.0 + error_rate)
|
|
1958
1955
|
if c < len(prob):
|
|
1959
1956
|
prob[c] *= reputation
|
|
@@ -3173,8 +3170,6 @@ class WeightedEnsemblePredictor:
|
|
|
3173
3170
|
|
|
3174
3171
|
|
|
3175
3172
|
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
3173
|
def explainability_prediction_batch(self, texts, mlp_probs, trans_probs, attn_weights, show_explanation=False):
|
|
3179
3174
|
results = []
|
|
3180
3175
|
for text in texts:
|
|
@@ -3186,7 +3181,6 @@ class WeightedEnsemblePredictor:
|
|
|
3186
3181
|
return results
|
|
3187
3182
|
|
|
3188
3183
|
|
|
3189
|
-
|
|
3190
3184
|
|
|
3191
3185
|
def predict_ensemble(self, input_ids, X_mlp, y_true, method='dynamic', embedded=False):
|
|
3192
3186
|
label_bins=None
|
|
@@ -3235,7 +3229,9 @@ class WeightedEnsemblePredictor:
|
|
|
3235
3229
|
elif method == 'meta':
|
|
3236
3230
|
# Meta-learner that decides weights
|
|
3237
3231
|
ensemble_probs = self._meta_ensemble(
|
|
3238
|
-
trans_probs, mlp_probs, attn_weights, X_mlp
|
|
3232
|
+
trans_probs, mlp_probs, attn_weights, X_mlp,
|
|
3233
|
+
lstm_probs=lstm_probs,
|
|
3234
|
+
lstm_weight_hint=lstm_weight_hint
|
|
3239
3235
|
)
|
|
3240
3236
|
|
|
3241
3237
|
elif method == 'calibration':
|
|
@@ -3439,7 +3435,6 @@ class WeightedEnsemblePredictor:
|
|
|
3439
3435
|
|
|
3440
3436
|
|
|
3441
3437
|
def _attention_weighted_ensemble(self, trans_probs, mlp_probs, attn_weights):
|
|
3442
|
-
|
|
3443
3438
|
if attn_weights is None:
|
|
3444
3439
|
return (trans_probs + mlp_probs) / 2
|
|
3445
3440
|
|
|
@@ -3448,8 +3443,8 @@ class WeightedEnsemblePredictor:
|
|
|
3448
3443
|
|
|
3449
3444
|
n_trans_classes = trans_probs.shape[1]
|
|
3450
3445
|
n_mlp_classes = mlp_probs.shape[1]
|
|
3451
|
-
|
|
3452
|
-
|
|
3446
|
+
|
|
3447
|
+
n_classes = max(n_trans_classes, n_mlp_classes)
|
|
3453
3448
|
for i in range(batch_size):
|
|
3454
3449
|
trans_row = np.zeros(n_classes)
|
|
3455
3450
|
mlp_row = np.zeros(n_classes)
|
|
@@ -3486,35 +3481,65 @@ class WeightedEnsemblePredictor:
|
|
|
3486
3481
|
|
|
3487
3482
|
return ensemble
|
|
3488
3483
|
|
|
3489
|
-
def _meta_ensemble(self, trans_probs, mlp_probs, attn_weights, X_mlp
|
|
3484
|
+
def _meta_ensemble(self, trans_probs, mlp_probs, attn_weights, X_mlp,
|
|
3485
|
+
lstm_probs=None, lstm_weight_hint=0.0):
|
|
3486
|
+
lstm_row = None
|
|
3487
|
+
|
|
3490
3488
|
batch_size = trans_probs.shape[0]
|
|
3491
3489
|
n_classes = trans_probs.shape[1]
|
|
3492
3490
|
threshold_feature = 0.1 + self.pipeline.confidence_threshold
|
|
3493
3491
|
|
|
3494
3492
|
n_trans_classes = trans_probs.shape[1]
|
|
3495
3493
|
n_mlp_classes = mlp_probs.shape[1]
|
|
3496
|
-
|
|
3494
|
+
|
|
3495
|
+
has_lstm = lstm_probs is not None
|
|
3496
|
+
if has_lstm:
|
|
3497
|
+
lstm_probs = np.asarray(lstm_probs, dtype=np.float64)
|
|
3498
|
+
if lstm_probs.ndim == 1: lstm_probs = lstm_probs[np.newaxis, :]
|
|
3499
|
+
n_lstm = lstm_probs.shape[1]
|
|
3500
|
+
else:
|
|
3501
|
+
lstm_probs = np.zeros((B, 1), dtype=np.float64) # dummy, not used
|
|
3502
|
+
n_lstm = 0
|
|
3503
|
+
|
|
3504
|
+
n_classes = max(n_trans_classes, n_lstm, n_mlp_classes)
|
|
3505
|
+
print(f"🔄 Aligning classes: trans={n_trans_classes} mlp={n_mlp_classes} "
|
|
3506
|
+
f"lstm={n_lstm} → {n_classes}")
|
|
3497
3507
|
|
|
3498
3508
|
# Create meta features
|
|
3499
3509
|
meta_features = []
|
|
3500
3510
|
for i in range(batch_size):
|
|
3501
3511
|
trans_row = np.zeros(n_classes)
|
|
3502
3512
|
mlp_row = np.zeros(n_classes)
|
|
3503
|
-
|
|
3513
|
+
|
|
3504
3514
|
trans_row[:n_trans_classes] = trans_probs[i]
|
|
3505
3515
|
mlp_row[:n_mlp_classes] = mlp_probs[i]
|
|
3506
|
-
|
|
3516
|
+
if has_lstm:
|
|
3517
|
+
lstm_row = np.zeros(n_classes)
|
|
3518
|
+
lstm_row[:n_lstm] = lstm_probs[i]
|
|
3519
|
+
lstm_row = lstm_row / (lstm_row.sum() + 1e-8)
|
|
3520
|
+
|
|
3507
3521
|
trans_row = trans_row / (trans_row.sum() + 1e-8)
|
|
3508
3522
|
mlp_row = mlp_row / (mlp_row.sum() + 1e-8)
|
|
3509
3523
|
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3524
|
+
if lstm_row is None:
|
|
3525
|
+
features = [
|
|
3526
|
+
np.max(trans_row), # Transformer confidence
|
|
3527
|
+
np.max(mlp_row), # MLP confidence
|
|
3528
|
+
np.std(trans_row), # Transformer spread
|
|
3529
|
+
np.std(mlp_row), # MLP spread
|
|
3530
|
+
1.0 if np.argmax(trans_row) == np.argmax(mlp_row) else 0.0, # Agreement
|
|
3531
|
+
]
|
|
3532
|
+
else:
|
|
3533
|
+
features = [
|
|
3534
|
+
np.max(trans_row), # Transformer confidence
|
|
3535
|
+
np.max(mlp_row), # MLP confidence
|
|
3536
|
+
np.max(lstm_row),
|
|
3537
|
+
np.std(trans_row), # Transformer spread
|
|
3538
|
+
np.std(mlp_row), # MLP spread
|
|
3539
|
+
np.std(lstm_row),
|
|
3540
|
+
1.0 if np.argmax(trans_row) == np.argmax(mlp_row) else 0.0, # Agreement
|
|
3541
|
+
]
|
|
3542
|
+
|
|
3518
3543
|
# Add attention stats if available
|
|
3519
3544
|
if attn_weights is not None and i < len(attn_weights):
|
|
3520
3545
|
attn = attn_weights[i]
|
|
@@ -3540,6 +3565,9 @@ class WeightedEnsemblePredictor:
|
|
|
3540
3565
|
mlp_conf = meta_features[i, 1]
|
|
3541
3566
|
agreement = meta_features[i, 4]
|
|
3542
3567
|
|
|
3568
|
+
trans_pred = int(np.argmax(trans_probs[i]))
|
|
3569
|
+
mlp_pred = int(np.argmax(mlp_probs[i]))
|
|
3570
|
+
|
|
3543
3571
|
# Boost weight when models agree
|
|
3544
3572
|
base_weight = threshold_feature + AME_sigmoid * agreement
|
|
3545
3573
|
|
|
@@ -3550,11 +3578,26 @@ class WeightedEnsemblePredictor:
|
|
|
3550
3578
|
else:
|
|
3551
3579
|
trans_weight = 1.0 - base_weight
|
|
3552
3580
|
mlp_weight = base_weight
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3581
|
+
|
|
3582
|
+
if has_lstm:
|
|
3583
|
+
if lstm_row is None:
|
|
3584
|
+
lstm_row = np.zeros(n_classes)
|
|
3585
|
+
lstm_row[:n_lstm] = lstm_probs[i]
|
|
3586
|
+
lstm_row /= lstm_row.sum() + 1e-8
|
|
3587
|
+
|
|
3588
|
+
lstm_pred = int(np.argmax(lstm_probs[i]))
|
|
3589
|
+
la = 1.0 if (lstm_pred == trans_pred or lstm_pred == mlp_pred) \
|
|
3590
|
+
else self.pipeline.confidence_threshold
|
|
3591
|
+
lw = float(lstm_weight_hints[i]) * (1.0 + la) / 2.0
|
|
3592
|
+
total = trans_weight + mlp_weight + lw + 1e-8
|
|
3593
|
+
ensemble[i] = (trans_weight/total) * trans_row + \
|
|
3594
|
+
(mlp_weight/total) * mlp_row + \
|
|
3595
|
+
(lw/total) * lstm_row
|
|
3596
|
+
else:
|
|
3597
|
+
try:
|
|
3598
|
+
ensemble[i] = trans_weight * trans_row + mlp_weight * mlp_row
|
|
3599
|
+
except:
|
|
3600
|
+
ensemble = trans_weight * trans_row + mlp_weight * mlp_row
|
|
3558
3601
|
|
|
3559
3602
|
return ensemble
|
|
3560
3603
|
|
|
@@ -5962,7 +6005,7 @@ class AsyncMessageQueue:
|
|
|
5962
6005
|
async def publish(self, message: Message) -> Any:
|
|
5963
6006
|
await self._ensure_started()
|
|
5964
6007
|
|
|
5965
|
-
# plain increment
|
|
6008
|
+
# plain increment
|
|
5966
6009
|
self._counter += 1
|
|
5967
6010
|
counter = self._counter
|
|
5968
6011
|
|
|
@@ -15474,7 +15517,7 @@ class PipelinePredictionManager:
|
|
|
15474
15517
|
if titles is not None and rules is not None:
|
|
15475
15518
|
print(f"[🔍] Preparing data for {len(titles)} titles with {len(rules)} length of rules.")
|
|
15476
15519
|
if X is None and y is None or X is None or y is None:
|
|
15477
|
-
print('[🔄] Creating automatic X samples because X is not provided manually.')
|
|
15520
|
+
print('[🔄] Creating automatic X samples because X Samples is not provided manually.')
|
|
15478
15521
|
datasets, X_gen = self.pipeline.data_preparation(titles, label_map)
|
|
15479
15522
|
_, y, _, _ = self.pipeline.mlp_training_features(rules, datasets)
|
|
15480
15523
|
else:
|
|
@@ -15735,7 +15778,7 @@ class PipelinePredictionManager:
|
|
|
15735
15778
|
num_classes = num_classes or mlp_probs.shape[1]
|
|
15736
15779
|
models_agree = False
|
|
15737
15780
|
|
|
15738
|
-
# ── MLP ─────────────────────────────────────────────
|
|
15781
|
+
# ── MLP layer ─────────────────────────────────────────────
|
|
15739
15782
|
mlp_class_idx = int(np.argmax(mlp_probs[i]))
|
|
15740
15783
|
is_valid_index = 0 <= mlp_class_idx < num_classes
|
|
15741
15784
|
|
|
@@ -15891,6 +15934,7 @@ class PipelinePredictionManager:
|
|
|
15891
15934
|
use_transformer=True, return_attention=False,
|
|
15892
15935
|
save_results=True, batch_size=2):
|
|
15893
15936
|
try:
|
|
15937
|
+
# ____ init temporary layer ____
|
|
15894
15938
|
eps = 1e-5
|
|
15895
15939
|
trans_probs = None
|
|
15896
15940
|
attn_weights = None
|