Browse Source

Update embedding_manager: raise exception if emb size mismatches

StrayWarrior 5 months ago
parent
commit
e0e8f8f38f
1 changed files with 2 additions and 0 deletions
  1. 2 0
      applications/embedding_manager.py

+ 2 - 0
applications/embedding_manager.py

@@ -86,6 +86,8 @@ class EmbeddingManager:
                     new_texts_ori_idx.append(idx)
 
         new_embeddings = self.model.get_embeddings(new_texts)
+        if new_embeddings.shape[0] > 0 and new_embeddings.shape[1] != self.emb_size:
+            raise Exception("Embedding size mismatch")
 
         # Generate embedding if not found in cache
         with self.lock:  # Ensure thread-safe access