Skip to content

Commit

Permalink
Update inference types (automated commit)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wauplin authored and github-actions[bot] committed Nov 22, 2024
1 parent fcecbb8 commit a6e1cd2
Show file tree
Hide file tree
Showing 31 changed files with 116 additions and 201 deletions.
8 changes: 2 additions & 6 deletions docs/source/en/package_reference/inference_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,6 @@ This part of the lib is still under development and will be improved in future r

[[autodoc]] huggingface_hub.ZeroShotClassificationInput

[[autodoc]] huggingface_hub.ZeroShotClassificationInputData

[[autodoc]] huggingface_hub.ZeroShotClassificationOutputElement

[[autodoc]] huggingface_hub.ZeroShotClassificationParameters
Expand All @@ -381,8 +379,6 @@ This part of the lib is still under development and will be improved in future r

[[autodoc]] huggingface_hub.ZeroShotImageClassificationInput

[[autodoc]] huggingface_hub.ZeroShotImageClassificationInputData

[[autodoc]] huggingface_hub.ZeroShotImageClassificationOutputElement

[[autodoc]] huggingface_hub.ZeroShotImageClassificationParameters
Expand All @@ -395,6 +391,6 @@ This part of the lib is still under development and will be improved in future r

[[autodoc]] huggingface_hub.ZeroShotObjectDetectionInput

[[autodoc]] huggingface_hub.ZeroShotObjectDetectionInputData

[[autodoc]] huggingface_hub.ZeroShotObjectDetectionOutputElement

[[autodoc]] huggingface_hub.ZeroShotObjectDetectionParameters
8 changes: 2 additions & 6 deletions docs/source/ko/package_reference/inference_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,6 @@ rendered properly in your Markdown viewer.

[[autodoc]] huggingface_hub.ZeroShotClassificationInput

[[autodoc]] huggingface_hub.ZeroShotClassificationInputData

[[autodoc]] huggingface_hub.ZeroShotClassificationOutputElement

[[autodoc]] huggingface_hub.ZeroShotClassificationParameters
Expand All @@ -380,8 +378,6 @@ rendered properly in your Markdown viewer.

[[autodoc]] huggingface_hub.ZeroShotImageClassificationInput

[[autodoc]] huggingface_hub.ZeroShotImageClassificationInputData

[[autodoc]] huggingface_hub.ZeroShotImageClassificationOutputElement

[[autodoc]] huggingface_hub.ZeroShotImageClassificationParameters
Expand All @@ -394,6 +390,6 @@ rendered properly in your Markdown viewer.

[[autodoc]] huggingface_hub.ZeroShotObjectDetectionInput

[[autodoc]] huggingface_hub.ZeroShotObjectDetectionInputData

[[autodoc]] huggingface_hub.ZeroShotObjectDetectionOutputElement

