Caching with existing embeddings #2000
Replies: 2 comments 2 replies
-
I think I understand, but maybe not =)
|
Beta Was this translation helpful? Give feedback.
-
Answer generated by a 🤖 AnswerI understand that you're trying to use LangChainJS with Redis caching and vector similarity search, and you already have pre-existing embeddings for your source data. You're looking to store these embeddings in the cache and use them for reference during search operations. You're also interested in understanding how to use the From your description, it seems you're on the right track. However, LangChainJS does not directly support passing vectors to the const simpleRes = await vectorStore.similaritySearchVectorWithScore([0.1, 0.2, 0.3...], 1); This method also returns the similarity scores along with the documents, which can be useful if you want to use a similarity threshold. Regarding your custom class, This approach should allow you to use pre-existing embeddings with LangChainJS and Redis, and perform similarity searches using vectors. However, please note that this is one potential solution based on the current capabilities of LangChainJS. There might be other ways to achieve the same result depending on your specific use case. If you find this solution helpful and believe it could benefit other users, I encourage you to make a pull request to update the LangChainJS documentation. This way, others facing the same issue can also benefit from your experience. SourcesThis response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. |
Beta Was this translation helpful? Give feedback.
-
I need help or maybe an explanation.
How can I use Redis caching and vector similarity search with LangchainJS if I already have embeddings for the source which I need to store to cache and for reference with which I will search it?
I understand that when you create a Vetror Store you need to pass a worker that will create embeddings for documents and retrieve it from them when needed.
And you can create your own class with custom logic.
But still, when you are searching there is only one option to pass the text, not a vector.
Also in custom class
What should do methods
embedDocuments
andembedQuery
.The first one as I understand should generate embeddings for documents. But I don't understand how it should actually work.
So the expected result is:
P.S. And as I understand if I want to use some similarity threshold I need to use
similaritySearchWithScore
instead ofsimilaritySearch
. And then compare values?Beta Was this translation helpful? Give feedback.
All reactions