-
Notifications
You must be signed in to change notification settings - Fork 155
Make sentence_transformers an optional dependency #674
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
Make sentence_transformers an optional dependency #674
Conversation
- Move sentence_transformers to optional dependencies in pyproject.toml - Add conditional import in features.py - Update __init__.py to only export SentenceTransformerEmbed when available - Add installation instructions to examples Fixes #636
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also help to update the documentation for the SentenceTransformerEmbed
function?
Hey, personally, I feel that for the extra name, |
- Add sentence-transformers to pyproject.toml dependencies in all 7 examples - Update README files with installation instructions for SentenceTransformerEmbed - Add clear dependency notes to examples that use sentence transformers Part of #636
I've updated all 7 examples that use I noticed that the main README.md and several docs files also reference Files that might need updates:
|
Agree, |
It'll be great if you can help to update these docs in the current PR:
Other docs may be just mentioning
Thanks! |
…mers dependency - Update quickstart.md: change pip install command to include [sentence-transformers] extra - Update functions.md: add optional dependency note for SentenceTransformerEmbed function - Remove manual 'pip install sentence-transformers' instructions from all example README.md and main.py files
I've addressed all the feedback regarding documentation updates:
|
@theparthgupta what do you think about this? Would you also change the feature name to |
Agreed on changing it! I'd lean toward embeddings (plural) since it typically handles multiple embeddings, but either embedding or embeddings works well. Much better than the current long name. If you agree i can work on this too |
|
Sounds good! I'll get started on the implementation. |
- Updated pyproject.toml to use [embeddings] instead of [sentence-transformers] for the optional dependency group - Replaced all install instructions using 'cocoindex[sentence-transformers]' with 'cocoindex[embeddings]' across docs and examples -
I've updated the optional dependency group name from sentence-transformers to embeddings as discussed. Let me know if you'd like any other naming adjustments or additions |
Thanks for this change! |
thanks for merging the PR! I noticed CI is failing on main after my PR was merged — looks like mypy can't find sentence_transformers or numpy. I think it's due to the optional import. Should I open a quick fix to update mypy.ini or CI deps? |
@theparthgupta The CI failure is largely due to the missing |
thanks for doing it |
Summary
This PR makes
sentence_transformers
an optional dependency as requested in #636. The dependency is heavy and not needed for all use cases, so users can now choose whether to install it.Changes Made
sentence_transformers
from required dependencies to optional dependencies under thesentence-transformers
extraSentenceTransformerEmbed
when the dependency is availableSentenceTransformerEmbed
only when availableSentenceTransformerEmbed
Installation Options
Users can now install with: