Find answers from the community

Updated 2 years ago

Hi I m trying to save and load my index

At a glance
Hi! I'm trying to save and load my index using the GPTVectorStoreIndex class. However, I keep getting an error when I try to reload my index:

Plain Text
gpt_index = GPTVectorStoreIndex(documents, llm_predictor=llm_predictor)
gpt_index.save_to_disk('./indices/gpt_index.json') # Works great! Saved to disk

loaded_index = GPTVectorStoreIndex.load_from_disk('./indices/gpt_index.json')

Error:
Plain Text
 TypeError: __init__() got an unexpected keyword argument 'simple_vector_store_data_dict'
K
L
11 comments
Seems to me like this would work, considering the only argument I need is a save_path but I could be mistaken!
I think that class isn't intended to be used directly

Try using GPTSimpleVectorIndex instead

(Also heads up, you'll want to pass in llm_predictor again when loading from disk to keep the llm settings)
Thanks @Logan M !
Getting a bit closer now. Here's the error I get when I do:
Plain Text
loaded_index = GPTSimpleVectorIndex.load_from_disk('./indices/gpt_index.json', llm_predictor=llm_predictor)

Error:
Plain Text
ValueError: doc_type vector_store not found in type_to_struct. Make sure that it was registered in the index registry.

If I look in the json, I can see "__type__": "vector_store"} at the end of an embedding trail, but maybe I should save the initial index in a specific way to ensure it can read the type_to_struct ?
Did you save the index using GPTSimpleVectorIndex as well? (Sorry, should have clarified that too)
Nah, I saved it using GPTVectorStoreIndex . Is this deprecated?
It's meant to be a Base class for all the vector indexes to inherit from.

Did you see a tutorial or example using that class?
I would use GPTSimpleVectorIndex, or one of the other vector indexes we have for 3rd party vector stores (pinecone, chroma, qdrant, etc.)
I haven't seen this! Where can I find that?
Lots of examples in the repo πŸ’ͺhere's one you might find helpful https://github.com/jerryjliu/llama_index/blob/main/examples/vector_indices/SimpleIndexDemo.ipynb

Also the docs are a great resource, I would start on this page: https://gpt-index.readthedocs.io/en/latest/guides/usage_pattern.html
Thanks again for all your help @Logan M ! :keanuthanks:
Add a reply
Sign up and join the conversation on Discord