huggingface-hub 0.26.5__py3-none-any.whl → 0.27.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of huggingface-hub might be problematic. Click here for more details.
- huggingface_hub/__init__.py +49 -23
- huggingface_hub/_commit_scheduler.py +30 -4
- huggingface_hub/_local_folder.py +0 -4
- huggingface_hub/_login.py +38 -54
- huggingface_hub/_snapshot_download.py +6 -3
- huggingface_hub/_tensorboard_logger.py +2 -3
- huggingface_hub/_upload_large_folder.py +1 -1
- huggingface_hub/errors.py +19 -0
- huggingface_hub/fastai_utils.py +3 -2
- huggingface_hub/file_download.py +10 -12
- huggingface_hub/hf_api.py +102 -498
- huggingface_hub/hf_file_system.py +274 -35
- huggingface_hub/hub_mixin.py +5 -25
- huggingface_hub/inference/_client.py +185 -136
- huggingface_hub/inference/_common.py +2 -2
- huggingface_hub/inference/_generated/_async_client.py +186 -137
- huggingface_hub/inference/_generated/types/__init__.py +31 -10
- huggingface_hub/inference/_generated/types/audio_classification.py +3 -5
- huggingface_hub/inference/_generated/types/automatic_speech_recognition.py +6 -9
- huggingface_hub/inference/_generated/types/chat_completion.py +8 -5
- huggingface_hub/inference/_generated/types/depth_estimation.py +1 -1
- huggingface_hub/inference/_generated/types/document_question_answering.py +2 -6
- huggingface_hub/inference/_generated/types/feature_extraction.py +1 -1
- huggingface_hub/inference/_generated/types/fill_mask.py +2 -4
- huggingface_hub/inference/_generated/types/image_classification.py +3 -5
- huggingface_hub/inference/_generated/types/image_segmentation.py +2 -4
- huggingface_hub/inference/_generated/types/image_to_image.py +2 -4
- huggingface_hub/inference/_generated/types/image_to_text.py +6 -9
- huggingface_hub/inference/_generated/types/object_detection.py +2 -4
- huggingface_hub/inference/_generated/types/question_answering.py +2 -4
- huggingface_hub/inference/_generated/types/sentence_similarity.py +1 -1
- huggingface_hub/inference/_generated/types/summarization.py +2 -4
- huggingface_hub/inference/_generated/types/table_question_answering.py +21 -3
- huggingface_hub/inference/_generated/types/text2text_generation.py +2 -4
- huggingface_hub/inference/_generated/types/text_classification.py +4 -10
- huggingface_hub/inference/_generated/types/text_to_audio.py +7 -10
- huggingface_hub/inference/_generated/types/text_to_image.py +2 -4
- huggingface_hub/inference/_generated/types/text_to_speech.py +7 -10
- huggingface_hub/inference/_generated/types/token_classification.py +11 -12
- huggingface_hub/inference/_generated/types/translation.py +2 -4
- huggingface_hub/inference/_generated/types/video_classification.py +3 -4
- huggingface_hub/inference/_generated/types/visual_question_answering.py +2 -5
- huggingface_hub/inference/_generated/types/zero_shot_classification.py +8 -18
- huggingface_hub/inference/_generated/types/zero_shot_image_classification.py +9 -19
- huggingface_hub/inference/_generated/types/zero_shot_object_detection.py +7 -9
- huggingface_hub/keras_mixin.py +3 -2
- huggingface_hub/lfs.py +2 -5
- huggingface_hub/repocard_data.py +4 -4
- huggingface_hub/serialization/__init__.py +2 -0
- huggingface_hub/serialization/_dduf.py +387 -0
- huggingface_hub/serialization/_torch.py +372 -14
- huggingface_hub/utils/_cache_manager.py +1 -1
- huggingface_hub/utils/_headers.py +9 -25
- huggingface_hub/utils/tqdm.py +15 -0
- {huggingface_hub-0.26.5.dist-info → huggingface_hub-0.27.0.dist-info}/METADATA +8 -3
- {huggingface_hub-0.26.5.dist-info → huggingface_hub-0.27.0.dist-info}/RECORD +60 -60
- huggingface_hub/_multi_commits.py +0 -306
- {huggingface_hub-0.26.5.dist-info → huggingface_hub-0.27.0.dist-info}/LICENSE +0 -0
- {huggingface_hub-0.26.5.dist-info → huggingface_hub-0.27.0.dist-info}/WHEEL +0 -0
- {huggingface_hub-0.26.5.dist-info → huggingface_hub-0.27.0.dist-info}/entry_points.txt +0 -0
- {huggingface_hub-0.26.5.dist-info → huggingface_hub-0.27.0.dist-info}/top_level.txt +0 -0
|
@@ -24,10 +24,14 @@ from .chat_completion import (
|
|
|
24
24
|
ChatCompletionInputFunctionDefinition,
|
|
25
25
|
ChatCompletionInputFunctionName,
|
|
26
26
|
ChatCompletionInputGrammarType,
|
|
27
|
+
ChatCompletionInputGrammarTypeType,
|
|
27
28
|
ChatCompletionInputMessage,
|
|
28
29
|
ChatCompletionInputMessageChunk,
|
|
30
|
+
ChatCompletionInputMessageChunkType,
|
|
29
31
|
ChatCompletionInputStreamOptions,
|
|
30
|
-
|
|
32
|
+
ChatCompletionInputTool,
|
|
33
|
+
ChatCompletionInputToolChoiceClass,
|
|
34
|
+
ChatCompletionInputToolChoiceEnum,
|
|
31
35
|
ChatCompletionInputURL,
|
|
32
36
|
ChatCompletionOutput,
|
|
33
37
|
ChatCompletionOutputComplete,
|
|
@@ -47,7 +51,6 @@ from .chat_completion import (
|
|
|
47
51
|
ChatCompletionStreamOutputLogprobs,
|
|
48
52
|
ChatCompletionStreamOutputTopLogprob,
|
|
49
53
|
ChatCompletionStreamOutputUsage,
|
|
50
|
-
ToolElement,
|
|
51
54
|
)
|
|
52
55
|
from .depth_estimation import DepthEstimationInput, DepthEstimationOutput
|
|
53
56
|
from .document_question_answering import (
|
|
@@ -56,7 +59,7 @@ from .document_question_answering import (
|
|
|
56
59
|
DocumentQuestionAnsweringOutputElement,
|
|
57
60
|
DocumentQuestionAnsweringParameters,
|
|
58
61
|
)
|
|
59
|
-
from .feature_extraction import FeatureExtractionInput
|
|
62
|
+
from .feature_extraction import FeatureExtractionInput, FeatureExtractionInputTruncationDirection
|
|
60
63
|
from .fill_mask import FillMaskInput, FillMaskOutputElement, FillMaskParameters
|
|
61
64
|
from .image_classification import (
|
|
62
65
|
ImageClassificationInput,
|
|
@@ -64,7 +67,12 @@ from .image_classification import (
|
|
|
64
67
|
ImageClassificationOutputTransform,
|
|
65
68
|
ImageClassificationParameters,
|
|
66
69
|
)
|
|
67
|
-
from .image_segmentation import
|
|
70
|
+
from .image_segmentation import (
|
|
71
|
+
ImageSegmentationInput,
|
|
72
|
+
ImageSegmentationOutputElement,
|
|
73
|
+
ImageSegmentationParameters,
|
|
74
|
+
ImageSegmentationSubtask,
|
|
75
|
+
)
|
|
68
76
|
from .image_to_image import ImageToImageInput, ImageToImageOutput, ImageToImageParameters, ImageToImageTargetSize
|
|
69
77
|
from .image_to_text import (
|
|
70
78
|
ImageToTextEarlyStoppingEnum,
|
|
@@ -86,13 +94,25 @@ from .question_answering import (
|
|
|
86
94
|
QuestionAnsweringParameters,
|
|
87
95
|
)
|
|
88
96
|
from .sentence_similarity import SentenceSimilarityInput, SentenceSimilarityInputData
|
|
89
|
-
from .summarization import
|
|
97
|
+
from .summarization import (
|
|
98
|
+
SummarizationInput,
|
|
99
|
+
SummarizationOutput,
|
|
100
|
+
SummarizationParameters,
|
|
101
|
+
SummarizationTruncationStrategy,
|
|
102
|
+
)
|
|
90
103
|
from .table_question_answering import (
|
|
104
|
+
Padding,
|
|
91
105
|
TableQuestionAnsweringInput,
|
|
92
106
|
TableQuestionAnsweringInputData,
|
|
93
107
|
TableQuestionAnsweringOutputElement,
|
|
108
|
+
TableQuestionAnsweringParameters,
|
|
109
|
+
)
|
|
110
|
+
from .text2text_generation import (
|
|
111
|
+
Text2TextGenerationInput,
|
|
112
|
+
Text2TextGenerationOutput,
|
|
113
|
+
Text2TextGenerationParameters,
|
|
114
|
+
Text2TextGenerationTruncationStrategy,
|
|
94
115
|
)
|
|
95
|
-
from .text2text_generation import Text2TextGenerationInput, Text2TextGenerationOutput, Text2TextGenerationParameters
|
|
96
116
|
from .text_classification import (
|
|
97
117
|
TextClassificationInput,
|
|
98
118
|
TextClassificationOutputElement,
|
|
@@ -106,11 +126,13 @@ from .text_generation import (
|
|
|
106
126
|
TextGenerationOutput,
|
|
107
127
|
TextGenerationOutputBestOfSequence,
|
|
108
128
|
TextGenerationOutputDetails,
|
|
129
|
+
TextGenerationOutputFinishReason,
|
|
109
130
|
TextGenerationOutputPrefillToken,
|
|
110
131
|
TextGenerationOutputToken,
|
|
111
132
|
TextGenerationStreamOutput,
|
|
112
133
|
TextGenerationStreamOutputStreamDetails,
|
|
113
134
|
TextGenerationStreamOutputToken,
|
|
135
|
+
TypeEnum,
|
|
114
136
|
)
|
|
115
137
|
from .text_to_audio import (
|
|
116
138
|
TextToAudioEarlyStoppingEnum,
|
|
@@ -128,11 +150,12 @@ from .text_to_speech import (
|
|
|
128
150
|
TextToSpeechParameters,
|
|
129
151
|
)
|
|
130
152
|
from .token_classification import (
|
|
153
|
+
TokenClassificationAggregationStrategy,
|
|
131
154
|
TokenClassificationInput,
|
|
132
155
|
TokenClassificationOutputElement,
|
|
133
156
|
TokenClassificationParameters,
|
|
134
157
|
)
|
|
135
|
-
from .translation import TranslationInput, TranslationOutput, TranslationParameters
|
|
158
|
+
from .translation import TranslationInput, TranslationOutput, TranslationParameters, TranslationTruncationStrategy
|
|
136
159
|
from .video_classification import (
|
|
137
160
|
VideoClassificationInput,
|
|
138
161
|
VideoClassificationOutputElement,
|
|
@@ -147,19 +170,17 @@ from .visual_question_answering import (
|
|
|
147
170
|
)
|
|
148
171
|
from .zero_shot_classification import (
|
|
149
172
|
ZeroShotClassificationInput,
|
|
150
|
-
ZeroShotClassificationInputData,
|
|
151
173
|
ZeroShotClassificationOutputElement,
|
|
152
174
|
ZeroShotClassificationParameters,
|
|
153
175
|
)
|
|
154
176
|
from .zero_shot_image_classification import (
|
|
155
177
|
ZeroShotImageClassificationInput,
|
|
156
|
-
ZeroShotImageClassificationInputData,
|
|
157
178
|
ZeroShotImageClassificationOutputElement,
|
|
158
179
|
ZeroShotImageClassificationParameters,
|
|
159
180
|
)
|
|
160
181
|
from .zero_shot_object_detection import (
|
|
161
182
|
ZeroShotObjectDetectionBoundingBox,
|
|
162
183
|
ZeroShotObjectDetectionInput,
|
|
163
|
-
ZeroShotObjectDetectionInputData,
|
|
164
184
|
ZeroShotObjectDetectionOutputElement,
|
|
185
|
+
ZeroShotObjectDetectionParameters,
|
|
165
186
|
)
|
|
@@ -14,12 +14,10 @@ AudioClassificationOutputTransform = Literal["sigmoid", "softmax", "none"]
|
|
|
14
14
|
|
|
15
15
|
@dataclass
|
|
16
16
|
class AudioClassificationParameters(BaseInferenceType):
|
|
17
|
-
"""Additional inference parameters
|
|
18
|
-
Additional inference parameters for Audio Classification
|
|
19
|
-
"""
|
|
17
|
+
"""Additional inference parameters for Audio Classification"""
|
|
20
18
|
|
|
21
19
|
function_to_apply: Optional["AudioClassificationOutputTransform"] = None
|
|
22
|
-
"""The function to apply to the
|
|
20
|
+
"""The function to apply to the model outputs in order to retrieve the scores."""
|
|
23
21
|
top_k: Optional[int] = None
|
|
24
22
|
"""When specified, limits the output to the top K most probable classes."""
|
|
25
23
|
|
|
@@ -33,7 +31,7 @@ class AudioClassificationInput(BaseInferenceType):
|
|
|
33
31
|
also provide the audio data as a raw bytes payload.
|
|
34
32
|
"""
|
|
35
33
|
parameters: Optional[AudioClassificationParameters] = None
|
|
36
|
-
"""Additional inference parameters"""
|
|
34
|
+
"""Additional inference parameters for Audio Classification"""
|
|
37
35
|
|
|
38
36
|
|
|
39
37
|
@dataclass
|
|
@@ -14,9 +14,7 @@ AutomaticSpeechRecognitionEarlyStoppingEnum = Literal["never"]
|
|
|
14
14
|
|
|
15
15
|
@dataclass
|
|
16
16
|
class AutomaticSpeechRecognitionGenerationParameters(BaseInferenceType):
|
|
17
|
-
"""Parametrization of the text generation process
|
|
18
|
-
Ad-hoc parametrization of the text generation process
|
|
19
|
-
"""
|
|
17
|
+
"""Parametrization of the text generation process"""
|
|
20
18
|
|
|
21
19
|
do_sample: Optional[bool] = None
|
|
22
20
|
"""Whether to use sampling instead of greedy decoding when generating new tokens."""
|
|
@@ -76,14 +74,13 @@ class AutomaticSpeechRecognitionGenerationParameters(BaseInferenceType):
|
|
|
76
74
|
|
|
77
75
|
@dataclass
|
|
78
76
|
class AutomaticSpeechRecognitionParameters(BaseInferenceType):
|
|
79
|
-
"""Additional inference parameters
|
|
80
|
-
Additional inference parameters for Automatic Speech Recognition
|
|
81
|
-
"""
|
|
77
|
+
"""Additional inference parameters for Automatic Speech Recognition"""
|
|
82
78
|
|
|
83
|
-
generate: Optional[AutomaticSpeechRecognitionGenerationParameters] = None
|
|
84
|
-
"""Parametrization of the text generation process"""
|
|
85
79
|
return_timestamps: Optional[bool] = None
|
|
86
80
|
"""Whether to output corresponding timestamps with the generated text"""
|
|
81
|
+
# Will be deprecated in the future when the renaming to `generation_parameters` is implemented in transformers
|
|
82
|
+
generate_kwargs: Optional[AutomaticSpeechRecognitionGenerationParameters] = None
|
|
83
|
+
"""Parametrization of the text generation process"""
|
|
87
84
|
|
|
88
85
|
|
|
89
86
|
@dataclass
|
|
@@ -95,7 +92,7 @@ class AutomaticSpeechRecognitionInput(BaseInferenceType):
|
|
|
95
92
|
also provide the audio data as a raw bytes payload.
|
|
96
93
|
"""
|
|
97
94
|
parameters: Optional[AutomaticSpeechRecognitionParameters] = None
|
|
98
|
-
"""Additional inference parameters"""
|
|
95
|
+
"""Additional inference parameters for Automatic Speech Recognition"""
|
|
99
96
|
|
|
100
97
|
|
|
101
98
|
@dataclass
|
|
@@ -60,8 +60,11 @@ class ChatCompletionInputFunctionName(BaseInferenceType):
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
@dataclass
|
|
63
|
-
class
|
|
64
|
-
function:
|
|
63
|
+
class ChatCompletionInputToolChoiceClass(BaseInferenceType):
|
|
64
|
+
function: ChatCompletionInputFunctionName
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
ChatCompletionInputToolChoiceEnum = Literal["auto", "none", "required"]
|
|
65
68
|
|
|
66
69
|
|
|
67
70
|
@dataclass
|
|
@@ -72,7 +75,7 @@ class ChatCompletionInputFunctionDefinition(BaseInferenceType):
|
|
|
72
75
|
|
|
73
76
|
|
|
74
77
|
@dataclass
|
|
75
|
-
class
|
|
78
|
+
class ChatCompletionInputTool(BaseInferenceType):
|
|
76
79
|
function: ChatCompletionInputFunctionDefinition
|
|
77
80
|
type: str
|
|
78
81
|
|
|
@@ -138,10 +141,10 @@ class ChatCompletionInput(BaseInferenceType):
|
|
|
138
141
|
lower values like 0.2 will make it more focused and deterministic.
|
|
139
142
|
We generally recommend altering this or `top_p` but not both.
|
|
140
143
|
"""
|
|
141
|
-
tool_choice: Optional[Union[
|
|
144
|
+
tool_choice: Optional[Union[ChatCompletionInputToolChoiceClass, "ChatCompletionInputToolChoiceEnum"]] = None
|
|
142
145
|
tool_prompt: Optional[str] = None
|
|
143
146
|
"""A prompt to be appended before the tools"""
|
|
144
|
-
tools: Optional[List[
|
|
147
|
+
tools: Optional[List[ChatCompletionInputTool]] = None
|
|
145
148
|
"""A list of tools the model may call. Currently, only functions are supported as a tool.
|
|
146
149
|
Use this to provide a list of
|
|
147
150
|
functions the model may generate JSON inputs for.
|
|
@@ -16,7 +16,7 @@ class DepthEstimationInput(BaseInferenceType):
|
|
|
16
16
|
inputs: Any
|
|
17
17
|
"""The input image data"""
|
|
18
18
|
parameters: Optional[Dict[str, Any]] = None
|
|
19
|
-
"""Additional inference parameters"""
|
|
19
|
+
"""Additional inference parameters for Depth Estimation"""
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
@dataclass
|
|
@@ -21,9 +21,7 @@ class DocumentQuestionAnsweringInputData(BaseInferenceType):
|
|
|
21
21
|
|
|
22
22
|
@dataclass
|
|
23
23
|
class DocumentQuestionAnsweringParameters(BaseInferenceType):
|
|
24
|
-
"""Additional inference parameters
|
|
25
|
-
Additional inference parameters for Document Question Answering
|
|
26
|
-
"""
|
|
24
|
+
"""Additional inference parameters for Document Question Answering"""
|
|
27
25
|
|
|
28
26
|
doc_stride: Optional[int] = None
|
|
29
27
|
"""If the words in the document are too long to fit with the question for the model, it will
|
|
@@ -62,7 +60,7 @@ class DocumentQuestionAnsweringInput(BaseInferenceType):
|
|
|
62
60
|
inputs: DocumentQuestionAnsweringInputData
|
|
63
61
|
"""One (document, question) pair to answer"""
|
|
64
62
|
parameters: Optional[DocumentQuestionAnsweringParameters] = None
|
|
65
|
-
"""Additional inference parameters"""
|
|
63
|
+
"""Additional inference parameters for Document Question Answering"""
|
|
66
64
|
|
|
67
65
|
|
|
68
66
|
@dataclass
|
|
@@ -81,5 +79,3 @@ class DocumentQuestionAnsweringOutputElement(BaseInferenceType):
|
|
|
81
79
|
"""The start word index of the answer (in the OCR’d version of the input or provided word
|
|
82
80
|
boxes).
|
|
83
81
|
"""
|
|
84
|
-
words: List[int]
|
|
85
|
-
"""The index of each word/box pair that is in the answer"""
|
|
@@ -26,7 +26,7 @@ class FeatureExtractionInput(BaseInferenceType):
|
|
|
26
26
|
prompt_name: Optional[str] = None
|
|
27
27
|
"""The name of the prompt that should be used by for encoding. If not set, no prompt
|
|
28
28
|
will be applied.
|
|
29
|
-
Must be a key in the `
|
|
29
|
+
Must be a key in the `sentence-transformers` configuration `prompts` dictionary.
|
|
30
30
|
For example if ``prompt_name`` is "query" and the ``prompts`` is {"query": "query: ",
|
|
31
31
|
...},
|
|
32
32
|
then the sentence "What is the capital of France?" will be encoded as
|
|
@@ -11,9 +11,7 @@ from .base import BaseInferenceType
|
|
|
11
11
|
|
|
12
12
|
@dataclass
|
|
13
13
|
class FillMaskParameters(BaseInferenceType):
|
|
14
|
-
"""Additional inference parameters
|
|
15
|
-
Additional inference parameters for Fill Mask
|
|
16
|
-
"""
|
|
14
|
+
"""Additional inference parameters for Fill Mask"""
|
|
17
15
|
|
|
18
16
|
targets: Optional[List[str]] = None
|
|
19
17
|
"""When passed, the model will limit the scores to the passed targets instead of looking up
|
|
@@ -32,7 +30,7 @@ class FillMaskInput(BaseInferenceType):
|
|
|
32
30
|
inputs: str
|
|
33
31
|
"""The text with masked tokens"""
|
|
34
32
|
parameters: Optional[FillMaskParameters] = None
|
|
35
|
-
"""Additional inference parameters"""
|
|
33
|
+
"""Additional inference parameters for Fill Mask"""
|
|
36
34
|
|
|
37
35
|
|
|
38
36
|
@dataclass
|
|
@@ -14,12 +14,10 @@ ImageClassificationOutputTransform = Literal["sigmoid", "softmax", "none"]
|
|
|
14
14
|
|
|
15
15
|
@dataclass
|
|
16
16
|
class ImageClassificationParameters(BaseInferenceType):
|
|
17
|
-
"""Additional inference parameters
|
|
18
|
-
Additional inference parameters for Image Classification
|
|
19
|
-
"""
|
|
17
|
+
"""Additional inference parameters for Image Classification"""
|
|
20
18
|
|
|
21
19
|
function_to_apply: Optional["ImageClassificationOutputTransform"] = None
|
|
22
|
-
"""The function to apply to the
|
|
20
|
+
"""The function to apply to the model outputs in order to retrieve the scores."""
|
|
23
21
|
top_k: Optional[int] = None
|
|
24
22
|
"""When specified, limits the output to the top K most probable classes."""
|
|
25
23
|
|
|
@@ -33,7 +31,7 @@ class ImageClassificationInput(BaseInferenceType):
|
|
|
33
31
|
also provide the image data as a raw bytes payload.
|
|
34
32
|
"""
|
|
35
33
|
parameters: Optional[ImageClassificationParameters] = None
|
|
36
|
-
"""Additional inference parameters"""
|
|
34
|
+
"""Additional inference parameters for Image Classification"""
|
|
37
35
|
|
|
38
36
|
|
|
39
37
|
@dataclass
|
|
@@ -14,9 +14,7 @@ ImageSegmentationSubtask = Literal["instance", "panoptic", "semantic"]
|
|
|
14
14
|
|
|
15
15
|
@dataclass
|
|
16
16
|
class ImageSegmentationParameters(BaseInferenceType):
|
|
17
|
-
"""Additional inference parameters
|
|
18
|
-
Additional inference parameters for Image Segmentation
|
|
19
|
-
"""
|
|
17
|
+
"""Additional inference parameters for Image Segmentation"""
|
|
20
18
|
|
|
21
19
|
mask_threshold: Optional[float] = None
|
|
22
20
|
"""Threshold to use when turning the predicted masks into binary values."""
|
|
@@ -37,7 +35,7 @@ class ImageSegmentationInput(BaseInferenceType):
|
|
|
37
35
|
also provide the image data as a raw bytes payload.
|
|
38
36
|
"""
|
|
39
37
|
parameters: Optional[ImageSegmentationParameters] = None
|
|
40
|
-
"""Additional inference parameters"""
|
|
38
|
+
"""Additional inference parameters for Image Segmentation"""
|
|
41
39
|
|
|
42
40
|
|
|
43
41
|
@dataclass
|
|
@@ -19,9 +19,7 @@ class ImageToImageTargetSize(BaseInferenceType):
|
|
|
19
19
|
|
|
20
20
|
@dataclass
|
|
21
21
|
class ImageToImageParameters(BaseInferenceType):
|
|
22
|
-
"""Additional inference parameters
|
|
23
|
-
Additional inference parameters for Image To Image
|
|
24
|
-
"""
|
|
22
|
+
"""Additional inference parameters for Image To Image"""
|
|
25
23
|
|
|
26
24
|
guidance_scale: Optional[float] = None
|
|
27
25
|
"""For diffusion models. A higher guidance scale value encourages the model to generate
|
|
@@ -46,7 +44,7 @@ class ImageToImageInput(BaseInferenceType):
|
|
|
46
44
|
also provide the image data as a raw bytes payload.
|
|
47
45
|
"""
|
|
48
46
|
parameters: Optional[ImageToImageParameters] = None
|
|
49
|
-
"""Additional inference parameters"""
|
|
47
|
+
"""Additional inference parameters for Image To Image"""
|
|
50
48
|
|
|
51
49
|
|
|
52
50
|
@dataclass
|
|
@@ -14,9 +14,7 @@ ImageToTextEarlyStoppingEnum = Literal["never"]
|
|
|
14
14
|
|
|
15
15
|
@dataclass
|
|
16
16
|
class ImageToTextGenerationParameters(BaseInferenceType):
|
|
17
|
-
"""Parametrization of the text generation process
|
|
18
|
-
Ad-hoc parametrization of the text generation process
|
|
19
|
-
"""
|
|
17
|
+
"""Parametrization of the text generation process"""
|
|
20
18
|
|
|
21
19
|
do_sample: Optional[bool] = None
|
|
22
20
|
"""Whether to use sampling instead of greedy decoding when generating new tokens."""
|
|
@@ -76,14 +74,13 @@ class ImageToTextGenerationParameters(BaseInferenceType):
|
|
|
76
74
|
|
|
77
75
|
@dataclass
|
|
78
76
|
class ImageToTextParameters(BaseInferenceType):
|
|
79
|
-
"""Additional inference parameters
|
|
80
|
-
Additional inference parameters for Image To Text
|
|
81
|
-
"""
|
|
77
|
+
"""Additional inference parameters for Image To Text"""
|
|
82
78
|
|
|
83
|
-
generate: Optional[ImageToTextGenerationParameters] = None
|
|
84
|
-
"""Parametrization of the text generation process"""
|
|
85
79
|
max_new_tokens: Optional[int] = None
|
|
86
80
|
"""The amount of maximum tokens to generate."""
|
|
81
|
+
# Will be deprecated in the future when the renaming to `generation_parameters` is implemented in transformers
|
|
82
|
+
generate_kwargs: Optional[ImageToTextGenerationParameters] = None
|
|
83
|
+
"""Parametrization of the text generation process"""
|
|
87
84
|
|
|
88
85
|
|
|
89
86
|
@dataclass
|
|
@@ -93,7 +90,7 @@ class ImageToTextInput(BaseInferenceType):
|
|
|
93
90
|
inputs: Any
|
|
94
91
|
"""The input image data"""
|
|
95
92
|
parameters: Optional[ImageToTextParameters] = None
|
|
96
|
-
"""Additional inference parameters"""
|
|
93
|
+
"""Additional inference parameters for Image To Text"""
|
|
97
94
|
|
|
98
95
|
|
|
99
96
|
@dataclass
|
|
@@ -11,9 +11,7 @@ from .base import BaseInferenceType
|
|
|
11
11
|
|
|
12
12
|
@dataclass
|
|
13
13
|
class ObjectDetectionParameters(BaseInferenceType):
|
|
14
|
-
"""Additional inference parameters
|
|
15
|
-
Additional inference parameters for Object Detection
|
|
16
|
-
"""
|
|
14
|
+
"""Additional inference parameters for Object Detection"""
|
|
17
15
|
|
|
18
16
|
threshold: Optional[float] = None
|
|
19
17
|
"""The probability necessary to make a prediction."""
|
|
@@ -28,7 +26,7 @@ class ObjectDetectionInput(BaseInferenceType):
|
|
|
28
26
|
also provide the image data as a raw bytes payload.
|
|
29
27
|
"""
|
|
30
28
|
parameters: Optional[ObjectDetectionParameters] = None
|
|
31
|
-
"""Additional inference parameters"""
|
|
29
|
+
"""Additional inference parameters for Object Detection"""
|
|
32
30
|
|
|
33
31
|
|
|
34
32
|
@dataclass
|
|
@@ -21,9 +21,7 @@ class QuestionAnsweringInputData(BaseInferenceType):
|
|
|
21
21
|
|
|
22
22
|
@dataclass
|
|
23
23
|
class QuestionAnsweringParameters(BaseInferenceType):
|
|
24
|
-
"""Additional inference parameters
|
|
25
|
-
Additional inference parameters for Question Answering
|
|
26
|
-
"""
|
|
24
|
+
"""Additional inference parameters for Question Answering"""
|
|
27
25
|
|
|
28
26
|
align_to_words: Optional[bool] = None
|
|
29
27
|
"""Attempts to align the answer to real words. Improves quality on space separated
|
|
@@ -60,7 +58,7 @@ class QuestionAnsweringInput(BaseInferenceType):
|
|
|
60
58
|
inputs: QuestionAnsweringInputData
|
|
61
59
|
"""One (context, question) pair to answer"""
|
|
62
60
|
parameters: Optional[QuestionAnsweringParameters] = None
|
|
63
|
-
"""Additional inference parameters"""
|
|
61
|
+
"""Additional inference parameters for Question Answering"""
|
|
64
62
|
|
|
65
63
|
|
|
66
64
|
@dataclass
|
|
@@ -14,9 +14,7 @@ SummarizationTruncationStrategy = Literal["do_not_truncate", "longest_first", "o
|
|
|
14
14
|
|
|
15
15
|
@dataclass
|
|
16
16
|
class SummarizationParameters(BaseInferenceType):
|
|
17
|
-
"""Additional inference parameters.
|
|
18
|
-
Additional inference parameters for summarization.
|
|
19
|
-
"""
|
|
17
|
+
"""Additional inference parameters for summarization."""
|
|
20
18
|
|
|
21
19
|
clean_up_tokenization_spaces: Optional[bool] = None
|
|
22
20
|
"""Whether to clean up the potential extra spaces in the text output."""
|
|
@@ -33,7 +31,7 @@ class SummarizationInput(BaseInferenceType):
|
|
|
33
31
|
inputs: str
|
|
34
32
|
"""The input text to summarize."""
|
|
35
33
|
parameters: Optional[SummarizationParameters] = None
|
|
36
|
-
"""Additional inference parameters."""
|
|
34
|
+
"""Additional inference parameters for summarization."""
|
|
37
35
|
|
|
38
36
|
|
|
39
37
|
@dataclass
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# - script: https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-codegen.ts
|
|
5
5
|
# - specs: https://github.com/huggingface/huggingface.js/tree/main/packages/tasks/src/tasks.
|
|
6
6
|
from dataclasses import dataclass
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import Dict, List, Literal, Optional
|
|
8
8
|
|
|
9
9
|
from .base import BaseInferenceType
|
|
10
10
|
|
|
@@ -19,14 +19,32 @@ class TableQuestionAnsweringInputData(BaseInferenceType):
|
|
|
19
19
|
"""The table to serve as context for the questions"""
|
|
20
20
|
|
|
21
21
|
|
|
22
|
+
Padding = Literal["do_not_pad", "longest", "max_length"]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
@dataclass
|
|
26
|
+
class TableQuestionAnsweringParameters(BaseInferenceType):
|
|
27
|
+
"""Additional inference parameters for Table Question Answering"""
|
|
28
|
+
|
|
29
|
+
padding: Optional["Padding"] = None
|
|
30
|
+
"""Activates and controls padding."""
|
|
31
|
+
sequential: Optional[bool] = None
|
|
32
|
+
"""Whether to do inference sequentially or as a batch. Batching is faster, but models like
|
|
33
|
+
SQA require the inference to be done sequentially to extract relations within sequences,
|
|
34
|
+
given their conversational nature.
|
|
35
|
+
"""
|
|
36
|
+
truncation: Optional[bool] = None
|
|
37
|
+
"""Activates and controls truncation."""
|
|
38
|
+
|
|
39
|
+
|
|
22
40
|
@dataclass
|
|
23
41
|
class TableQuestionAnsweringInput(BaseInferenceType):
|
|
24
42
|
"""Inputs for Table Question Answering inference"""
|
|
25
43
|
|
|
26
44
|
inputs: TableQuestionAnsweringInputData
|
|
27
45
|
"""One (table, question) pair to answer"""
|
|
28
|
-
parameters: Optional[
|
|
29
|
-
"""Additional inference parameters"""
|
|
46
|
+
parameters: Optional[TableQuestionAnsweringParameters] = None
|
|
47
|
+
"""Additional inference parameters for Table Question Answering"""
|
|
30
48
|
|
|
31
49
|
|
|
32
50
|
@dataclass
|
|
@@ -14,9 +14,7 @@ Text2TextGenerationTruncationStrategy = Literal["do_not_truncate", "longest_firs
|
|
|
14
14
|
|
|
15
15
|
@dataclass
|
|
16
16
|
class Text2TextGenerationParameters(BaseInferenceType):
|
|
17
|
-
"""Additional inference parameters
|
|
18
|
-
Additional inference parameters for Text2text Generation
|
|
19
|
-
"""
|
|
17
|
+
"""Additional inference parameters for Text2text Generation"""
|
|
20
18
|
|
|
21
19
|
clean_up_tokenization_spaces: Optional[bool] = None
|
|
22
20
|
"""Whether to clean up the potential extra spaces in the text output."""
|
|
@@ -33,7 +31,7 @@ class Text2TextGenerationInput(BaseInferenceType):
|
|
|
33
31
|
inputs: str
|
|
34
32
|
"""The input text data"""
|
|
35
33
|
parameters: Optional[Text2TextGenerationParameters] = None
|
|
36
|
-
"""Additional inference parameters"""
|
|
34
|
+
"""Additional inference parameters for Text2text Generation"""
|
|
37
35
|
|
|
38
36
|
|
|
39
37
|
@dataclass
|
|
@@ -14,18 +14,12 @@ TextClassificationOutputTransform = Literal["sigmoid", "softmax", "none"]
|
|
|
14
14
|
|
|
15
15
|
@dataclass
|
|
16
16
|
class TextClassificationParameters(BaseInferenceType):
|
|
17
|
-
"""
|
|
18
|
-
Additional inference parameters for Text Classification.
|
|
19
|
-
"""
|
|
17
|
+
"""Additional inference parameters for Text Classification"""
|
|
20
18
|
|
|
21
19
|
function_to_apply: Optional["TextClassificationOutputTransform"] = None
|
|
22
|
-
"""
|
|
23
|
-
The function to apply to the output.
|
|
24
|
-
"""
|
|
20
|
+
"""The function to apply to the model outputs in order to retrieve the scores."""
|
|
25
21
|
top_k: Optional[int] = None
|
|
26
|
-
"""
|
|
27
|
-
When specified, limits the output to the top K most probable classes.
|
|
28
|
-
"""
|
|
22
|
+
"""When specified, limits the output to the top K most probable classes."""
|
|
29
23
|
|
|
30
24
|
|
|
31
25
|
@dataclass
|
|
@@ -35,7 +29,7 @@ class TextClassificationInput(BaseInferenceType):
|
|
|
35
29
|
inputs: str
|
|
36
30
|
"""The text to classify"""
|
|
37
31
|
parameters: Optional[TextClassificationParameters] = None
|
|
38
|
-
"""Additional inference parameters"""
|
|
32
|
+
"""Additional inference parameters for Text Classification"""
|
|
39
33
|
|
|
40
34
|
|
|
41
35
|
@dataclass
|
|
@@ -14,9 +14,7 @@ TextToAudioEarlyStoppingEnum = Literal["never"]
|
|
|
14
14
|
|
|
15
15
|
@dataclass
|
|
16
16
|
class TextToAudioGenerationParameters(BaseInferenceType):
|
|
17
|
-
"""Parametrization of the text generation process
|
|
18
|
-
Ad-hoc parametrization of the text generation process
|
|
19
|
-
"""
|
|
17
|
+
"""Parametrization of the text generation process"""
|
|
20
18
|
|
|
21
19
|
do_sample: Optional[bool] = None
|
|
22
20
|
"""Whether to use sampling instead of greedy decoding when generating new tokens."""
|
|
@@ -40,11 +38,11 @@ class TextToAudioGenerationParameters(BaseInferenceType):
|
|
|
40
38
|
max_length: Optional[int] = None
|
|
41
39
|
"""The maximum length (in tokens) of the generated text, including the input."""
|
|
42
40
|
max_new_tokens: Optional[int] = None
|
|
43
|
-
"""The maximum number of tokens to generate. Takes precedence over
|
|
41
|
+
"""The maximum number of tokens to generate. Takes precedence over max_length."""
|
|
44
42
|
min_length: Optional[int] = None
|
|
45
43
|
"""The minimum length (in tokens) of the generated text, including the input."""
|
|
46
44
|
min_new_tokens: Optional[int] = None
|
|
47
|
-
"""The minimum number of tokens to generate. Takes precedence over
|
|
45
|
+
"""The minimum number of tokens to generate. Takes precedence over min_length."""
|
|
48
46
|
num_beam_groups: Optional[int] = None
|
|
49
47
|
"""Number of groups to divide num_beams into in order to ensure diversity among different
|
|
50
48
|
groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details.
|
|
@@ -76,11 +74,10 @@ class TextToAudioGenerationParameters(BaseInferenceType):
|
|
|
76
74
|
|
|
77
75
|
@dataclass
|
|
78
76
|
class TextToAudioParameters(BaseInferenceType):
|
|
79
|
-
"""Additional inference parameters
|
|
80
|
-
Additional inference parameters for Text To Audio
|
|
81
|
-
"""
|
|
77
|
+
"""Additional inference parameters for Text To Audio"""
|
|
82
78
|
|
|
83
|
-
|
|
79
|
+
# Will be deprecated in the future when the renaming to `generation_parameters` is implemented in transformers
|
|
80
|
+
generate_kwargs: Optional[TextToAudioGenerationParameters] = None
|
|
84
81
|
"""Parametrization of the text generation process"""
|
|
85
82
|
|
|
86
83
|
|
|
@@ -91,7 +88,7 @@ class TextToAudioInput(BaseInferenceType):
|
|
|
91
88
|
inputs: str
|
|
92
89
|
"""The input text data"""
|
|
93
90
|
parameters: Optional[TextToAudioParameters] = None
|
|
94
|
-
"""Additional inference parameters"""
|
|
91
|
+
"""Additional inference parameters for Text To Audio"""
|
|
95
92
|
|
|
96
93
|
|
|
97
94
|
@dataclass
|
|
@@ -19,9 +19,7 @@ class TextToImageTargetSize(BaseInferenceType):
|
|
|
19
19
|
|
|
20
20
|
@dataclass
|
|
21
21
|
class TextToImageParameters(BaseInferenceType):
|
|
22
|
-
"""Additional inference parameters
|
|
23
|
-
Additional inference parameters for Text To Image
|
|
24
|
-
"""
|
|
22
|
+
"""Additional inference parameters for Text To Image"""
|
|
25
23
|
|
|
26
24
|
guidance_scale: Optional[float] = None
|
|
27
25
|
"""A higher guidance scale value encourages the model to generate images closely linked to
|
|
@@ -48,7 +46,7 @@ class TextToImageInput(BaseInferenceType):
|
|
|
48
46
|
inputs: str
|
|
49
47
|
"""The input text data (sometimes called "prompt")"""
|
|
50
48
|
parameters: Optional[TextToImageParameters] = None
|
|
51
|
-
"""Additional inference parameters"""
|
|
49
|
+
"""Additional inference parameters for Text To Image"""
|
|
52
50
|
|
|
53
51
|
|
|
54
52
|
@dataclass
|