AbstractIntegratedModule 1.1.4__tar.gz → 1.1.5__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-1.1.4 → abstractintegratedmodule-1.1.5}/AbstractIntegratedModule.egg-info/PKG-INFO +1 -1
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/AbstractIntegratedModule.py +63 -10
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/AbstractOptimizedModules.c +200 -200
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/PKG-INFO +1 -1
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/README.md +3 -5
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/pyproject.toml +1 -1
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/setup.py +1 -1
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/AbstractOptimizedModules.pyx +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/MANIFEST.in +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/abstract_model_storage/Cargo.toml +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/abstract_model_storage/pyproject.toml +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/abstract_model_storage/src/lib.rs +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
- {abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/setup.cfg +0 -0
{abstractintegratedmodule-1.1.4 → abstractintegratedmodule-1.1.5}/AbstractIntegratedModule.py
RENAMED
|
@@ -4003,6 +4003,7 @@ class ExplainabilityModule:
|
|
|
4003
4003
|
def data_preparation(self, titles, labels):
|
|
4004
4004
|
datasets = []
|
|
4005
4005
|
raw = []
|
|
4006
|
+
|
|
4006
4007
|
for title in titles:
|
|
4007
4008
|
tupled_title = (str(title))
|
|
4008
4009
|
datasets.append(tupled_title)
|
|
@@ -4025,6 +4026,7 @@ class ExplainabilityModule:
|
|
|
4025
4026
|
filled = int(value * max_width)
|
|
4026
4027
|
return '█' * filled + '░' * (max_width - filled)
|
|
4027
4028
|
|
|
4029
|
+
|
|
4028
4030
|
def _learn_from_feedback(self, text, correct_label, wrong_result, batch_size=2):
|
|
4029
4031
|
eps = 1e-5
|
|
4030
4032
|
print(f"\n[📚] Learning: '{text}' → {correct_label}...")
|
|
@@ -9872,6 +9874,7 @@ class IntegratedPipeline:
|
|
|
9872
9874
|
f"Unexpected memory type: {type(memory).__name__}",
|
|
9873
9875
|
"Clear and reinitialize memory")
|
|
9874
9876
|
|
|
9877
|
+
|
|
9875
9878
|
def k_fold_cross_validate(self, X, y, input_dim, n_classes, k=5, seed=42,
|
|
9876
9879
|
epochs=None, lr=None, log_to_diagnostics=True):
|
|
9877
9880
|
"""
|
|
@@ -13318,6 +13321,7 @@ class IntegratedPipeline:
|
|
|
13318
13321
|
raise Warning('[!] Dataset is None or empty! Make sure you provide a dataset or create it automatically.')
|
|
13319
13322
|
|
|
13320
13323
|
if not self.model2:
|
|
13324
|
+
print(datasets)
|
|
13321
13325
|
intents = [d[1] for d in datasets]
|
|
13322
13326
|
intent_to_id = {intent: i for i, intent in enumerate(sorted(set(intents)))}
|
|
13323
13327
|
num_classes = self._get_num_classes(label_map=label_map)
|
|
@@ -14505,6 +14509,7 @@ class AsyncResultQueue:
|
|
|
14505
14509
|
logger.debug(f"[=] Submitted request {request_id}: {texts}")
|
|
14506
14510
|
return request_id
|
|
14507
14511
|
|
|
14512
|
+
|
|
14508
14513
|
async def wait_for_result(self, request_id: str, timeout: int = 30) -> Dict:
|
|
14509
14514
|
"""
|
|
14510
14515
|
Wait for a specific request to complete.
|
|
@@ -16369,7 +16374,6 @@ class PipelineAsyncManager:
|
|
|
16369
16374
|
class PipelinePredictionManager:
|
|
16370
16375
|
def __init__(self, pipeline, label_csv='labels.csv', target_title='title', label='label'):
|
|
16371
16376
|
self.pipeline = pipeline
|
|
16372
|
-
|
|
16373
16377
|
try:
|
|
16374
16378
|
print("📖 Loading labels from text file...")
|
|
16375
16379
|
self.titles, self.y_raw, self.label_map = self.load_labels_from_csv(label_csv, target_title, label)
|
|
@@ -16490,8 +16494,10 @@ class PipelinePredictionManager:
|
|
|
16490
16494
|
X_gen = None
|
|
16491
16495
|
use_embedded = False
|
|
16492
16496
|
attn_weights = None
|
|
16497
|
+
|
|
16493
16498
|
trans_probs = None
|
|
16494
16499
|
mlp_probs = None
|
|
16500
|
+
target_probs = None
|
|
16495
16501
|
|
|
16496
16502
|
print(f"\n[🚀] Regular Prediction Initiated...")
|
|
16497
16503
|
self.pipeline.titles = titles
|
|
@@ -16508,6 +16514,30 @@ class PipelinePredictionManager:
|
|
|
16508
16514
|
_, y, _, _ = self.pipeline.mlp_training_features(rules, dataset)
|
|
16509
16515
|
else:
|
|
16510
16516
|
dataset, _ = self.pipeline.data_preparation(titles, label_map)
|
|
16517
|
+
|
|
16518
|
+
if X is not None or y is not None and isinstance(X, (np.ndarray, list)) and isinstance(y, (np.ndarray, list)) and len(X) > 0 and len(y) > 0:
|
|
16519
|
+
X_train, X_val, y_train, y_val = self._prepare_train_val_split(
|
|
16520
|
+
X, y, min_val_per_class=5, min_frac=0.1, max_frac=0.3
|
|
16521
|
+
)
|
|
16522
|
+
|
|
16523
|
+
onehot_validation = self.pipeline._validate_onehot(y_train)
|
|
16524
|
+
if onehot_validation:
|
|
16525
|
+
if num_classes != len(label_map):
|
|
16526
|
+
num_classes = len(label_map)
|
|
16527
|
+
if num_classes > np.max(y_train):
|
|
16528
|
+
y_train = np.eye(num_classes)[np.asarray(y_train)]
|
|
16529
|
+
y_val = np.eye(num_classes)[np.asarray(y_val)]
|
|
16530
|
+
else:
|
|
16531
|
+
print('[⚠️] Warning: Y onehot encoding fails, Returning y samples as is, This may cause Exploding Gradient in MLP Training!')
|
|
16532
|
+
y_train = y_train
|
|
16533
|
+
y_val = y_val
|
|
16534
|
+
|
|
16535
|
+
X_mean = X_train.mean(axis=0)
|
|
16536
|
+
X_std = X_train.std(axis=0) + 1e-8
|
|
16537
|
+
|
|
16538
|
+
X_train = (X_train - X_mean) / X_std
|
|
16539
|
+
X = (X_val - X_mean) / X_std
|
|
16540
|
+
y = y_val.copy()
|
|
16511
16541
|
|
|
16512
16542
|
if X_gen is not None:
|
|
16513
16543
|
self.pipeline.transformer_utilities(X_provided=X, X_raw=X_gen, y_true=y, rules=rules, datasets=dataset, label_map=label_map, batch_size=batch_size)
|
|
@@ -16860,6 +16890,7 @@ class PipelinePredictionManager:
|
|
|
16860
16890
|
self.pipeline.titles = titles
|
|
16861
16891
|
self.pipeline.labels = label_map
|
|
16862
16892
|
|
|
16893
|
+
num_classes = self.pipeline._get_num_classes(label_map=label_map)
|
|
16863
16894
|
try:
|
|
16864
16895
|
|
|
16865
16896
|
if titles is not None and rules is not None:
|
|
@@ -16871,10 +16902,34 @@ class PipelinePredictionManager:
|
|
|
16871
16902
|
else:
|
|
16872
16903
|
datasets, _ = self.pipeline.data_preparation(titles, label_map)
|
|
16873
16904
|
|
|
16905
|
+
if X is not None or y is not None and len(X) > 0 and len(y) > 0:
|
|
16906
|
+
X_train, X_val, y_train, y_val = self._prepare_train_val_split(
|
|
16907
|
+
X, y, min_val_per_class=5, min_frac=0.1, max_frac=0.3
|
|
16908
|
+
)
|
|
16909
|
+
|
|
16910
|
+
onehot_validation = self.pipeline._validate_onehot(y_train)
|
|
16911
|
+
if onehot_validation:
|
|
16912
|
+
if num_classes != len(label_map):
|
|
16913
|
+
num_classes = len(label_map)
|
|
16914
|
+
if num_classes > np.max(y_train):
|
|
16915
|
+
y_train = np.eye(num_classes)[np.asarray(y_train)]
|
|
16916
|
+
y_val = np.eye(num_classes)[np.asarray(y_val)]
|
|
16917
|
+
else:
|
|
16918
|
+
print('[⚠️] Warning: Y onehot encoding fails, Returning y samples as is, This may cause Exploding Gradient in MLP Training!')
|
|
16919
|
+
y_train = y_train
|
|
16920
|
+
y_val = y_val
|
|
16921
|
+
|
|
16922
|
+
X_mean = X_train.mean(axis=0)
|
|
16923
|
+
X_std = X_train.std(axis=0) + 1e-8
|
|
16924
|
+
|
|
16925
|
+
X_train = (X_train - X_mean) / X_std
|
|
16926
|
+
X = (X_val - X_mean) / X_std
|
|
16927
|
+
y = y_val.copy()
|
|
16928
|
+
|
|
16874
16929
|
if X_gen is not None:
|
|
16875
|
-
self.pipeline.transformer_utilities(X_provided=
|
|
16930
|
+
self.pipeline.transformer_utilities(X_provided=X_train, X_raw=X_gen, y_true=y_train, rules=rules, datasets=dataset, label_map=label_map, batch_size=batch_size)
|
|
16876
16931
|
else:
|
|
16877
|
-
self.pipeline.transformer_utilities(X_provided=
|
|
16932
|
+
self.pipeline.transformer_utilities(X_provided=X_train, X_raw=X, y_true=y_train, rules=rules, datasets=dataset, label_map=label_map, batch_size=batch_size)
|
|
16878
16933
|
|
|
16879
16934
|
reverse_map = {v: k for k, v in label_map.items()}
|
|
16880
16935
|
|
|
@@ -17395,7 +17450,7 @@ class PipelinePredictionManager:
|
|
|
17395
17450
|
signals.append(f'AME={AME:.3f}')
|
|
17396
17451
|
|
|
17397
17452
|
if error_counts is not None and len(error_counts) > 0:
|
|
17398
|
-
#
|
|
17453
|
+
# max: catches localized single-class failure
|
|
17399
17454
|
# that a flat average would dilute away
|
|
17400
17455
|
worst_class_idx = int(np.argmax(error_counts))
|
|
17401
17456
|
max_error = float(error_counts[worst_class_idx])
|
|
@@ -17434,6 +17489,7 @@ class PipelinePredictionManager:
|
|
|
17434
17489
|
AME = None
|
|
17435
17490
|
use_embedded = False
|
|
17436
17491
|
dataset = None
|
|
17492
|
+
target_probs = None
|
|
17437
17493
|
|
|
17438
17494
|
X_gen = None
|
|
17439
17495
|
sec_chosen_label = None
|
|
@@ -17661,6 +17717,7 @@ class PipelinePredictionManager:
|
|
|
17661
17717
|
return result, cached['prediction'], cached['confidence']
|
|
17662
17718
|
else:
|
|
17663
17719
|
print(f'[!] Similarity: {cached['similarity']} is low, Cannot pick label due to low certainty, Initiating advanced prediction...')
|
|
17720
|
+
target_probs = mlp_probs.copy()
|
|
17664
17721
|
else:
|
|
17665
17722
|
print('[=] No verified output from cache available that matched samples, starting advanced prediction...')
|
|
17666
17723
|
if self.pipeline.use_transformer:
|
|
@@ -17669,7 +17726,7 @@ class PipelinePredictionManager:
|
|
|
17669
17726
|
|
|
17670
17727
|
target_probs = self.pipeline.predict_proba(input_ids, X, type='Hybrid', embedded=use_embedded)
|
|
17671
17728
|
else:
|
|
17672
|
-
target_probs = mlp_probs
|
|
17729
|
+
target_probs = mlp_probs.copy()
|
|
17673
17730
|
|
|
17674
17731
|
target_probs = target_probs[:mlp_probs.shape[0], :mlp_probs.shape[1]]
|
|
17675
17732
|
target_probs = self.pipeline.model3.continuous_predictive_correction(self, target_probs, mlp_pred_indices)
|
|
@@ -18025,7 +18082,6 @@ class PipelinePredictionManager:
|
|
|
18025
18082
|
if titles is not None and len(titles) > 0:
|
|
18026
18083
|
correct, sec_correct = self.display_hybrid_results(payload, final_class_idx, results, top_k, verbose=True)
|
|
18027
18084
|
|
|
18028
|
-
|
|
18029
18085
|
return results, chosen_label, confidence
|
|
18030
18086
|
|
|
18031
18087
|
else:
|
|
@@ -18312,7 +18368,7 @@ class PipelinePredictionManager:
|
|
|
18312
18368
|
print(f'[⚡] Final Prediction: {chosen_label} with confidence: {confidence:.1%}')
|
|
18313
18369
|
chosen_label = chosen_label
|
|
18314
18370
|
|
|
18315
|
-
|
|
18371
|
+
self.pipeline.evaluate_mlp_performance(X, y, self.label_map)
|
|
18316
18372
|
# delete pipelines cache
|
|
18317
18373
|
print('[🔍] Pipelines Cache Cleaned!')
|
|
18318
18374
|
self.pipeline.cache.clear()
|
|
@@ -18374,10 +18430,7 @@ class PipelinePredictionManager:
|
|
|
18374
18430
|
|
|
18375
18431
|
except Exception as e:
|
|
18376
18432
|
print(f'[!] Cant check and calibrate probs based on penalty due to: {e}')
|
|
18377
|
-
traceback.print_exc()
|
|
18378
18433
|
|
|
18379
|
-
|
|
18380
|
-
|
|
18381
18434
|
return final_probs
|
|
18382
18435
|
|
|
18383
18436
|
|