Skip to content

Handle hf_inference in single file #2766

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

Wauplin
Copy link
Contributor

@Wauplin Wauplin commented Jan 20, 2025

cc @hanouticelina this is a suggestion for PR #2757

Main changes are:

  1. IMO provider_helper.prepare_payload should not have a expect_binary parameter => since the provider_helper depends on the task, we already know if the input must be a binary or not
  2. I've made model: Optional[str] required in provider_helper.prepare_payload for all providers and all tasks. At the moment the model is only passed if we know the provider will use it. But in practice the InferenceClient and providers implementation should be independent. Hence passing it all the time and letting the provider decide what to do with the info.
  3. (the biggest change) use classes (yeah, I know... 🤦‍♂️) for hf-inference provider. This reduces by a lot the complexity / duplicated code. I'm defining HfInferenceTask for generic tasks, HFInferenceBinaryInputTask for tasks which require a binary input (so no need for expect_binary: bool anymore) and HFInferenceConversational for specific task.

Let me know what you think. We can either discuss some changes here or merge it and continue on your PR.

@Wauplin Wauplin requested a review from hanouticelina January 20, 2025 17:30
Copy link
Contributor

@hanouticelina hanouticelina left a comment

Choose a reason for hiding this comment

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

make sense, thanks a lot! let's merge it

@hanouticelina hanouticelina merged commit 20e8d3a into inference-providers-compatibility Jan 20, 2025
11 of 15 checks passed
@hanouticelina hanouticelina deleted the inference-providers-compatibility-suggestion branch January 20, 2025 21:11
hanouticelina added a commit that referenced this pull request Jan 23, 2025
* Add first version of third-party providers support

* add task level in model id mappings

* raise error when task is not supported by a provider + some improvements

* small (big) refactoring

* multiple fixes

* add hf inference tasks

* Handle hf_inference in single file (#2766)

* harmonize prepare_payload args and add automatic-speech-recognition task

* backward compatibility with custom urls

* first draft of tests

* InferenceClient as fixture + skip if no api_key

* give name to parametrized tests

* upload cassettes

* make quali

* download sample files from prod

* fix python3.8

* small improvement for better readability

Co-authored-by: Lucain <lucain@huggingface.co>

* make style

* fixing more tests

* test url building

* fix and record async client tests

* re-add cassettes

* fix

* add cassettes back

* fix test

* hopefully this will fix the test

* fix sentence similarity test

---------

Co-authored-by: Lucain <lucain@huggingface.co>
Co-authored-by: Lucain Pouget <lucainp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants