Skip to content

Commit b031f1c

Browse files
committed
fix customize_embeddings.py
Signed-off-by: Mystic-Slice <vaashwath@gmail.com>
1 parent 98e233e commit b031f1c

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

customize/customize_embeddings.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
# Sentence transformer model HF
3535
model_path = 'models/all-MiniLM-L6-v2'
36-
model_id = model_path.split("/")[1]
36+
model_id = model_path.split("/")[1].lower()
3737

3838
# INPUT FILE
3939
# Default file with empty embeddings
@@ -43,13 +43,15 @@
4343
# OUTPUT FILE
4444
json_out_file_name = f'{json_in_file_name}-{model_id}.json'
4545

46+
print(f'Loading existing data')
47+
existing_data = None
4648
# check if the output file already exists
4749
if os.path.exists(json_out_file_name):
4850
try:
4951
# Load existing data from the output file
5052
existing_data = customize_helper.load_json(json_out_file_name)
5153
except Exception as e:
52-
existing_data = None
54+
print(f"Error loading existing data: {e}")
5355

5456
# hashmap
5557
prompts_embeddings = {}
@@ -62,8 +64,10 @@
6264
prompts_embeddings[p["text"]] = p["embedding"]
6365

6466

65-
67+
print("Populating embeddings and centroids")
6668
prompt_json = json.load(open(json_in_file))
6769
prompt_json_embeddings = customize_helper.populate_embeddings(prompt_json, model_path, prompts_embeddings)
6870
prompt_json_centroids = customize_helper.populate_centroids(prompt_json_embeddings)
71+
72+
print("Saving the embeddings")
6973
customize_helper.save_json(prompt_json_centroids, json_out_file_name)

0 commit comments

Comments
 (0)