Replies: 2 comments 2 replies
-
I also need a feature like that, but about the LLM HuggingFaceEndpoint. I think your proposed solution is good. |
Beta Was this translation helpful? Give feedback.
2 replies
-
You can copy this code instead from (your py file name) import HuggingFaceEndpointEmbeddings
To use it
|
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
-
Checked
Feature request
Description
When importing
HuggingFaceEndpointEmbeddings
fromlangchain_huggingface.embeddings
, it is currently necessary to install the completelangchain-huggingface
package. This package includes thepytorch
library as a dependency, which significantly increases the size of container images by up to 6GB. This is problematic for use cases that only require remote embedding API access and do not need thepytorch
library.Proposed Solution
Refactor the
HuggingFaceEndpointEmbeddings
module so that it can be imported and used without the need forpytorch
and other heavy dependencies. This could be achieved by:langchain-huggingface
package into smaller, more focused modules.HuggingFaceEndpointEmbeddings
class that only includes the necessary components for remote embedding API access.pytorch
only when necessary for local model execution.Benefits
pytorch
dependency, the size of container images can be significantly reduced, making deployments faster and more efficient.pytorch
library.Additional Context
This change is particularly important for users who operate in environments with strict resource limitations or those who prioritize lightweight and efficient deployments.
Example
Current import statement:
Proposed import statement after refactoring:
but with an optional dependency:
Impact
This change will help in making the
langchain-huggingface
package more modular and user-friendly, especially for those who rely solely on remote services for embedding tasks.Thank you for considering this proposal. I believe it will greatly enhance the usability and efficiency of the
langchain-huggingface
package.Motivation
I wrote a containerized Retrieval Augmented Generation (RAG) app just needing the
HuggingFaceEndpointEmbeddings
as a dependency. The container image size was about 200 MB. After adding thelangchain-huggingface
dependency the container image size exploded up to 6GB! I think it's mainly because of the necessarypytorch
dependency (for this remote embedding point use case).Proposal (If applicable)
No response
Beta Was this translation helpful? Give feedback.
All reactions