Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community: add support for using GPUs with FastEmbedEmbeddings #29627

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

vemonet
Copy link
Contributor

@vemonet vemonet commented Feb 6, 2025

  • Description: add a gpu: bool = False field to the FastEmbedEmbeddings class which enables to use GPU (through ONNX CUDA provider) when generating embeddings with any fastembed model. It just requires the user to install a different dependency and we use a different provider when instantiating fastembed.TextEmbedding
  • Issue: when generating embeddings for a really large amount of documents this drastically increase performance (honestly that is a must have in some situations, you can't just use CPU it is way too slow)
  • Dependencies: no direct change to dependencies, but the users will need to install fastembed-gpu instead of fastembed, I made all the changes to the init function and docstrings to properly let the user know which dependency they should install depending on if they enabled gpu or not

cf. fastembed docs about GPU for more details: https://qdrant.github.io/fastembed/examples/FastEmbed_GPU/

I did not added test because it would require access to a GPU in the testing environment

… greatly increase speed and scalability when generating embeddings for a large amount of documents with a GPU
@dosubot dosubot bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Feb 6, 2025
Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Feb 6, 2025 11:35am

@dosubot dosubot bot added community Related to langchain-community Ɑ: embeddings Related to text embedding models module labels Feb 6, 2025
)

if importlib.metadata.version("fastembed") < MIN_VERSION:
if importlib.metadata.version(pkg_to_import) < MIN_VERSION:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming fastembed and fastembed-gpu versions are kept in sync? (They appear on the same minor version now.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Feb 6, 2025
@ccurme ccurme merged commit 0ac5536 into langchain-ai:master Feb 6, 2025
19 checks passed
ccurme pushed a commit that referenced this pull request Feb 6, 2025
…bedEmbeddings (#29631)

Made a mistake in the module to import (the module stay the same only
the installed package changes), fixed it and tested it

#29627

@ccurme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Related to langchain-community Ɑ: embeddings Related to text embedding models module lgtm PR looks good. Use to confirm that a PR is ready for merging. size:S This PR changes 10-29 lines, ignoring generated files.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants