Storing MultiVectorRetriever in Redis for a Multimodal RAG System #28583
Replies: 1 comment 1 reply
-
Hey @baeGil! I'm here to help you with any bugs, questions, or contributions. Let's tackle this issue together! To reconstruct a Here's a general approach you can follow:
Here is an example of how you might serialize and deserialize a LangChain object: from langchain_core.load import dumps, loads
# Assuming `retriever` is your MultiVectorRetriever object
# Serialize the retriever to a JSON string
json_string = dumps(retriever, pretty=True)
# Store `json_string` in Redis
# Retrieve `json_string` from Redis
# Deserialize the JSON string back into a MultiVectorRetriever object
retriever = loads(json_string) This approach should help you store and retrieve To continue talking to Dosu, mention @dosu. Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I tried to make a Multimodal RAG system with LangChain and Redis as a cache database. When a person starts a new conversation and uploads a file, it creates a MultiVectorRetriever and uses that retriever to answer questions from the user. I want to store that retriever in Redis to avoid redundant creation.
I figured out that Redis stores the JSON string representing the object, not the actual object itself. So, I convert the MultiVectorRetriever object to JSON by calling the
to_json()
method, so I can store it in Redis.However, after storing it in Redis, how can I get the actual data back from it? The
json.loads()
returns the JSON string, but LangChain does not provide any method to reconstruct the JSON back into a MultiVectorRetriever object after calling theto_json()
method.repr
returns a string type, meanwhile my actual data has this datatype:langchain.retrievers.multi_vector.MultiVectorRetriever
.Beta Was this translation helpful? Give feedback.
All reactions