Replies: 1 comment
-
Hey there, @gbaglini! I'm here to help you with any bugs, questions, or just to chat while we wait for a human maintainer. Let me know how I can assist you today. To properly store and reload the index using the Storing the Index
from llama_index.vector_stores.timescalevector import TimescaleVectorStore
from llama_index.core import StorageContext, VectorStoreIndex
# Parameters for the TimescaleVectorStore
service_url = os.environ["TIMESCALE_SERVICE_URL"]
table_name = "reuters_test"
# Create the TimescaleVectorStore
ts_vector_store = TimescaleVectorStore.from_params(
service_url=service_url,
table_name=table_name,
)
# Add nodes to the vector store
nodes = [create_node2(row) for _, row in reuters.iterrows()]
ts_vector_store.add(nodes[:100])
# Create a storage context
storage_context = StorageContext.from_defaults(vector_store=ts_vector_store)
# Create the index
index = VectorStoreIndex.from_documents(nodes, storage_context=storage_context)
# Save the index to storage
index.storage_context.persist(persist_dir="your_persist_dir") Reloading the Index
from llama_index.core import StorageContext, load_index_from_storage
# Create a storage context from the persisted directory
storage_context = StorageContext.from_defaults(persist_dir="your_persist_dir")
# Load the index from storage
index = load_index_from_storage(storage_context) By following these steps, you ensure that the index is stored and can be reloaded without needing to recreate it each time. This approach uses the For more detailed examples and documentation, you can refer to the LlamaIndex documentation on customizing storage [1] and the TimescaleVector example [2]. |
Beta Was this translation helpful? Give feedback.
-
I'm currently working with the llama_index Python package and using the llama-index-vector-stores-timescalevector extension to manage my vectors with Timescale. However, I’ve encountered an issue where I’m unable to store the index for future use, which means I have to recreate it every time I run my code. This is quite inefficient and not ideal for my use case.
I followed this tutorial: TimescaleVector Example, but it doesn't mention how to store and later load the index.
Here’s a snippet of my code setup. The csv is available at this link
Does anyone have experience with the llama-index-vector-stores-timescalevector package? How can I properly store and reload the index to avoid having to recreate it each time? Any guidance on the correct method or any relevant documentation would be greatly appreciated.
I expected to be able to store the index and later reload it without needing to recreate it from scratch.
Beta Was this translation helpful? Give feedback.
All reactions