AbstractIntegratedModule 0.6.0__tar.gz → 0.6.2__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.
Files changed (21) hide show
  1. abstractintegratedmodule-0.6.2/AbstractIntegratedModule.cp313-win_amd64.pyd +0 -0
  2. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractIntegratedModule.cpython-310-aarch64-linux-gnu.so +0 -0
  3. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractIntegratedModule.cpython-312-x86_64-linux-gnu.so +0 -0
  4. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2/AbstractIntegratedModule.egg-info}/PKG-INFO +5 -9
  5. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractIntegratedModule.py +49 -24
  6. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractOptimizedModules.c +152 -152
  7. {abstractintegratedmodule-0.6.0/AbstractIntegratedModule.egg-info → abstractintegratedmodule-0.6.2}/PKG-INFO +5 -9
  8. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/README.md +4 -8
  9. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/setup.py +1 -1
  10. abstractintegratedmodule-0.6.0/AbstractIntegratedModule.cp313-win_amd64.pyd +0 -0
  11. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractIntegratedModule.egg-info/SOURCES.txt +0 -0
  12. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractIntegratedModule.egg-info/dependency_links.txt +0 -0
  13. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractIntegratedModule.egg-info/requires.txt +0 -0
  14. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractIntegratedModule.egg-info/top_level.txt +0 -0
  15. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractOptimizedModules.cp313-win_amd64.pyd +0 -0
  16. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractOptimizedModules.cpython-310-aarch64-linux-gnu.so +0 -0
  17. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractOptimizedModules.cpython-312-x86_64-linux-gnu.so +0 -0
  18. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/AbstractOptimizedModules.pyx +0 -0
  19. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/MANIFEST.in +0 -0
  20. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/pyproject.toml +0 -0
  21. {abstractintegratedmodule-0.6.0 → abstractintegratedmodule-0.6.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: AbstractIntegratedModule
3
- Version: 0.6.0
3
+ Version: 0.6.2
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.6.0 Official Release.
45
+ - Development Stage: 0.6.2 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.
@@ -67,14 +67,10 @@ https://github.com/Micro-Novelty/IntegratedPipeline-Specialized-Non-LLM-AI-Agent
67
67
  - Robust Advanced prediction capabilities proven effective on ARM64 Using MLP + LSTM Architectures.
68
68
  - Transformer Modules Optimized using Cython, to reduce Memory overhead and Reduce CPU Usage, With Reduced Training Time.
69
69
  - Changelog:
70
- - v0.6.0:
70
+ - v0.6.2:
71
71
  - [=] New features:
72
- - Added Anisotropy measurement optimization in Cython to handle complex logic.
73
- - Added Cython softmax for Transformer to reduce CPU consumption.
74
- - Added Cython Cosine similarity to reduce ensemble prediction time needed for prediction.
75
- - Added safety guards for Cosine similarity to prevent string arrays to cause further errors.
76
- - Refined csv load labels function to accept path dir, so users can finnaly find their Training labels without much restrictions and errors.
77
-
72
+ - Ensure proper shape handling before shape alignment in Transformer Training.
73
+ - Fixed Silent bugs that can cause single scalar to bypass shape conditions gate in training step for Transformer.
78
74
 
79
75
  -----
80
76
 
@@ -1226,8 +1226,6 @@ class Transformer:
1226
1226
 
1227
1227
  AME = self.AME_Encoder(input_ids_list)
1228
1228
 
1229
-
1230
-
1231
1229
  # precompute LR schedule once
1232
1230
  lr_schedule = [
1233
1231
  self.learning_rate_warm_up(e, epochs, lr, schedule)
@@ -1237,24 +1235,36 @@ class Transformer:
1237
1235
  print(f"[==] Starting comprehensive training for {epochs} epochs with mode: {mode}, learning rate: {lr}, schedule: {schedule}")
1238
1236
 
1239
1237
  for y in y_true_list:
1240
- y_arr = np.asarray(y)
1241
- if y_arr.ndim == 1:
1242
- y_arr = y_arr[np.newaxis, :]
1238
+ y_arr = np.asarray(y, dtype=np.float64)
1239
+
1240
+ # normalize to exactly 2D before smoothing
1241
+ if y_arr.ndim == 0:
1242
+ y_arr = y_arr.reshape(1, 1)
1243
+ elif y_arr.ndim == 1:
1244
+ y_arr = y_arr.reshape(1, -1)
1245
+ elif y_arr.ndim > 2:
1246
+ y_arr = y_arr.reshape(-1, y_arr.shape[-1])
1247
+
1243
1248
  smoothed = self.smoothing_labels_utility(y_arr, smoothing=0.1)
1244
- # guarantee 2D output
1245
- while smoothed.ndim > 2:
1246
- smoothed = smoothed.squeeze(0)
1249
+
1250
+ # guarantee 2D output regardless of what smoothing returns
1251
+ smoothed = np.asarray(smoothed, dtype=np.float64)
1252
+ if smoothed.ndim == 0:
1253
+ smoothed = smoothed.reshape(1, 1)
1254
+ elif smoothed.ndim == 1:
1255
+ smoothed = smoothed.reshape(1, -1)
1256
+ elif smoothed.ndim > 2:
1257
+ smoothed = smoothed.reshape(-1, smoothed.shape[-1])
1258
+
1247
1259
  y_true_smoothed_list.append(smoothed)
1248
1260
 
1249
1261
  for epoch in range(epochs):
1250
1262
  epoch_losses = []
1251
1263
  epoch_accs = []
1252
-
1253
- # FIX 2 — lookup instead of compute
1264
+
1254
1265
  current_lr = lr_schedule[epoch]
1255
1266
  self.alpha = min(1.0, epoch / 100)
1256
1267
 
1257
- # FIX 1 — pass precomputed smooth labels
1258
1268
  for input_ids, y_true, y_true_smooth in zip(
1259
1269
  input_ids_list, y_true_list, y_true_smoothed_list
1260
1270
  ):
@@ -1283,10 +1293,9 @@ class Transformer:
1283
1293
 
1284
1294
  return losses, accs
1285
1295
 
1286
-
1287
1296
  def train_step(self, input_ids, epoch, y_true, lr=0.01, AME=None,
1288
1297
  mode=None, embedded=False, max_norm=1.0,
1289
- pad_token_id=0, y_true_smooth=None):
1298
+ pad_token_id=0, y_true_smooth=None):
1290
1299
 
1291
1300
  y_true = np.asarray(y_true)
1292
1301
  if len(y_true.shape) < 2:
@@ -1304,25 +1313,41 @@ class Transformer:
1304
1313
  ffn_dropout=self.ffn_dropout_rate
1305
1314
  )
