langflow
langflow copied to clipboard
Passing a new query in retrieval QA chain its building the entire flow.
i have created a RAG pipeline using langflow, Where im using Huggingfacepipeline for llm, HuggingFaceEmbeddings for Embeddings and retrivalQA as chain and chat input and chat output for the same. So when i enter playground and send a query its builing the flow from start like documentloader, text splitters, embeddings.. and so on any suggestion will be of big help i will be attaching the image of my flow
To address the issue of your RAG pipeline rebuilding the entire flow with each new query, consider implementing a caching mechanism for the HuggingFaceEmbeddingsComponent
. This involves specifying a cache_folder
in its configuration, allowing the component to store and reuse embeddings for subsequent queries, thus avoiding the need to recompute them. Here's a concise example on how to set this up:
from langchain_community.embeddings.huggingface import HuggingFaceEmbeddings
from langflow.interface.custom.custom_component import CustomComponent
hugging_face_embeddings_component = HuggingFaceEmbeddingsComponent().build(
cache_folder='/path/to/your/cache/folder', # Path to cache folder
encode_kwargs={}, # Optional: Additional encoding kwargs
model_kwargs={}, # Optional: Additional model kwargs
model_name='sentence-transformers/all-mpnet-base-v2', # Model name
multi_process=True # Optional: Enable multi-processing
)
By leveraging the cache_folder
, the component will check for existing embeddings before processing new queries, significantly reducing the computational load and speeding up the response time for your pipeline. This approach optimizes the use of document loaders, text splitters, and embeddings, ensuring efficient reuse across queries.
Details
Sources
- src/backend/langflow/components/embeddings/HuggingFaceEmbeddings.py
- src/backend/base/langflow/components/embeddings/HuggingFaceEmbeddings.py
- src/backend/base/langflow/services/cache/init.py
- src/backend/base/langflow/interface/utils.py
- src/backend/langflow/services/cache/factory.py
About Dosu This response is meant to be useful and save you time. 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.
To continue the conversation, mention @dosu.
Hello,
Sorry for the delay. Did you try using the new version? Does the error still persist with the new Freeze option?
example:
Hi @baksh07,
I hope you're doing well. Just a friendly reminder that if we do not hear back from you within the next 3 days, we will close this issue. If you need more time or further assistance, please let us know.
Thank you for your understanding!
Thank you for your contribution! This issue will be closed. If you have any questions or encounter another problem, please open a new issue and we will be ready to assist you.