AbstractIntegratedModule 0.8.4__tar.gz → 0.8.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-0.8.4 → abstractintegratedmodule-0.8.5}/AbstractIntegratedModule.egg-info/PKG-INFO +4 -5
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/AbstractIntegratedModule.py +102 -67
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/AbstractOptimizedModules.c +2860 -1143
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/AbstractOptimizedModules.pyx +140 -1
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/PKG-INFO +4 -5
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/README.md +3 -4
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/setup.py +1 -1
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/MANIFEST.in +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/abstract_model_storage/Cargo.toml +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/abstract_model_storage/pyproject.toml +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/abstract_model_storage/src/lib.rs +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/abstract_model_storage/target/debug/build/libsqlite3-sys-ed07b882cd2aa5e2/out/bindgen.rs +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/abstract_model_storage/target/debug/build/serde_core-ebc15f2e9cad7f5f/out/private.rs +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/abstract_model_storage/target/debug/build/target-lexicon-08527f45de28143d/out/host.rs +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/abstract_model_storage/target/release/build/libsqlite3-sys-bf0400df4523274c/out/bindgen.rs +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/abstract_model_storage/target/release/build/serde_core-5cdb76131825e4af/out/private.rs +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/abstract_model_storage/target/release/build/target-lexicon-43eb95a0588bf457/out/host.rs +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/pyproject.toml +0 -0
- {abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: AbstractIntegratedModule
|
|
3
|
-
Version: 0.8.
|
|
3
|
+
Version: 0.8.5
|
|
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.8.
|
|
45
|
+
- Development Stage: 0.8.5 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.
|
|
@@ -80,10 +80,9 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
|
|
|
80
80
|
- Transformer Optimized using Cython, to reduce Memory overhead and Reduce CPU Usage, With Reduced Training Time.
|
|
81
81
|
______________
|
|
82
82
|
- Changelog:
|
|
83
|
-
- v0.8.
|
|
83
|
+
- v0.8.5:
|
|
84
84
|
- [=] New features:
|
|
85
|
-
- Added
|
|
86
|
-
- Added improvements for handling batch prediction responses, ensuring robust references and graceful conditions for edge cases.
|
|
85
|
+
- Added new Optimization module using Cython maths for dynamic weighted ensemble function.
|
|
87
86
|
- Fixed P2P Vulnerabilities:
|
|
88
87
|
- Empty allowed_ips in PRODUCTION/HARDENED mode now DENIES external IPs instead of allowing all
|
|
89
88
|
- Startup validation warns about dangerous config combinations
|
{abstractintegratedmodule-0.8.4 → abstractintegratedmodule-0.8.5}/AbstractIntegratedModule.py
RENAMED
|
@@ -61,7 +61,8 @@ try:
|
|
|
61
61
|
optimized_ame_encoder,
|
|
62
62
|
optimized_anisotropy,
|
|
63
63
|
optimized_cosine_similarity,
|
|
64
|
-
optimized_softmax_2d
|
|
64
|
+
optimized_softmax_2d,
|
|
65
|
+
optimized_dynamic_weighted_ensemble
|
|
65
66
|
)
|
|
66
67
|
_OPT_AVAILABLE = True
|
|
67
68
|
print('[=] Cython acceleration loaded ✅')
|
|
@@ -3020,82 +3021,116 @@ class WeightedEnsemblePredictor:
|
|
|
3020
3021
|
|
|
3021
3022
|
return anisotropy
|
|
3022
3023
|
|
|
3023
|
-
def _dynamic_weighted_ensemble(self, trans_probs, mlp_probs, attn_weights,
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3024
|
+
def _dynamic_weighted_ensemble(self, trans_probs, mlp_probs, attn_weights,
|
|
3025
|
+
input_ids, lstm_probs=None, lstm_weight_hint=0.0):
|
|
3026
|
+
# normalize all inputs to guaranteed 2D float64
|
|
3027
3027
|
try:
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
n_lstm_classes = lstm_probs.shape[1]
|
|
3031
|
-
except:
|
|
3032
|
-
n_trans_classes = trans_probs.shape[-1]
|
|
3033
|
-
n_mlp_classes = mlp_probs.shape[-1]
|
|
3034
|
-
n_lstm_classes = lstm_probs.shape[-1]
|
|
3028
|
+
trans_probs = np.asarray(trans_probs, dtype=np.float64)
|
|
3029
|
+
mlp_probs = np.asarray(mlp_probs, dtype=np.float64)
|
|
3035
3030
|
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
print(f"🔄 Aligning classes: {n_trans_classes} and {n_mlp_classes} → {n_classes}")
|
|
3039
|
-
ensemble = np.zeros((batch_size, n_classes))
|
|
3040
|
-
for i in range(batch_size):
|
|
3041
|
-
trans_row = np.zeros(n_classes)
|
|
3042
|
-
mlp_row = np.zeros(n_classes)
|
|
3043
|
-
|
|
3044
|
-
trans_row[:n_trans_classes] = trans_probs[i]
|
|
3045
|
-
mlp_row[:n_mlp_classes] = mlp_probs[i]
|
|
3046
|
-
|
|
3047
|
-
trans_row = trans_row / (trans_row.sum() + 1e-8)
|
|
3048
|
-
mlp_row = mlp_row / (mlp_row.sum() + 1e-8)
|
|
3049
|
-
|
|
3050
|
-
trans_pred = np.argmax(trans_probs[i])
|
|
3051
|
-
mlp_pred = np.argmax(mlp_probs[i])
|
|
3052
|
-
agreement = 1.0 if trans_pred == mlp_pred else 0.3
|
|
3031
|
+
if trans_probs.ndim == 1: trans_probs = trans_probs[np.newaxis, :]
|
|
3032
|
+
if mlp_probs.ndim == 1: mlp_probs = mlp_probs[np.newaxis, :]
|
|
3053
3033
|
|
|
3054
|
-
|
|
3055
|
-
print('🔄 Sophisticated confidence assembling')
|
|
3056
|
-
attn = attn_weights[i]
|
|
3057
|
-
anisotropy = self.anisotropy_measurement(attn)
|
|
3034
|
+
B = trans_probs.shape[0]
|
|
3058
3035
|
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
attn_limit = (1.0 - attn_focus + attn_growth) * anisotropy
|
|
3036
|
+
n_trans = trans_probs.shape[1]
|
|
3037
|
+
n_mlp = mlp_probs.shape[1]
|
|
3062
3038
|
|
|
3063
|
-
|
|
3039
|
+
has_lstm = lstm_probs is not None
|
|
3040
|
+
if has_lstm:
|
|
3041
|
+
lstm_probs = np.asarray(lstm_probs, dtype=np.float64)
|
|
3042
|
+
if lstm_probs.ndim == 1: lstm_probs = lstm_probs[np.newaxis, :]
|
|
3043
|
+
n_lstm = lstm_probs.shape[1]
|
|
3064
3044
|
else:
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
trans_conf_factor = attn_growth * anisotropy
|
|
3045
|
+
lstm_probs = np.zeros((B, 1), dtype=np.float64) # dummy, not used
|
|
3046
|
+
n_lstm = 0
|
|
3068
3047
|
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
trans_weight = trans_conf_factor * (1.0 + agreement) / 2
|
|
3073
|
-
mlp_weight = mlp_conf_factor * (1.0 + agreement) / 2
|
|
3048
|
+
n_classes = max(n_trans, n_mlp, n_lstm)
|
|
3049
|
+
print(f"🔄 Aligning classes: trans={n_trans} mlp={n_mlp} "
|
|
3050
|
+
f"lstm={n_lstm} → {n_classes}")
|
|
3074
3051
|
|
|
3075
|
-
if
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3052
|
+
if attn_weights is not None:
|
|
3053
|
+
attn_arr = np.asarray(attn_weights, dtype=np.float64)
|
|
3054
|
+
attn_flat = attn_arr.reshape(B, -1) if attn_arr.ndim > 1 \
|
|
3055
|
+
else np.tile(attn_arr.ravel(), (B, 1))
|
|
3056
|
+
else:
|
|
3057
|
+
attn_flat = np.full((B, 1), 0.5, dtype=np.float64)
|
|
3079
3058
|
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3059
|
+
# per-sample lstm_weight_hints
|
|
3060
|
+
if isinstance(lstm_weight_hint, (int, float)):
|
|
3061
|
+
lstm_weight_hints = np.full(B, float(lstm_weight_hint), dtype=np.float64)
|
|
3062
|
+
else:
|
|
3063
|
+
lstm_weight_hints = np.asarray(lstm_weight_hint, dtype=np.float64)
|
|
3064
|
+
if lstm_weight_hints.ndim == 0:
|
|
3065
|
+
lstm_weight_hints = np.full(B, float(lstm_weight_hints))
|
|
3066
|
+
|
|
3067
|
+
|
|
3068
|
+
if _OPT_AVAILABLE:
|
|
3069
|
+
try:
|
|
3070
|
+
print('[+] Using Optimized Dynamic weighted ensemble Method.')
|
|
3071
|
+
return optimized_dynamic_weighted_ensemble(
|
|
3072
|
+
np.ascontiguousarray(trans_probs),
|
|
3073
|
+
np.ascontiguousarray(mlp_probs),
|
|
3074
|
+
np.ascontiguousarray(attn_flat),
|
|
3075
|
+
np.ascontiguousarray(lstm_probs),
|
|
3076
|
+
np.ascontiguousarray(lstm_weight_hints),
|
|
3077
|
+
float(self.pipeline.confidence_threshold),
|
|
3078
|
+
has_lstm
|
|
3079
|
+
)
|
|
3080
|
+
except Exception as e:
|
|
3081
|
+
print(f'[=] Error in optimized dynamic weighted ensemble: {e}, using regular dynamic ensemble method.')
|
|
3082
|
+
pass
|
|
3083
|
+
|
|
3084
|
+
# pure Python fallback
|
|
3085
|
+
ensemble = np.zeros((B, n_classes))
|
|
3086
|
+
for i in range(B):
|
|
3087
|
+
trans_row = np.zeros(n_classes)
|
|
3088
|
+
mlp_row = np.zeros(n_classes)
|
|
3089
|
+
trans_row[:n_trans] = trans_probs[i]
|
|
3090
|
+
mlp_row[:n_mlp] = mlp_probs[i]
|
|
3091
|
+
trans_row /= trans_row.sum() + 1e-8
|
|
3092
|
+
mlp_row /= mlp_row.sum() + 1e-8
|
|
3093
|
+
|
|
3094
|
+
trans_pred = int(np.argmax(trans_probs[i]))
|
|
3095
|
+
mlp_pred = int(np.argmax(mlp_probs[i]))
|
|
3096
|
+
agreement = 1.0 if trans_pred == mlp_pred else 0.3
|
|
3097
|
+
|
|
3098
|
+
attn = attn_flat[i]
|
|
3099
|
+
attn_focus = float(np.std(attn)) if attn.size > 1 else 0.5
|
|
3100
|
+
attn_growth = 1.0 / (1.0 + np.exp(-attn_focus))
|
|
3101
|
+
anisotropy = self.anisotropy_measurement(attn.reshape(1, -1))
|
|
3102
|
+
attn_limit = (1.0 - attn_focus + attn_growth) * anisotropy
|
|
3103
|
+
trans_cf = attn_growth + attn_limit * attn_focus
|
|
3104
|
+
|
|
3105
|
+
mlp_entropy = -np.sum(mlp_probs[i] * np.log(mlp_probs[i] + 1e-8))
|
|
3106
|
+
mlp_cf = 1.0 / (1.0 + mlp_entropy)
|
|
3107
|
+
|
|
3108
|
+
tw = trans_cf * (1.0 + agreement) / 2.0
|
|
3109
|
+
mw = mlp_cf * (1.0 + agreement) / 2.0
|
|
3110
|
+
|
|
3111
|
+
if has_lstm:
|
|
3112
|
+
lstm_row = np.zeros(n_classes)
|
|
3113
|
+
lstm_row[:n_lstm] = lstm_probs[i]
|
|
3114
|
+
lstm_row /= lstm_row.sum() + 1e-8
|
|
3115
|
+
lstm_pred = int(np.argmax(lstm_probs[i]))
|
|
3116
|
+
la = 1.0 if (lstm_pred == trans_pred or lstm_pred == mlp_pred) \
|
|
3117
|
+
else self.pipeline.confidence_threshold
|
|
3118
|
+
lw = float(lstm_weight_hints[i]) * (1.0 + la) / 2.0
|
|
3119
|
+
total = tw + mw + lw + 1e-8
|
|
3120
|
+
ensemble[i] = (tw/total) * trans_row + \
|
|
3121
|
+
(mw/total) * mlp_row + \
|
|
3122
|
+
(lw/total) * lstm_row
|
|
3123
|
+
else:
|
|
3124
|
+
total = tw + mw + 1e-8
|
|
3125
|
+
ensemble[i] = (tw/total) * trans_row + (mw/total) * mlp_row
|
|
3126
|
+
|
|
3127
|
+
return ensemble
|
|
3128
|
+
|
|
3129
|
+
except Exception as e:
|
|
3130
|
+
print(f'[!] Cant do ensemble prediction due ensemble prediction due to: {e}, returning MLP probabilities')
|
|
3131
|
+
return mlp_probs.copy()
|
|
3084
3132
|
|
|
3085
|
-
total = trans_weight + mlp_weight + lstm_weight + 1e-8
|
|
3086
|
-
trans_weight /= total
|
|
3087
|
-
mlp_weight /= total
|
|
3088
|
-
lstm_weight /= total
|
|
3089
3133
|
|
|
3090
|
-
ensemble[i] = trans_weight * trans_row + mlp_weight * mlp_row + lstm_weight * lstm_row
|
|
3091
|
-
else:
|
|
3092
|
-
# original two-model path — unchanged
|
|
3093
|
-
total = trans_weight + mlp_weight + 1e-8
|
|
3094
|
-
trans_weight /= total
|
|
3095
|
-
mlp_weight /= total
|
|
3096
|
-
ensemble[i] = trans_weight * trans_row + mlp_weight * mlp_row
|
|
3097
|
-
|
|
3098
|
-
return ensemble
|
|
3099
3134
|
|
|
3100
3135
|
def _attention_weighted_ensemble(self, trans_probs, mlp_probs, attn_weights):
|
|
3101
3136
|
|
|
@@ -13575,7 +13610,7 @@ class PipelineAsyncManager:
|
|
|
13575
13610
|
else:
|
|
13576
13611
|
print(f"[❌] INCORRECT LABEL (expected: {expected})")
|
|
13577
13612
|
|
|
13578
|
-
predicted_output.append(f'{text} -> {predicted_label} With {confidence} Confidence')
|
|
13613
|
+
predicted_output.append(f'{text} -> {predicted_label} With {confidence:.1%} Confidence')
|
|
13579
13614
|
|
|
13580
13615
|
# Get stats
|
|
13581
13616
|
print(f"[=] Stats: {self.get_stats()}")
|