Here is my current code :
#### Build index
from llama_index.core import StorageContext
from llama_index.vector_stores.milvus import MilvusVectorStore
from llama_index.storage.docstore.redis import RedisDocumentStore
docstore = RedisDocumentStore.from_host_and_port(host="127.0.0.1", port="6379", namespace="llama_index")
vector_store = MilvusVectorStore(url='http://localhost:19530', dim=384, overwrite=True, collection_name = "myCollection")
storage_context = StorageContext.from_defaults(docstore=docstore, vector_store=vector_store)
# Chunk
node_parser = HierarchicalNodeParser.from_defaults(chunk_sizes=[2048, 512, 128])
nodes = node_parser.get_nodes_from_documents(docs)
# NOTE : I'd rather add the nodes before embedding. There is no point in storing embeddings in the docstore
docstore.add_documents(nodes)
# Compute Embeddings
embedded_nodes = huggingface_embedding_model(nodes)
# Add embeddings to my vector store
vector_store.add(embedded_nodes)
Here I create my vector_store_index but it needs docstore to perform automerging retrieval so it fails on the query !
#### Inference
# VectorStoreIndex is created without docstore ???
vector_store_index = VectorStoreIndex.from_vector_store(vector_store, embed_model=huggingface_embedding_model)
retriever = vector_store_index.as_retriever(
similarity_top_k=20,
vector_store_query_mode="default"
)
automerging_retriever = AutoMergingRetriever(
retriever,
vector_store_index.storage_context,
verbose=True,
)
rerank = SentenceTransformerRerank(top_n=5, model="BAAI/bge-reranker-base")
auto_merging_engine = RetrieverQueryEngine.from_args(
automerging_retriever,
llm=llm.model,
node_postprocessors=[rerank]
)
auto_merging_engine.query("what is the best model ?")
Maybe I am doing it the wrong way