----------------------
Yes, you can use Neo4j as a vector storage backend to store documents used by the auto-merge query engine in LlamaIndex.
Here is an example of how you can do this:
First, you need to install the necessary packages:
%pip install llama-index-vector-stores-neo4jvector
!pip install llama-index
Then, you can initiate the Neo4j vector wrapper:
from llama_index.vector_stores.neo4jvector import Neo4jVectorStore
username = "neo4j"
password = "pleaseletmein"
url = "bolt://localhost:7687"
embed_dim = 1536
neo4j_vector = Neo4jVectorStore(username, password, url, embed_dim)
After that, you can load your documents and build the VectorStoreIndex:
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
from llama_index.core import StorageContext
# load documents
documents = SimpleDirectoryReader("./data/paul_graham").load_data()
storage_context = StorageContext.from_defaults(vector_store=neo4j_vector)
index = VectorStoreIndex.from_documents(
documents, storage_context=storage_context
)
Finally, you can use the index as a query engine:
query_engine = index.as_query_engine()
response = query_engine.query("What happened at interleaf?")
For more details, you can refer to the
Neo4jVectorDemo notebook () on GitHub.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------