1306
1315
 
1307
- # only compute if not precomputed
1316
+ # comprehensive shape normalization before any use
1308
1317
  if y_true_smooth is not None:
1309
- y_true_smooth = np.asarray(y_true_smooth)
1310
- # squeeze out any extra leading dimensions
1318
+ y_true_smooth = np.asarray(y_true_smooth, dtype=np.float64)
1319
+
1320
+ # handle 0-d scalar — expand to (1, 1)
1321
+ if y_true_smooth.ndim == 0:
1322
+ print(f'[!] y_true_smooth was scalar ({float(y_true_smooth):.4f}) — recomputing')
1323
+ y_true_smooth = self.smoothing_labels_utility(y_true, smoothing=0.1)
1324
+
1325
+ # squeeze extra leading dims safely
1311
1326
  while y_true_smooth.ndim > 2:
1312
1327
  y_true_smooth = y_true_smooth.squeeze(0)
1328
+
1313
1329
  # ensure at least 2D
1314
1330
  if y_true_smooth.ndim == 1:
1315
1331
  y_true_smooth = y_true_smooth[np.newaxis, :]
1316
1332
 
1317
- # shape alignment
1318
- if y_true_smooth.shape[0] and y_true_smooth.shape[1] != probs.shape[1]:
1333
+ # final sanity — if still not 2D something is deeply wrong
1334
+ if y_true_smooth.ndim != 2:
1335
+ print(f'[!] y_true_smooth shape {y_true_smooth.shape} unrecoverable — recomputing')
1336
+ y_true_smooth = self.smoothing_labels_utility(y_true, smoothing=0.1)
1337
+
1338
+ else:
1339
+ # compute fresh
1340
+ y_true_smooth = self.smoothing_labels_utility(y_true, smoothing=0.1)
1341
+
1342
+ # shape alignment, y_true_smooth guaranteed 2D
1343
+ if y_true_smooth.shape[1] != probs.shape[1]:
1319
1344
  if y_true_smooth.shape[1] > probs.shape[1]:
1320
1345
  y_true_smooth = y_true_smooth[:, :probs.shape[1]]
1321
1346
  y_true = y_true[:, :probs.shape[1]]
1322
1347
  else:
1323
- pad = probs.shape[1] - y_true_smooth.shape[1]
1324
- y_true_smooth = np.pad(y_true_smooth, ((0,0),(0,pad)))
1325
- y_true = np.pad(y_true, ((0,0),(0,pad)))
1348
+ pad = probs.shape[1] - y_true_smooth.shape[1]
1349
+ y_true_smooth = np.pad(y_true_smooth, ((0, 0), (0, pad)))
1350
+ y_true = np.pad(y_true, ((0, 0), (0, pad)))
1326
1351
 
1327
1352
  loss = -np.mean(np.sum(y_true_smooth * np.log(probs + 1e-8), axis=1))
1328
1353
  d_logits = (probs - y_true_smooth) / y_true_smooth.shape[0]
@@ -1334,11 +1359,11 @@ class Transformer:
1334
1359
 
1335
1360
  preds = np.argmax(probs, axis=1)
1336
1361
  true = np.argmax(y_true, axis=1)
1337
- acc = np.mean(preds == true)
1362
+ acc = float(np.mean(preds == true))
1338
1363
 
1339
1364
  return loss, acc
1340
1365
 
1341
-
1366
+
1342
1367
 
1343
1368
  def predict(self, input_ids, embedded=False):
1344
1369
  if not embedded and input_ids.ndim == 1:
@@ -12969,7 +12994,7 @@ class PipelinePredictionManager:
12969
12994
  calibration_weighting = calibration[target_class_idx] if target_class_idx < len(calibration) else 0.0
12970
12995
 
12971
12996
  # Weighted blend: calibration_weighting * calibrated + (1-weight) * mlp
12972
- if lstm_weight is not None:
12997
+ if lstm_confidence is not None and lstm_weight is not None:
12973
12998
  final_probs = mlp_weight * target_probs[i][:len(calibration)] + trans_weight * calibration[i][:len(calibration)] + lstm_weight * calibration[i][:len(calibration)]
12974
12999
  else:
12975
13000
  final_probs = mlp_weight * target_probs[i][:len(calibration)] + trans_weight * calibration[i][:len(calibration)]