Needing help with Knowledge Graph Index.. #16129
Replies: 1 comment 1 reply
-
Hey there, @bilalkhan1011! I'm here to assist you with any bugs, questions, or contributions you may have. Let's tackle this together! I found a similar solved discussion that might help you: ValueError: doc_id not found while using KnowledgeGraphIndex. The issue was related to using To successfully build, save, and load a
Ensure that the |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have been working on trying to solve this issue for days on end now but can't seem to get it to work. I am trying to build a KnowledgeGraphIndex and then save, and load it in my application. This seems to work sometimes but my tool will fail to find any matching information when I query. When I try to turn my loaded index into a networkx graph it also shows as completely empty which feels like it should not happen.
This is how my index is built and stored:
graph_store = SimpleGraphStore()
storage_context = StorageContext.from_defaults(graph_store=graph_store)
root_id= "kgindex"
index = KnowledgeGraphIndex.from_documents( documents=documents,
max_triplets_per_chunk=2,
storage_context=storage_context,
embed_model=embed_model,
include_embeddings=True,
show_progress=True)
index.set_index_id(root_id)
storage_context.persist(persist_dir="./index")
and this is how I'm loading it in which doesn't work for some reason:
root_id = "kgindex"
storage_dir = "./index"
graph_store = SimpleGraphStore()
storage_context = StorageContext.from_defaults(graph_store=graph_store, persist_dir=storage_dir)
index = (load_index_from_storage(storage_context))
query_engine = index.as_query_engine(similarity_top_k=2)
Any help would be massively appreciated as I have been trying for so long.
Beta Was this translation helpful? Give feedback.
All reactions