Conversation
|
Heads-up for maintainers This PR is from a fork and touches integrations whose integration tests require API keys. Affected integrations:
Please run the integration tests locally ( |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Coverage report (huggingface_api)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sorry to bother you @bogdankostic, this should be ready to review and I've resolved the previously existing merge conflicts. |
anakin87
left a comment
There was a problem hiding this comment.
Hey @maxdswain, thanks for this contribution!
Since this requires much more code to maintain, I'd like to see reproducible proof that it improves performance significantly compared to HTTP.
I quickly tried benchmarking this myself but I could not find conclusive results. Could you try and let me know?
Hi @anakin87, thanks for the reply. Most of the code in this PR is in the curl -Lo src/haystack_integrations/components/embedders/huggingface_api/_grpc/tei.proto https://raw.githubusercontent.com/huggingface/text-embeddings-inference/main/proto/tei.proto
pip install grpcio-tools mypy-protobuf
python -m grpc_tools.protoc --proto_path=src --python_out=src --pyi_out=src --grpc_python_out=src --mypy_grpc_out=src haystack_integrations/components/embedders/huggingface_api/_grpc/tei.protoI've found there to be large performance differences at high concurrency (i.e., when ingesting documents or when many users are asking questions) when running on GPUs, as this is when inference time takes up a much smaller portion of the request time. I contribute to OS on a old personal laptop without access to GPUs so unfortunately I'm unable to give you more solid evidence on the performance differences. |
|
I see, thanks for clarifying. Could you try exploring server reflection as an alternative? We might be able to build the client dynamically and avoid shipping and regenerating the protobuf bindings when TEI changes. I tried a prototype using grpc-requests. Could you try doing something similar and see if the performance benefits still hold? This solution would be simpler and more maintainable. |
Related Issues
Proposed Changes:
Add grpc support through optional grpc extras for the hugging face text embedding inference (TEI). To support this implementation, I generated a grpc client from the latest TEI protobuf. Instructions on how to regenerate the files from the protobuf have been added to the README.
This needed to be done as the existing huggingface hub inference client does not support grpc, and does not intend to.
How did you test it?
Added unit and integration tests. You need to run
docker compose up -dbefore running the integration tests.Notes for the reviewer
The TEI grpc API doesn't have an API where it takes a list of inputs to embed, so instead for the document embedder components, I used the
EmbedStreaminterface. In my testing, this is faster then using multiple streams one after the other and batching requests.I added grpc client initialisation in the
warm_up/warm_up_asyncmethods and client closing in theclose/close_asyncmethods to align with the recent changes to lifecycle management for HTTP clients.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:.