mirror of
https://github.com/hwchase17/langchain.git
synced 2026-01-17 09:46:33 +00:00
**Description:** `langchain_huggingface` has a very large installation size of around 600 MB (on a Mac with Python 3.11). This is due to its dependency on `sentence-transformers`, which in turn depends on `torch`, which is 320 MB all by itself. Similarly, the depedency on `transformers` adds another set of heavy dependencies. With those dependencies removed, the installation of `langchain_huggingface` only takes up ~26 MB. This is only 5 % of the full installation! These libraries are not necessary to use `langchain_huggingface`'s API wrapper classes, only for local inferences/embeddings. All import statements for those two libraries already have import guards in place (try/catch with a helpful "please install x" message). This PR therefore moves those two libraries to an optional dependency group `full`. So a `pip install langchain_huggingface` will only install the lightweight version, and a `pip install "langchain_huggingface[full]"` will install all dependencies. I know this may break existing code, because `sentence-transformers` and `transformers` are now no longer installed by default. Given that users will see helpful error messages when that happens, and the major impact of this small change, I hope that you will still consider this PR. **Dependencies:** No new dependencies, but new optional grouping.