Commit a8f42b41 authored by 赵威's avatar 赵威

retrain

parent 876f7a6d
......@@ -87,29 +87,24 @@ if __name__ == "__main__":
index.add_with_ids(tractate_embeddings, tractate_ids)
print("trained: " + str(index.is_trained))
# index2 = faiss.IndexIDMap(index)
# index2.add_with_ids(tractate_embeddings, tractate_ids)
# print("trained: " + str(index2.is_trained))
# print("total index: " + str(index2.ntotal))
# base_dir = os.getcwd()
# model_dir = os.path.join(base_dir, "_models")
# index_path = os.path.join(model_dir, "faiss_personas_vector.index")
# faiss.write_index(index2, index_path)
# print(index_path)
base_dir = os.getcwd()
model_dir = os.path.join(base_dir, "_models")
index_path = os.path.join(model_dir, "faiss_personas_vector.index")
faiss.write_index(index, index_path)
print(index_path)
# device vector
for _, row in device_tags_df.iterrows():
vecs = []
for i in row["business_tags"]:
# vec = tags_vector_dict.get(i, np.array([]))
vec = tags_vector_dict.get(i)
if vec:
vecs.append(np.array(json.loads(vec)).astype("float32"))
if vecs:
t = np.array([np.average(vecs, axis=0)]).astype("float32")
D, I = index.search(t, 10)
print(row["cl_id"], row["business_tags"])
print(I)
# for _, row in device_tags_df.iterrows():
# vecs = []
# for i in row["business_tags"]:
# # vec = tags_vector_dict.get(i, np.array([]))
# vec = tags_vector_dict.get(i)
# if vec:
# vecs.append(np.array(json.loads(vec)).astype("float32"))
# if vecs:
# t = np.array([np.average(vecs, axis=0)]).astype("float32")
# D, I = index.search(t, 10)
# print(row["cl_id"], row["business_tags"])
# print(I)
# curl "http://172.16.31.17:9000/gm-dbmw-tractate-read/_search?pretty" -d '{"query": {"term": {"id": "10269"}}, "_source": {"include": ["content", "portrait_tag_name"]}}'
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