-
Notifications
You must be signed in to change notification settings - Fork 2.5k
feat: Add HuggingFace API (text-embeddings-inference for rerank model) for component.rankers #9414
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
Conversation
…ce for rerank) ranker component
|
Hey @atopx thanks for your effort, have a look at contributing guide - you need to add reno note to this PR. We use it to generate beautiful release notes for Haystack 🙏 |
reno note added: releasenotes/notes/add-huggingface-api-text-embeddings-inference-to-component-rankers-0e3f54e523e42141.yaml |
# Conflicts: # docs/pydoc/config/rankers_api.yml
|
Hey @atopx this looks good. Please note that we can't serialize tokens directly as that is sensitive info and we have to use our Secret API This will take you 5 min to update 🙏 @anakin87 just to confirm, we don't have these HF remote rankers already somewhere? Is this a good direction in general. TIA |
1. `hugging_face_api.HuggingFaceAPIRanker` rename to `hugging_face_tei.HuggingFaceAPIRanker` 2. HuggingFaceAPIRanker: use our Secret API for token 3. add the missing modules for `docs/pydoc/config/rankers_api.yml` 4. added function `async_request_with_retry` for `haystack/utils/requests_utils.py` and added unittest on `test/utils/test_requests_utils.py` 4. HuggingFaceAPIRanker: refactor the retry function to support configuration based on attempts and status code. 5. HuggingFaceAPIRanker: refactor the test into unit tests using mocks
anakin87
left a comment
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.
Thanks for your work!
I found some opportunities for further improvement.
@dfokina could you please take a look at the docstrings?
...tes/add-huggingface-api-text-embeddings-inference-to-component-rankers-0e3f54e523e42141.yaml
Outdated
Show resolved
Hide resolved
- Force keyword-only arguments in __init__ method by adding *, - Clarify token docstring that it's not always required - Copy documents to avoid modifying original objects - Remove test file from slow workflow - Add monkeypatch eånvironment variable cleanup in tests - Fix missing module in rankers_api.yml and sort modules alphabetically - Remove unnecessary test info from release notes
Pull Request Test Coverage Report for Build 15270742072Details
💛 - Coveralls |
- "None" of "Optional[Secret]" has no attribute "resolve_value" - run/run_async: too many parameters
anakin87
left a comment
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.
This PR looks in a good state.
I would like to do some local tests (and refine the docstrings). I think I can do that next week.
@atopx, in the meantime, thanks for all the good work!
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.
Leaving some suggestions from the writing perspective.
…Ranker, improve the parameter descriptions, ensure consistency and clarity. Add error handling information to enhance the readability of the API response.
Thank you for pointing that out! |
dfokina
left a comment
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.
LGTM!
anakin87
left a comment
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.
@atopx thanks for this good work! 🥳
I'm merging this PR now...
Add HuggingFace API (text-embeddings-inference for rerank model)
Proposed Changes:
How did you test it?
Unit tests have been added in
test/components/rankers/test_hugging_face_api.pyNotes for the reviewer
Running unit tests requires setting up the text-embeddings-inference service and running the reranker model BAAI/bge-reranker-v2-m3
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.