Find answers from the community

Updated 3 months ago

Weaviate

After parsing the nodes and persisting a vectorindex (specifically weaviate) I'm unable to load it
Plain Text
# Parse the nodes
docstore = SimpleDocumentStore()
docstore.add_documents(nodes)
storage_context = StorageContext.from_defaults(
    docstore=docstore,
    vector_store=vector_store,
)

# Create vecorstore
index = VectorStoreIndex(
    nodes=nodes,
    service_context=ServiceContext.from_defaults(llm=llm, embed_model=embedding),
    storage_context=storage_context,
)

# Persist
index.storage_context.persist("../index/frcb/")

# Reload
from llama_index.storage import StorageContext
from llama_index.storage.index_store import SimpleIndexStore
from llama_index.storage.docstore import SimpleDocumentStore

storage_context_loaded = StorageContext.from_defaults(
    vector_store=vector_store,
    docstore=SimpleDocumentStore.from_persist_path("../index/frcb/docstore.json"),
    index_store=SimpleIndexStore.from_persist_path("../index/frcb/index_store.json"),
    persist_dir="../index/frcb/",
)

from llama_index.indices.loading import load_index_from_storage

index_loaded = load_index_from_storage(
    storage_context=storage_context_loaded,
    service_context=ServiceContext.from_defaults(llm=llm, embed_model=embedding),
)

I know it's not retrieving properly because I'm getting Empty Response
Plain Text
engine_loaded = index_loaded.as_query_engine(
    similarity_top_k=10,
)
final_engine_loaded = SubQuestionQueryEngine.from_defaults(
    query_engine_tools=[
        QueryEngineTool(
            query_engine=engine_loaded,
            metadata=ToolMetadata(
                name="free_form_question_answer",
                description="financial insights.",
            ),
        )
    ],
    question_gen=question_gen,
    service_context=ServiceContext.from_defaults(llm=llm, embed_model=embedding),
    use_async=True,
)
W
L
m
4 comments
Are you persisting locally for some specific reason?
For loading you can directly do it with weaviate:
https://docs.llamaindex.ai/en/stable/examples/vector_stores/WeaviateIndexDemo.html
In addition to the above, giving the weaviate store a consistent index_name is also pretty important
Naming the index using the Weaviate client resolved the issue. It was not obvious to me that the nodes (which contain both metadata info as well as chunks of the documents) would be stored along with the proper embeddings.
If that is the case then I'll remove the docstore
Add a reply
Sign up and join the conversation on Discord