Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(llm): change vid embedding x:yy to yy & use multi-thread #158

Merged
merged 8 commits into from
Jan 15, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def __init__(self, embedding: BaseEmbedding):
self.vid_index = VectorIndex.from_index_file(self.index_dir)
self.embedding = embedding

def extract_names(self, vertices: list[str]) -> list[str]:
return [v.split(":")[1] for v in vertices]
MrJs133 marked this conversation as resolved.
Show resolved Hide resolved

def run(self, context: Dict[str, Any]) -> Dict[str, Any]:
past_vids = self.vid_index.properties
# TODO: We should build vid vector index separately, especially when the vertices may be very large
Expand All @@ -40,8 +43,10 @@ def run(self, context: Dict[str, Any]) -> Dict[str, Any]:
removed_num = self.vid_index.remove(removed_vids)
added_vids = list(set(present_vids) - set(past_vids))
if len(added_vids) > 0:
log.debug("Building vector index for %s vertices...", len(added_vids))
added_embeddings = [self.embedding.get_text_embedding(v) for v in tqdm(added_vids)]
# TODO: We should use multi value map. (When [1:tom, 2:tom])
extract_added_vids = self.extract_names(added_vids)
log.debug("Building vector index for %s vertices...", len(extract_added_vids))
added_embeddings = [self.embedding.get_text_embedding(v) for v in tqdm(extract_added_vids)]
log.debug("Vector index built for %s vertices.", len(added_embeddings))
self.vid_index.add(added_embeddings, added_vids)
self.vid_index.to_index_file(self.index_dir)
Expand Down
Loading