[[autodoc]] huggingface_hub.ZeroShotObjectDetectionParameters
18 changes: 9 additions & 9 deletions src/huggingface_hub/inference/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def audio_classification(
top_k (`int`, *optional*):
When specified, limits the output to the top K most probable classes.
function_to_apply (`"AudioClassificationOutputTransform"`, *optional*):
The function to apply to the output.
The function to apply to the model outputs in order to retrieve the scores.
Returns:
`List[AudioClassificationOutputElement]`: List of [`AudioClassificationOutputElement`] items containing the predicted labels and their confidence.
Expand Down Expand Up @@ -1131,7 +1131,7 @@ def image_classification(
The model to use for image classification. Can be a model ID hosted on the Hugging Face Hub or a URL to a
deployed Inference Endpoint. If not provided, the default recommended model for image classification will be used.
function_to_apply (`"ImageClassificationOutputTransform"`, *optional*):
The function to apply to the output.
The function to apply to the model outputs in order to retrieve the scores.
top_k (`int`, *optional*):
When specified, limits the output to the top K most probable classes.
Returns:
Expand Down Expand Up @@ -1814,7 +1814,7 @@ def text_classification(
top_k (`int`, *optional*):
When specified, limits the output to the top K most probable classes.
function_to_apply (`"TextClassificationOutputTransform"`, *optional*):
The function to apply to the output.
The function to apply to the model outputs in order to retrieve the scores.
Returns:
`List[TextClassificationOutputElement]`: a list of [`TextClassificationOutputElement`] items containing the predicted label and associated probability.
Expand Down Expand Up @@ -2494,11 +2494,11 @@ def text_to_speech(
max_length (`int`, *optional*):
The maximum length (in tokens) of the generated text, including the input.
max_new_tokens (`int`, *optional*):
The maximum number of tokens to generate. Takes precedence over maxLength.
The maximum number of tokens to generate. Takes precedence over max_length.
min_length (`int`, *optional*):
The minimum length (in tokens) of the generated text, including the input.
min_new_tokens (`int`, *optional*):
The minimum number of tokens to generate. Takes precedence over maxLength.
The minimum number of tokens to generate. Takes precedence over min_length.
num_beam_groups (`int`, *optional*):
Number of groups to divide num_beams into in order to ensure diversity among different groups of beams.
See [this paper](https://hf.co/papers/1610.02424) for more details.
Expand Down Expand Up @@ -2801,8 +2801,8 @@ def zero_shot_classification(
the label likelihoods for each sequence is 1. If true, the labels are considered independent and
probabilities are normalized for each candidate.
hypothesis_template (`str`, *optional*):
The sentence used in conjunction with candidateLabels to attempt the text classification by replacing
the placeholder with the candidate labels.
The sentence used in conjunction with `candidate_labels` to attempt the text classification by
replacing the placeholder with the candidate labels.
model (`str`, *optional*):
The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
Inference Endpoint. This parameter overrides the model defined at the instance level. If not provided, the default recommended zero-shot classification model will be used.
Expand Down Expand Up @@ -2918,8 +2918,8 @@ def zero_shot_image_classification(
The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
Inference Endpoint. This parameter overrides the model defined at the instance level. If not provided, the default recommended zero-shot image classification model will be used.
hypothesis_template (`str`, *optional*):
The sentence used in conjunction with candidateLabels to attempt the text classification by replacing
the placeholder with the candidate labels.
The sentence used in conjunction with `candidate_labels` to attempt the image classification by
replacing the placeholder with the candidate labels.
Returns:
`List[ZeroShotImageClassificationOutputElement]`: List of [`ZeroShotImageClassificationOutputElement`] items containing the predicted labels and their confidence.
Expand Down
18 changes: 9 additions & 9 deletions src/huggingface_hub/inference/_generated/_async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ async def audio_classification(
top_k (`int`, *optional*):
When specified, limits the output to the top K most probable classes.
function_to_apply (`"AudioClassificationOutputTransform"`, *optional*):
The function to apply to the output.
The function to apply to the model outputs in order to retrieve the scores.
Returns:
`List[AudioClassificationOutputElement]`: List of [`AudioClassificationOutputElement`] items containing the predicted labels and their confidence.
Expand Down Expand Up @@ -1176,7 +1176,7 @@ async def image_classification(
The model to use for image classification. Can be a model ID hosted on the Hugging Face Hub or a URL to a
deployed Inference Endpoint. If not provided, the default recommended model for image classification will be used.
function_to_apply (`"ImageClassificationOutputTransform"`, *optional*):
The function to apply to the output.
The function to apply to the model outputs in order to retrieve the scores.
top_k (`int`, *optional*):
When specified, limits the output to the top K most probable classes.
Returns:
Expand Down Expand Up @@ -1876,7 +1876,7 @@ async def text_classification(
top_k (`int`, *optional*):
When specified, limits the output to the top K most probable classes.
function_to_apply (`"TextClassificationOutputTransform"`, *optional*):
The function to apply to the output.
The function to apply to the model outputs in order to retrieve the scores.
Returns:
`List[TextClassificationOutputElement]`: a list of [`TextClassificationOutputElement`] items containing the predicted label and associated probability.
Expand Down Expand Up @@ -2559,11 +2559,11 @@ async def text_to_speech(
max_length (`int`, *optional*):
The maximum length (in tokens) of the generated text, including the input.
max_new_tokens (`int`, *optional*):
The maximum number of tokens to generate. Takes precedence over maxLength.
The maximum number of tokens to generate. Takes precedence over max_length.
min_length (`int`, *optional*):
The minimum length (in tokens) of the generated text, including the input.
min_new_tokens (`int`, *optional*):
The minimum number of tokens to generate. Takes precedence over maxLength.
The minimum number of tokens to generate. Takes precedence over min_length.
num_beam_groups (`int`, *optional*):
Number of groups to divide num_beams into in order to ensure diversity among different groups of beams.
See [this paper](https://hf.co/papers/1610.02424) for more details.
Expand Down Expand Up @@ -2870,8 +2870,8 @@ async def zero_shot_classification(
the label likelihoods for each sequence is 1. If true, the labels are considered independent and
probabilities are normalized for each candidate.
hypothesis_template (`str`, *optional*):
The sentence used in conjunction with candidateLabels to attempt the text classification by replacing
the placeholder with the candidate labels.
The sentence used in conjunction with `candidate_labels` to attempt the text classification by
replacing the placeholder with the candidate labels.
model (`str`, *optional*):
The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
Inference Endpoint. This parameter overrides the model defined at the instance level. If not provided, the default recommended zero-shot classification model will be used.
Expand Down Expand Up @@ -2989,8 +2989,8 @@ async def zero_shot_image_classification(
The model to use for inference. Can be a model ID hosted on the Hugging Face Hub or a URL to a deployed
Inference Endpoint. This parameter overrides the model defined at the instance level. If not provided, the default recommended zero-shot image classification model will be used.
hypothesis_template (`str`, *optional*):
The sentence used in conjunction with candidateLabels to attempt the text classification by replacing
the placeholder with the candidate labels.
The sentence used in conjunction with `candidate_labels` to attempt the image classification by
replacing the placeholder with the candidate labels.
Returns:
`List[ZeroShotImageClassificationOutputElement]`: List of [`ZeroShotImageClassificationOutputElement`] items containing the predicted labels and their confidence.
Expand Down
4 changes: 1 addition & 3 deletions src/huggingface_hub/inference/_generated/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,19 +167,17 @@
)
from .zero_shot_classification import (
ZeroShotClassificationInput,
ZeroShotClassificationInputData,
ZeroShotClassificationOutputElement,
ZeroShotClassificationParameters,
)
from .zero_shot_image_classification import (
ZeroShotImageClassificationInput,
ZeroShotImageClassificationInputData,
ZeroShotImageClassificationOutputElement,
ZeroShotImageClassificationParameters,
)
from .zero_shot_object_detection import (
ZeroShotObjectDetectionBoundingBox,
ZeroShotObjectDetectionInput,
ZeroShotObjectDetectionInputData,
ZeroShotObjectDetectionOutputElement,
ZeroShotObjectDetectionParameters,
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@

@dataclass
class AudioClassificationParameters(BaseInferenceType):
"""Additional inference parameters
Additional inference parameters for Audio Classification
"""
"""Additional inference parameters for Audio Classification"""

function_to_apply: Optional["AudioClassificationOutputTransform"] = None
"""The function to apply to the output."""
"""The function to apply to the model outputs in order to retrieve the scores."""
top_k: Optional[int] = None
"""When specified, limits the output to the top K most probable classes."""

Expand All @@ -33,7 +31,7 @@ class AudioClassificationInput(BaseInferenceType):
also provide the audio data as a raw bytes payload.
"""
parameters: Optional[AudioClassificationParameters] = None
"""Additional inference parameters"""
"""Additional inference parameters for Audio Classification"""


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

@dataclass
class AutomaticSpeechRecognitionGenerationParameters(BaseInferenceType):
"""Parametrization of the text generation process
Ad-hoc parametrization of the text generation process
"""
"""Parametrization of the text generation process"""

do_sample: Optional[bool] = None
"""Whether to use sampling instead of greedy decoding when generating new tokens."""
Expand Down Expand Up @@ -76,11 +74,9 @@ class AutomaticSpeechRecognitionGenerationParameters(BaseInferenceType):

@dataclass
class AutomaticSpeechRecognitionParameters(BaseInferenceType):
"""Additional inference parameters
Additional inference parameters for Automatic Speech Recognition
"""
"""Additional inference parameters for Automatic Speech Recognition"""

generate: Optional[AutomaticSpeechRecognitionGenerationParameters] = None
generation_parameters: Optional[AutomaticSpeechRecognitionGenerationParameters] = None
"""Parametrization of the text generation process"""
return_timestamps: Optional[bool] = None
"""Whether to output corresponding timestamps with the generated text"""
Expand All @@ -95,7 +91,7 @@ class AutomaticSpeechRecognitionInput(BaseInferenceType):
also provide the audio data as a raw bytes payload.
"""
parameters: Optional[AutomaticSpeechRecognitionParameters] = None
"""Additional inference parameters"""
"""Additional inference parameters for Automatic Speech Recognition"""


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DepthEstimationInput(BaseInferenceType):
inputs: Any
"""The input image data"""
parameters: Optional[Dict[str, Any]] = None
"""Additional inference parameters"""
"""Additional inference parameters for Depth Estimation"""


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ class DocumentQuestionAnsweringInputData(BaseInferenceType):

@dataclass
class DocumentQuestionAnsweringParameters(BaseInferenceType):
"""Additional inference parameters
Additional inference parameters for Document Question Answering
"""
"""Additional inference parameters for Document Question Answering"""

doc_stride: Optional[int] = None
"""If the words in the document are too long to fit with the question for the model, it will
Expand Down Expand Up @@ -62,7 +60,7 @@ class DocumentQuestionAnsweringInput(BaseInferenceType):
inputs: DocumentQuestionAnsweringInputData
"""One (document, question) pair to answer"""
parameters: Optional[DocumentQuestionAnsweringParameters] = None
"""Additional inference parameters"""
"""Additional inference parameters for Document Question Answering"""


@dataclass
Expand All @@ -81,5 +79,3 @@ class DocumentQuestionAnsweringOutputElement(BaseInferenceType):
"""The start word index of the answer (in the OCR’d version of the input or provided word
boxes).
"""
words: List[int]
"""The index of each word/box pair that is in the answer"""
6 changes: 2 additions & 4 deletions src/huggingface_hub/inference/_generated/types/fill_mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@

@dataclass
class FillMaskParameters(BaseInferenceType):
"""Additional inference parameters
Additional inference parameters for Fill Mask
"""
"""Additional inference parameters for Fill Mask"""

targets: Optional[List[str]] = None
"""When passed, the model will limit the scores to the passed targets instead of looking up
Expand All @@ -32,7 +30,7 @@ class FillMaskInput(BaseInferenceType):
inputs: str
"""The text with masked tokens"""
parameters: Optional[FillMaskParameters] = None
"""Additional inference parameters"""
"""Additional inference parameters for Fill Mask"""


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@

@dataclass
class ImageClassificationParameters(BaseInferenceType):
"""Additional inference parameters
Additional inference parameters for Image Classification
"""
"""Additional inference parameters for Image Classification"""

function_to_apply: Optional["ImageClassificationOutputTransform"] = None
"""The function to apply to the output."""
"""The function to apply to the model outputs in order to retrieve the scores."""
top_k: Optional[int] = None
"""When specified, limits the output to the top K most probable classes."""

Expand All @@ -33,7 +31,7 @@ class ImageClassificationInput(BaseInferenceType):
also provide the image data as a raw bytes payload.
"""
parameters: Optional[ImageClassificationParameters] = None
"""Additional inference parameters"""
"""Additional inference parameters for Image Classification"""


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@

@dataclass
class ImageSegmentationParameters(BaseInferenceType):
"""Additional inference parameters
Additional inference parameters for Image Segmentation
"""
"""Additional inference parameters for Image Segmentation"""

mask_threshold: Optional[float] = None
"""Threshold to use when turning the predicted masks into binary values."""
Expand All @@ -37,7 +35,7 @@ class ImageSegmentationInput(BaseInferenceType):
also provide the image data as a raw bytes payload.
"""
parameters: Optional[ImageSegmentationParameters] = None
"""Additional inference parameters"""
"""Additional inference parameters for Image Segmentation"""


@dataclass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ class ImageToImageTargetSize(BaseInferenceType):

@dataclass
class ImageToImageParameters(BaseInferenceType):
"""Additional inference parameters
Additional inference parameters for Image To Image
"""
"""Additional inference parameters for Image To Image"""

guidance_scale: Optional[float] = None
"""For diffusion models. A higher guidance scale value encourages the model to generate
Expand All @@ -46,7 +44,7 @@ class ImageToImageInput(BaseInferenceType):
also provide the image data as a raw bytes payload.
"""
parameters: Optional[ImageToImageParameters] = None
"""Additional inference parameters"""
"""Additional inference parameters for Image To Image"""


@dataclass
Expand Down
Loading

0 comments on commit a6e1cd2

Please sign in to comment.