Find answers from the community

Updated 4 months ago

Hey guys,

At a glance

The community member asks if it is possible to save the state of a query engine so that it does not need to be re-initialized when using rerankers or indexes. They provide a code snippet that suggests pickling the query engine, but they are unsure if this is correct. In the comments, another community member states that there is no real "state" to save, and that pickling a local model may not be possible, especially if the model is API-based. There is no explicitly marked answer in the post or comments.

Hey guys,
  1. can we save query engines state so that we don't have to re-initialize it with the rerankers or the indexes?
Assume the index is in a vector store and not in memory.
Mendable tells this MLesque answer
import pickle

Assuming 'query_engine' is your initialized query engine

with open('query_engine.pkl', 'wb') as f:
pickle.dump(query_engine, f)

To load the query engine later

with open('query_engine.pkl', 'rb') as f:
loaded_query_engine = pickle.load(f)
which i am not sure correct...
L
1 comment
There is no "state" really. You can't really pickle a local model either (if you are using an API based model, then it might be more possible, but if its api based, then initializing it is basically a no-op
Add a reply
Sign up and join the conversation on Discord