-
Notifications
You must be signed in to change notification settings - Fork 470
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
Generate inference types + start using output types #2036
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2036 +/- ##
==========================================
+ Coverage 80.70% 82.71% +2.01%
==========================================
Files 71 102 +31
Lines 8519 9490 +971
==========================================
+ Hits 6875 7850 +975
+ Misses 1644 1640 -4 ☔ View full report in Codecov by Sentry. |
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 discussed irl, looks quite cool already!
This PR is now ready for review :) 🎉 |
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.
Looks good! Clear implementation, awesome to have the types so neatly defined within the runtime.
It would be awesome to gradually move towards the same input/output definitions within transformers & diffusers pipelines.
(No need to review but FYI @sanchit-gandhi @Rocketknight1 @amyeroberts @molbap @yiyixuxu as we'll want to adopt this soon)
src/huggingface_hub/inference/_generated/types/zero_shot_image_classification.py
Outdated
Show resolved
Hide resolved
@dataclass | ||
class TextClassificationOutput(BaseInferenceType): | ||
"""Outputs of inference for the Text Classification task""" | ||
|
||
label: str | ||
"""The predicted class label.""" | ||
score: float | ||
"""The corresponding probability.""" |
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.
Output is actually a List of those if I'm not mistaken :(
I had to manually parse the TS code to add that array definition in huggingface.js (bug also reported in quicktype)
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.
Yeah I already had a script to handle the shared classes (typically ClassificationOutput
) but now I pushed 56955a8 so that classes are named AudioClassificationOutputElement
, to emphasize that the expected output will be a list of those.
Does it look better for you like this?
Very cool that the inference types are used in the Inference client right away! |
Let's merge this PR now that everything's addressed! I have listed remaining todos in a follow-up issue: #2063. |
cc @SBrandeis @julien-c for visibility.
This PR adds scripts to generate inference types + start to use the output types in the InferenceClient.
The broader goal is to use all the spec-ed types in the
InferenceClient
but also intransformers
anddiffusers
pipelines.How it works:
Docs:
TODO:
_client.py
...huggingface_hub
?Breaking changes in outputs 💔:
automatic_speech_recognition
: str =>AutomaticSpeechRecognitionOutput
summarization
: str =>SummarizationOutput
translation
: str =>TranslationOutput
Left out of scope for this PR:
stream=True
conversational
=> will be deprecated/removed soon