Replies: 1 comment
-
PR: #8249 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked
Feature request
Adding query embedding caching
Currently CacheBackedEmbeddings does not do query caching with a code comment from two years ago "might make sense to hold off to see the most common patterns."
langchainjs/langchain/src/embeddings/cache_backed.ts
Line 81 in b7a9cac
I suspect there is not going to be a one size fits all, but perhaps we can address some use cases with an implementation similar to the caching of document embeddings.
Motivation
In applications that do one-shot text classification, some inputs tend to repeat themselves. For example, in a customer service router where a customer states what they need for the application to route them to the correct department, microservice, etc. There is a portion of the customer requests that are an exact match of each other. By providing the option to developers to utilize such a cache if applicable to their use case they can reduce their model and related calls and costs.
Proposal (If applicable)
The proposal is to use a similar implementation as the document embedding caching but make the query caching optional so it would be a non-breaking addition, and help anyone that can benefit from it. Similar to the document caching we are not going to have anything for purging the old entrees and going to leave it to the devs to add TTL, or a clean up process to their cache storage.
I actually have the query caching implemented in cjs and deployed with a patch-package patch to a prod application that I have up and running. I can repack it in TS, add tests and documentation and submit a PR for it in the next few weeks.
Beta Was this translation helpful? Give feedback.
All reactions