-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
refactor: HF API Embedders - use InferenceClient.feature_extraction
instead of InferenceClient.post
#8794
Merged
Merged
refactor: HF API Embedders - use InferenceClient.feature_extraction
instead of InferenceClient.post
#8794
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e06997a
HF API Embedders: refactoring
anakin87 d7e3fb1
rename variables
anakin87 3de0901
rm leftovers
anakin87 3ebd5cb
Merge branch 'main' into fix-hfhub-embedder
anakin87 3599e05
rm pin
anakin87 6c32f83
rm unused import
anakin87 56afdd0
relnote
anakin87 f9479e0
warning with truncate/normalize and serverless inference API
anakin87 a27287d
test that warnings are raised
anakin87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ extra-dependencies = [ | |
"numba>=0.54.0", # This pin helps uv resolve the dependency tree. See https://github.com/astral-sh/uv/issues/7881 | ||
|
||
"transformers[torch,sentencepiece]==4.47.1", # ExtractiveReader, TransformersSimilarityRanker, LocalWhisperTranscriber, HFGenerators... | ||
"huggingface_hub>=0.27.0, <0.28.0", # Hugging Face API Generators and Embedders | ||
"huggingface_hub>=0.27.0", # Hugging Face API Generators and Embedders | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. based on my local tests, this solution works both with the new and the old version, so we can safely remove the pin |
||
"sentence-transformers>=3.0.0", # SentenceTransformersTextEmbedder and SentenceTransformersDocumentEmbedder | ||
"langdetect", # TextLanguageRouter and DocumentLanguageClassifier | ||
"openai-whisper>=20231106", # LocalWhisperTranscriber | ||
|
5 changes: 5 additions & 0 deletions
5
releasenotes/notes/hf-embedders-feature-extraction-ea0421a8f76052f0.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
fixes: | ||
- | | ||
In the Hugging Face API embedders, the `InferenceClient.feature_extraction` method is now used instead of | ||
`InferenceClient.post` to compute embeddings. This ensures a more robust and future-proof implementation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
as explained in the comment, the method does what we need but this usage is not officially supported
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.
For my own understanding, I looked into the API. From this discussion, am I correct to deduce that both types
str
andList[str]
are supported fortext
. We are unsure because the docs don't mentionList[str]
officially but the underlying models do expect lists and return correct results.In that case, it would make sense to introduce this change.
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.
I think you are basically right.
I reached out to the
huggingface_hub
maintainers here: huggingface/huggingface_hub#2824You can read this message to get a better understanding.