Find answers from the community

Updated 2 months ago

My basic understanding of the

My basic understanding of the VectorStoreIndex is apparently somewhat confused. The class file vector_store/base.py describes it as:

An index that is built on top of an existing vector store.

Key words here being an existing vector store. As such, I thought a vector store was built when the index is initialized, such as with:

Plain Text
index = VectorStoreIndex(nodes)
index.storage_context.persist(persist_dir = persist_dir)


However, when I try to access the underlying vector store on top of which the index was supposed to be built:

Plain Text
storage_context = StorageContext.from_defaults(persist_dir = persist_dir)
index = load_index_from_storage(storage_context = storage_context)
vector_store = index.from_vector_store()


... it tells me that I need to provide a vector store, and therein lies my confusion. I'm trying to access the vector store from the index which I thought was located in persist_dir when VectorStoreIndex() was initialized, not build a new one.

Where is the underlying vector store for the index and how can I access it, please? (For context, I want to retrieve the vector store from the index in order to pass it as an argument to VectorMemory.)
L
b
U
8 comments
pretty sure its just index.vector_store no?
I'll copy/paste my reply.
Looks like that's it πŸ‘

It's accessed as a class property (i.e., index.vector_store), which is not listed as one of the properties in the init method of VectorStoreIndex. However, there is a method vector_store() which just returns self._vector_store, but when I call it, I get this:

TypeError: 'SimpleVectorStore' object is not callable

Must be some convoluted Python going on πŸ€”
My mistake. Don't include the parens
Not convoluted, just a @property decoroator to access the underlying ._storage_context.vector_store object
Ach ... must've missed that! πŸ€¦β€β™‚οΈ
Just to confirm ... it does not appear that SimpleVectorStore() allows for the storage of text along with node embeddings. As text storage is required by VectorMemory, this means I need to choose another vector store, correct?
yea, the SimpleVectorStore stores a mapping of node id -> embedding

Then the node_id is used to fetch the actual node from the docstore
Add a reply
Sign up and join the conversation on Discord