This is an automated email from the ASF dual-hosted git repository.

ming pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph-ai.git


The following commit(s) were added to refs/heads/main by this push:
     new deced7e  Add progress bars and print information for building vector 
indexes (#74)
deced7e is described below

commit deced7e627dd4aecf36ed0e9c6f44a989c28f2cf
Author: vichayturen <[email protected]>
AuthorDate: Tue Aug 27 12:39:28 2024 +0800

    Add progress bars and print information for building vector indexes (#74)
    
    Co-authored-by: imbajin <[email protected]>
---
 .../src/hugegraph_llm/operators/index_op/build_semantic_index.py     | 3 ++-
 .../src/hugegraph_llm/operators/index_op/build_vector_index.py       | 5 ++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git 
a/hugegraph-llm/src/hugegraph_llm/operators/index_op/build_semantic_index.py 
b/hugegraph-llm/src/hugegraph_llm/operators/index_op/build_semantic_index.py
index a439d46..2582653 100644
--- a/hugegraph-llm/src/hugegraph_llm/operators/index_op/build_semantic_index.py
+++ b/hugegraph-llm/src/hugegraph_llm/operators/index_op/build_semantic_index.py
@@ -19,6 +19,7 @@
 import os
 from typing import Any, Dict
 
+from tqdm import tqdm
 from hugegraph_llm.config import resource_path, settings
 from hugegraph_llm.models.embeddings.base import BaseEmbedding
 from hugegraph_llm.indices.vector_index import VectorIndex
@@ -36,7 +37,7 @@ class BuildSemanticIndex:
             log.debug("Building vector index for %s vertices...", 
len(context["vertices"]))
             vids = []
             vids_embedding = []
-            for vertex in context["vertices"]:
+            for vertex in tqdm(context["vertices"]):
                 vertex_text = f"{vertex['label']}\n{vertex['properties']}"
                 
vids_embedding.append(self.embedding.get_text_embedding(vertex_text))
                 vids.append(vertex["id"])
diff --git 
a/hugegraph-llm/src/hugegraph_llm/operators/index_op/build_vector_index.py 
b/hugegraph-llm/src/hugegraph_llm/operators/index_op/build_vector_index.py
index 51f7bec..1fccf15 100644
--- a/hugegraph-llm/src/hugegraph_llm/operators/index_op/build_vector_index.py
+++ b/hugegraph-llm/src/hugegraph_llm/operators/index_op/build_vector_index.py
@@ -19,9 +19,11 @@
 import os
 from typing import Dict, Any
 
+from tqdm import tqdm
 from hugegraph_llm.config import settings, resource_path
 from hugegraph_llm.indices.vector_index import VectorIndex
 from hugegraph_llm.models.embeddings.base import BaseEmbedding
+from hugegraph_llm.utils.log import log
 
 
 class BuildVectorIndex:
@@ -37,7 +39,8 @@ class BuildVectorIndex:
             raise ValueError("chunks not found in context.")
         chunks = context["chunks"]
         chunks_embedding = []
-        for chunk in chunks:
+        log.debug("Building vector index for %s chunks...", 
len(context["chunks"]))
+        for chunk in tqdm(chunks):
             chunks_embedding.append(self.embedding.get_text_embedding(chunk))
         if len(chunks_embedding) > 0:
             if os.path.exists(self.index_file) and 
os.path.exists(self.content_file):

Reply via email to