Commit a45d3de3 authored by 赵威's avatar 赵威

update method

parent 8249f3d9
......@@ -10,9 +10,9 @@ import faiss
import numpy as np
import pandas as pd
from gensim.models import Word2Vec, word2vec
from utils.cache import redis_client_db
from utils.defs import nth_element
from utils.files import get_df
from utils.cache import redis_client_db
def device_tractate_fe():
......@@ -80,7 +80,9 @@ if __name__ == "__main__":
tractate_embeddings = np.array(list(tractate_vector_dict.values())).astype("float32")
# index = faiss.IndexFlatL2(tractate_embeddings.shape[1])
index= faiss.IndexIVFFlat(tractate_embeddings.shape[1])
quantizer = faiss.IndexFlatL2(tractate_embeddings.shape[1])
index = faiss.IndexIVFFlat(quantizer, tractate_embeddings.shape[1], 100, faiss.METRIC_L2)
print("trained: " + str(index.is_trained))
index2 = faiss.IndexIDMap(index)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment