Skip to content

Commit

Permalink
add tqdm loading
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Dec 2, 2024
1 parent 5aaec73 commit 67990b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/sparql_llm/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ def init_vectordb(vectordb_host: str = settings.vectordb_host) -> None:
),
# wait=False, # Waiting for indexing to finish or not
)
print(f"Done generating and indexing {len(docs)} documents into the vectordb in {time.time() - start_time} seconds")
print(
f"Done generating and indexing {len(docs)} documents into the vectordb in {time.time() - start_time} seconds"
)

if not vectordb.collection_exists(settings.entities_collection_name):
vectordb.create_collection(
Expand Down
7 changes: 5 additions & 2 deletions src/sparql_llm/embed_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@

from langchain_core.documents import Document
from qdrant_client import models
from tqdm import tqdm

from sparql_llm.config import get_embedding_model, get_vectordb, settings
from sparql_llm.utils import query_sparql
from tqdm import tqdm

entities_embeddings_dir = os.path.join("data", "embeddings")
entities_embeddings_filepath = os.path.join(entities_embeddings_dir, "entities_embeddings.csv")


def retrieve_index_data(entity: dict, docs: list[Document], pagination: (int, int) = None):
query = f"{entity['query']} LIMIT {pagination[0]} OFFSET {pagination[1]}" if pagination else entity["query"]
try:
Expand Down Expand Up @@ -307,7 +308,9 @@ def load_entities_embeddings_to_vectordb():
)
)
embeddings.append(literal_eval(row["embedding"]))
print(f"Found embeddings for {len(docs)} entities in {time.time() - start_time} seconds. Now adding them to the vectordb")
print(
f"Found embeddings for {len(docs)} entities in {time.time() - start_time} seconds. Now adding them to the vectordb"
)
vectordb.upsert(
collection_name=settings.entities_collection_name,
points=models.Batch(
Expand Down

0 comments on commit 67990b3

Please sign in to comment.