Open AlastairJarvis opened 3 weeks ago
Hey there, @AlastairJarvis! 👋 I'm Dosu, a friendly bot here to lend a hand with bugs, answer your queries, or guide you on contributing while we await a human maintainer. Just wanted you to know I'm diving into your issue and will get back to you with a comprehensive response soon! Stay tuned.
Let me know if you can't reproduce and I can send through the Problem Report for Python from the OS.
I get this 100%, and happy to help debug if you're unable to repro it there.
To address the crash issue you're encountering with Python when integrating Hugging Face Embeddings into your Vector Store RAG Flow, consider the following targeted steps:
Ensure Initialization Before Forking: Load all Hugging Face models before any multiprocessing occurs to avoid semaphore and objc
fork safety issues.
Adjust Langflow Component Configuration: In the HuggingFaceEmbeddingsComponent
, set multi_process
to False
to prevent multiprocessing complications.
Set Environment Variable on macOS: Use OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
to bypass objc
fork safety checks, though proceed with caution as it may affect application stability.
Change Multiprocessing Context: Switch Python's multiprocessing context to "spawn" or "thread" to mitigate issues related to process forking.
Update Libraries: Keep Hugging Face Transformers, Sentence Transformers, and Langflow libraries up to date to benefit from the latest fixes and improvements.
Enhance Debugging in Langflow: Implement detailed logging around the initialization and operation of the HuggingFaceEmbeddingsComponent
to identify the crash source more effectively.
Here's an example of how to configure the HuggingFaceEmbeddingsComponent
to avoid multiprocessing issues:
hugging_face_component = HuggingFaceEmbeddingsComponent(
model_name="sentence-transformers/all-mpnet-base-v2",
multi_process=False # Avoids multiprocessing issues
)
Additionally, the introduction of the CTransformersComponent
in Langflow, with its config
parameter for detailed configuration, including multiprocessing settings, suggests enhanced support for Hugging Face model integration. This component is designed to improve the handling of language models by providing customizable deployment and execution options.
If these steps do not resolve the issue, please share any additional error messages or information for further assistance.
To continue the conversation, mention @dosu.
Hey @AlastairJarvis
Do you know if this component accesses the HuggingFace API or if it loads the model locally?
Running it locally will not work on the 1.0 alpha because it will load the model on every run.
Aha.
When I first tried this component (HuggingFaceEmbeddings), LangFlow prompted me to download and install it, which leads me to believe it's trying to run it locally.
I see HuggingFaceAPI Embeddings is a different component, but it looks like this is also pointing to localhost - so pointing to an API being served locally?
Describe the bug While building a flow using Hugging Face Embeddings component (model: sentence-transformers/all-mpnet-base-v2), Python crashes.
Browser and Version
To Reproduce Steps to reproduce the behavior: