#
Inference types

This page lists the types (e.g. dataclasses) available for each task supported on the Hugging Face Hub. Each task is specified using a JSON schema, and the types are generated from these schemas - with some customization due to Python requirements. Visit @huggingface.js/tasks to find the JSON schemas for each task.

This part of the lib is still under development and will be improved in future releases.

##
audio_classification

###
class huggingface_hub.AudioClassificationInput

< source >

( inputs: Any parameters: Optional = None )

Inputs for Audio Classification inference

###
class huggingface_hub.AudioClassificationOutputElement

< source >

( label: str score: float )

Outputs for Audio Classification inference

###
class huggingface_hub.AudioClassificationParameters

< source >

( function_to_apply: Optional = None top_k: Optional = None )

Additional inference parameters Additional inference parameters for Audio Classification

##
audio_to_audio

###
class huggingface_hub.AudioToAudioInput

< source >

( inputs: Any )

Inputs for Audio to Audio inference

###
class huggingface_hub.AudioToAudioOutputElement

< source >

( blob: Any content_type: str label: str )

Outputs of inference for the Audio To Audio task A generated audio file with its label.

##
automatic_speech_recognition

###
class huggingface_hub.AutomaticSpeechRecognitionGenerationParameters

< source >

( do_sample: Optional = None early_stopping: Union = None epsilon_cutoff: Optional = None eta_cutoff: Optional = None max_length: Optional = None max_new_tokens: Optional = None min_length: Optional = None min_new_tokens: Optional = None num_beam_groups: Optional = None num_beams: Optional = None penalty_alpha: Optional = None temperature: Optional = None top_k: Optional = None top_p: Optional = None typical_p: Optional = None use_cache: Optional = None )

Parametrization of the text generation process Ad-hoc parametrization of the text generation process

###
class huggingface_hub.AutomaticSpeechRecognitionInput

< source >

( inputs: Any parameters: Optional = None )

Inputs for Automatic Speech Recognition inference

###
class huggingface_hub.AutomaticSpeechRecognitionOutput

< source >

( text: str chunks: Optional = None )

Outputs of inference for the Automatic Speech Recognition task

###
class huggingface_hub.AutomaticSpeechRecognitionOutputChunk

< source >

( text: str timestamps: List )

###
class huggingface_hub.AutomaticSpeechRecognitionParameters

< source >

( generate: Optional = None return_timestamps: Optional = None )

Additional inference parameters Additional inference parameters for Automatic Speech Recognition

##
chat_completion

###
class huggingface_hub.ChatCompletionInput

< source >

( messages: List model: str frequency_penalty: Optional = None logit_bias: Optional = None logprobs: Optional = None max_tokens: Optional = None n: Optional = None presence_penalty: Optional = None seed: Optional = None stop: Optional = None stream: Optional = None temperature: Optional = None tool_choice: Union = None tool_prompt: Optional = None tools: Optional = None top_logprobs: Optional = None top_p: Optional = None )

Chat Completion Input. Auto-generated from TGI specs. For more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.

###
class huggingface_hub.ChatCompletionInputFunctionDefinition

< source >

( arguments: Any name: str description: Optional = None )

###
class huggingface_hub.ChatCompletionInputMessage

< source >

( role: str content: Optional = None name: Optional = None tool_calls: Optional = None )

###
class huggingface_hub.ChatCompletionInputTool

< source >

( function: ChatCompletionInputFunctionDefinition type: str )

###
class huggingface_hub.ChatCompletionInputToolCall

< source >

( function: ChatCompletionInputFunctionDefinition id: int type: str )

###
class huggingface_hub.ChatCompletionInputToolTypeClass

< source >

( function_name: str )

###
class huggingface_hub.ChatCompletionOutput

< source >

( choices: List created: int id: str model: str object: str system_fingerprint: str usage: ChatCompletionOutputUsage )

Chat Completion Output. Auto-generated from TGI specs. For more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.

###
class huggingface_hub.ChatCompletionOutputComplete

< source >

( finish_reason: str index: int message: ChatCompletionOutputMessage logprobs: Optional = None )

###
class huggingface_hub.ChatCompletionOutputFunctionDefinition

< source >

( arguments: Any name: str description: Optional = None )

###
class huggingface_hub.ChatCompletionOutputLogprob

< source >

( logprob: float token: str top_logprobs: List )

###
class huggingface_hub.ChatCompletionOutputLogprobs

< source >

( content: List )

###
class huggingface_hub.ChatCompletionOutputMessage

< source >

( role: str content: Optional = None name: Optional = None tool_calls: Optional = None )

###
class huggingface_hub.ChatCompletionOutputToolCall

< source >

( function: ChatCompletionOutputFunctionDefinition id: int type: str )

###
class huggingface_hub.ChatCompletionOutputTopLogprob

< source >

( logprob: float token: str )

###
class huggingface_hub.ChatCompletionOutputUsage

< source >

( completion_tokens: int prompt_tokens: int total_tokens: int )

###
class huggingface_hub.ChatCompletionStreamOutput

< source >

( choices: List created: int id: str model: str object: str system_fingerprint: str )

Chat Completion Stream Output. Auto-generated from TGI specs. For more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.

###
class huggingface_hub.ChatCompletionStreamOutputChoice

< source >

( delta: ChatCompletionStreamOutputDelta index: int finish_reason: Optional = None logprobs: Optional = None )

###
class huggingface_hub.ChatCompletionStreamOutputDelta

< source >

( role: str content: Optional = None tool_calls: Optional = None )

###
class huggingface_hub.ChatCompletionStreamOutputDeltaToolCall

< source >

( function: ChatCompletionStreamOutputFunction id: str index: int type: str )

###
class huggingface_hub.ChatCompletionStreamOutputFunction

< source >

( arguments: str name: Optional = None )

###
class huggingface_hub.ChatCompletionStreamOutputLogprob

< source >

( logprob: float token: str top_logprobs: List )

###
class huggingface_hub.ChatCompletionStreamOutputLogprobs

< source >

( content: List )

###
class huggingface_hub.ChatCompletionStreamOutputTopLogprob

< source >

( logprob: float token: str )

##
depth_estimation

###
class huggingface_hub.DepthEstimationInput

< source >

( inputs: Any parameters: Optional = None )

Inputs for Depth Estimation inference

###
class huggingface_hub.DepthEstimationOutput

< source >

( depth: Any predicted_depth: Any )

Outputs of inference for the Depth Estimation task

##
document_question_answering

###
class huggingface_hub.DocumentQuestionAnsweringInput

< source >

( inputs: DocumentQuestionAnsweringInputData parameters: Optional = None )

Inputs for Document Question Answering inference

###
class huggingface_hub.DocumentQuestionAnsweringInputData

< source >

( image: Any question: str )

One (document, question) pair to answer

###
class huggingface_hub.DocumentQuestionAnsweringOutputElement

< source >

( answer: str end: int score: float start: int words: List )

Outputs of inference for the Document Question Answering task

###
class huggingface_hub.DocumentQuestionAnsweringParameters

< source >

( doc_stride: Optional = None handle_impossible_answer: Optional = None lang: Optional = None max_answer_len: Optional = None max_question_len: Optional = None max_seq_len: Optional = None top_k: Optional = None word_boxes: Optional = None )

Additional inference parameters Additional inference parameters for Document Question Answering

##
feature_extraction

###
class huggingface_hub.FeatureExtractionInput

< source >

( inputs: Union normalize: Optional = None truncate: Optional = None )

Feature Extraction Input. Auto-generated from TEI specs. For more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tei-import.ts.

##
fill_mask

###
class huggingface_hub.FillMaskInput

< source >

( inputs: str parameters: Optional = None )

Inputs for Fill Mask inference

###
class huggingface_hub.FillMaskOutputElement

< source >

( score: float sequence: str token: int token_str: Any fill_mask_output_token_str: Optional = None )

Outputs of inference for the Fill Mask task

###
class huggingface_hub.FillMaskParameters

< source >

( targets: Optional = None top_k: Optional = None )

Additional inference parameters Additional inference parameters for Fill Mask

##
image_classification

###
class huggingface_hub.ImageClassificationInput

< source >

( inputs: Any parameters: Optional = None )

Inputs for Image Classification inference

###
class huggingface_hub.ImageClassificationOutputElement

< source >

( label: str score: float )

Outputs of inference for the Image Classification task

###
class huggingface_hub.ImageClassificationParameters

< source >

( function_to_apply: Optional = None top_k: Optional = None )

Additional inference parameters Additional inference parameters for Image Classification

##
image_segmentation

###
class huggingface_hub.ImageSegmentationInput

< source >

( inputs: Any parameters: Optional = None )

Inputs for Image Segmentation inference

###
class huggingface_hub.ImageSegmentationOutputElement

< source >

( label: str mask: Any score: Optional = None )

Outputs of inference for the Image Segmentation task A predicted mask / segment

###
class huggingface_hub.ImageSegmentationParameters

< source >

( mask_threshold: Optional = None overlap_mask_area_threshold: Optional = None subtask: Optional = None threshold: Optional = None )

Additional inference parameters Additional inference parameters for Image Segmentation

##
image_to_image

###
class huggingface_hub.ImageToImageInput

< source >

( inputs: Any parameters: Optional = None )

Inputs for Image To Image inference

###
class huggingface_hub.ImageToImageOutput

< source >

( image: Any )

Outputs of inference for the Image To Image task

###
class huggingface_hub.ImageToImageParameters

< source >

( guidance_scale: Optional = None negative_prompt: Optional = None num_inference_steps: Optional = None target_size: Optional = None )

Additional inference parameters Additional inference parameters for Image To Image

###
class huggingface_hub.ImageToImageTargetSize

< source >

( height: int width: int )

The size in pixel of the output image

##
image_to_text

###
class huggingface_hub.ImageToTextGenerationParameters

< source >

( do_sample: Optional = None early_stopping: Union = None epsilon_cutoff: Optional = None eta_cutoff: Optional = None max_length: Optional = None max_new_tokens: Optional = None min_length: Optional = None min_new_tokens: Optional = None num_beam_groups: Optional = None num_beams: Optional = None penalty_alpha: Optional = None temperature: Optional = None top_k: Optional = None top_p: Optional = None typical_p: Optional = None use_cache: Optional = None )

Parametrization of the text generation process Ad-hoc parametrization of the text generation process

###
class huggingface_hub.ImageToTextInput

< source >

( inputs: Any parameters: Optional = None )

Inputs for Image To Text inference

###
class huggingface_hub.ImageToTextOutput

< source >

( generated_text: Any image_to_text_output_generated_text: Optional = None )

Outputs of inference for the Image To Text task

###
class huggingface_hub.ImageToTextParameters

< source >

( generate: Optional = None max_new_tokens: Optional = None )

Additional inference parameters Additional inference parameters for Image To Text

##
object_detection

###
class huggingface_hub.ObjectDetectionBoundingBox

< source >

( xmax: int xmin: int ymax: int ymin: int )

The predicted bounding box. Coordinates are relative to the top left corner of the input image.

###
class huggingface_hub.ObjectDetectionInput

< source >

( inputs: Any parameters: Optional = None )

Inputs for Object Detection inference

###
class huggingface_hub.ObjectDetectionOutputElement

< source >

( box: ObjectDetectionBoundingBox label: str score: float )

Outputs of inference for the Object Detection task

###
class huggingface_hub.ObjectDetectionParameters

< source >

( threshold: Optional = None )

Additional inference parameters Additional inference parameters for Object Detection

##
question_answering

###
class huggingface_hub.QuestionAnsweringInput

< source >

( inputs: QuestionAnsweringInputData parameters: Optional = None )

Inputs for Question Answering inference

###
class huggingface_hub.QuestionAnsweringInputData

< source >

( context: str question: str )

One (context, question) pair to answer

###
class huggingface_hub.QuestionAnsweringOutputElement

< source >

( answer: str end: int score: float start: int )

Outputs of inference for the Question Answering task

###
class huggingface_hub.QuestionAnsweringParameters

< source >

( align_to_words: Optional = None doc_stride: Optional = None handle_impossible_answer: Optional = None max_answer_len: Optional = None max_question_len: Optional = None max_seq_len: Optional = None top_k: Optional = None )

Additional inference parameters Additional inference parameters for Question Answering

##
sentence_similarity

###
class huggingface_hub.SentenceSimilarityInput

< source >

( inputs: SentenceSimilarityInputData parameters: Optional = None )

Inputs for Sentence similarity inference

###
class huggingface_hub.SentenceSimilarityInputData

< source >

( sentences: List source_sentence: str )

##
summarization

###
class huggingface_hub.SummarizationGenerationParameters

< source >

( clean_up_tokenization_spaces: Optional = None generate_parameters: Optional = None truncation: Optional = None )

Additional inference parameters Additional inference parameters for Text2text Generation

###
class huggingface_hub.SummarizationInput

< source >

( inputs: str parameters: Optional = None )

Inputs for Summarization inference Inputs for Text2text Generation inference

###
class huggingface_hub.SummarizationOutput

< source >

( summary_text: str )

Outputs of inference for the Summarization task

##
table_question_answering

###
class huggingface_hub.TableQuestionAnsweringInput

< source >

( inputs: TableQuestionAnsweringInputData parameters: Optional = None )

Inputs for Table Question Answering inference

###
class huggingface_hub.TableQuestionAnsweringInputData

< source >

( question: str table: Dict )

One (table, question) pair to answer

###
class huggingface_hub.TableQuestionAnsweringOutputElement

< source >

( answer: str cells: List coordinates: List aggregator: Optional = None )

Outputs of inference for the Table Question Answering task

##
text2text_generation

###
class huggingface_hub.Text2TextGenerationInput

< source >

( inputs: str parameters: Optional = None )

Inputs for Text2text Generation inference

###
class huggingface_hub.Text2TextGenerationOutput

< source >

( generated_text: Any text2_text_generation_output_generated_text: Optional = None )

Outputs of inference for the Text2text Generation task

###
class huggingface_hub.Text2TextGenerationParameters

< source >

( clean_up_tokenization_spaces: Optional = None generate_parameters: Optional = None truncation: Optional = None )

Additional inference parameters Additional inference parameters for Text2text Generation

##
text_classification

###
class huggingface_hub.TextClassificationInput

< source >

( inputs: str parameters: Optional = None )

Inputs for Text Classification inference

###
class huggingface_hub.TextClassificationOutputElement

< source >

( label: str score: float )

Outputs of inference for the Text Classification task

###
class huggingface_hub.TextClassificationParameters

< source >

( function_to_apply: Optional = None top_k: Optional = None )

Additional inference parameters Additional inference parameters for Text Classification

##
text_generation

###
class huggingface_hub.TextGenerationInput

< source >

( inputs: str parameters: Optional = None stream: Optional = None )

Text Generation Input. Auto-generated from TGI specs. For more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.

###
class huggingface_hub.TextGenerationInputGenerateParameters

< source >

( best_of: Optional = None decoder_input_details: Optional = None details: Optional = None do_sample: Optional = None frequency_penalty: Optional = None grammar: Optional = None max_new_tokens: Optional = None repetition_penalty: Optional = None return_full_text: Optional = None seed: Optional = None stop: Optional = None temperature: Optional = None top_k: Optional = None top_n_tokens: Optional = None top_p: Optional = None truncate: Optional = None typical_p: Optional = None watermark: Optional = None )

###
class huggingface_hub.TextGenerationInputGrammarType

< source >

( type: TypeEnum value: Any )

###
class huggingface_hub.TextGenerationOutput

< source >

( generated_text: str details: Optional = None )

Text Generation Output. Auto-generated from TGI specs. For more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.

###
class huggingface_hub.TextGenerationOutputBestOfSequence

< source >

( finish_reason: TextGenerationOutputFinishReason generated_text: str generated_tokens: int prefill: List tokens: List seed: Optional = None top_tokens: Optional = None )

###
class huggingface_hub.TextGenerationOutputDetails

< source >

( finish_reason: TextGenerationOutputFinishReason generated_tokens: int prefill: List tokens: List best_of_sequences: Optional = None seed: Optional = None top_tokens: Optional = None )

###
class huggingface_hub.TextGenerationOutputPrefillToken

< source >

( id: int logprob: float text: str )

###
class huggingface_hub.TextGenerationOutputToken

< source >

( id: int logprob: float special: bool text: str )

###
class huggingface_hub.TextGenerationStreamOutput

< source >

( index: int token: TextGenerationStreamOutputToken details: Optional = None generated_text: Optional = None top_tokens: Optional = None )

Text Generation Stream Output. Auto-generated from TGI specs. For more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.

###
class huggingface_hub.TextGenerationStreamOutputStreamDetails

< source >

( finish_reason: TextGenerationOutputFinishReason generated_tokens: int seed: Optional = None )

###
class huggingface_hub.TextGenerationStreamOutputToken

< source >

( id: int logprob: float special: bool text: str )

##
text_to_audio

###
class huggingface_hub.TextToAudioGenerationParameters

< source >

( do_sample: Optional = None early_stopping: Union = None epsilon_cutoff: Optional = None eta_cutoff: Optional = None max_length: Optional = None max_new_tokens: Optional = None min_length: Optional = None min_new_tokens: Optional = None num_beam_groups: Optional = None num_beams: Optional = None penalty_alpha: Optional = None temperature: Optional = None top_k: Optional = None top_p: Optional = None typical_p: Optional = None use_cache: Optional = None )

Parametrization of the text generation process Ad-hoc parametrization of the text generation process

###
class huggingface_hub.TextToAudioInput

< source >

( inputs: str parameters: Optional = None )

Inputs for Text To Audio inference

###
class huggingface_hub.TextToAudioOutput

< source >

( audio: Any sampling_rate: Any text_to_audio_output_sampling_rate: Optional = None )

Outputs of inference for the Text To Audio task

###
class huggingface_hub.TextToAudioParameters

< source >

( generate: Optional = None )

Additional inference parameters Additional inference parameters for Text To Audio

##
text_to_image

###
class huggingface_hub.TextToImageInput

< source >

( inputs: str parameters: Optional = None )

Inputs for Text To Image inference

###
class huggingface_hub.TextToImageOutput

< source >

( image: Any )

Outputs of inference for the Text To Image task

###
class huggingface_hub.TextToImageParameters

< source >

( guidance_scale: Optional = None negative_prompt: Optional = None num_inference_steps: Optional = None scheduler: Optional = None target_size: Optional = None )

Additional inference parameters Additional inference parameters for Text To Image

###
class huggingface_hub.TextToImageTargetSize

< source >

( height: int width: int )

The size in pixel of the output image

##
token_classification

###
class huggingface_hub.TokenClassificationInput

< source >

( inputs: str parameters: Optional = None )

Inputs for Token Classification inference

###
class huggingface_hub.TokenClassificationOutputElement

< source >

( label: Any score: float end: Optional = None entity_group: Optional = None start: Optional = None word: Optional = None )

Outputs of inference for the Token Classification task

###
class huggingface_hub.TokenClassificationParameters

< source >

( aggregation_strategy: Optional = None ignore_labels: Optional = None stride: Optional = None )

Additional inference parameters Additional inference parameters for Token Classification

##
translation

###
class huggingface_hub.TranslationGenerationParameters

< source >

( clean_up_tokenization_spaces: Optional = None generate_parameters: Optional = None truncation: Optional = None )

Additional inference parameters Additional inference parameters for Text2text Generation

###
class huggingface_hub.TranslationInput

< source >

( inputs: str parameters: Optional = None )

Inputs for Translation inference Inputs for Text2text Generation inference

###
class huggingface_hub.TranslationOutput

< source >

( translation_text: str )

Outputs of inference for the Translation task

##
video_classification

###
class huggingface_hub.VideoClassificationInput

< source >

( inputs: Any parameters: Optional = None )

Inputs for Video Classification inference

###
class huggingface_hub.VideoClassificationOutputElement

< source >

( label: str score: float )

Outputs of inference for the Video Classification task

###
class huggingface_hub.VideoClassificationParameters

< source >

( frame_sampling_rate: Optional = None function_to_apply: Optional = None num_frames: Optional = None top_k: Optional = None )

Additional inference parameters Additional inference parameters for Video Classification

##
visual_question_answering

###
class huggingface_hub.VisualQuestionAnsweringInput

< source >

( inputs: VisualQuestionAnsweringInputData parameters: Optional = None )

Inputs for Visual Question Answering inference

###
class huggingface_hub.VisualQuestionAnsweringInputData

< source >

( image: Any question: Any )

One (image, question) pair to answer

###
class huggingface_hub.VisualQuestionAnsweringOutputElement

< source >

( label: Any score: float answer: Optional = None )

Outputs of inference for the Visual Question Answering task

###
class huggingface_hub.VisualQuestionAnsweringParameters

< source >

( top_k: Optional = None )

Additional inference parameters Additional inference parameters for Visual Question Answering

##
zero_shot_classification

###
class huggingface_hub.ZeroShotClassificationInput

< source >

( inputs: ZeroShotClassificationInputData parameters: Optional = None )

Inputs for Zero Shot Classification inference

###
class huggingface_hub.ZeroShotClassificationInputData

< source >

( candidate_labels: List text: str )

The input text data, with candidate labels

###
class huggingface_hub.ZeroShotClassificationOutputElement

< source >

( label: str score: float )

Outputs of inference for the Zero Shot Classification task

###
class huggingface_hub.ZeroShotClassificationParameters

< source >

( hypothesis_template: Optional = None multi_label: Optional = None )

Additional inference parameters Additional inference parameters for Zero Shot Classification

##
zero_shot_image_classification

###
class huggingface_hub.ZeroShotImageClassificationInput

< source >

( inputs: ZeroShotImageClassificationInputData parameters: Optional = None )

Inputs for Zero Shot Image Classification inference

###
class huggingface_hub.ZeroShotImageClassificationInputData

< source >

( candidate_labels: List image: Any )

The input image data, with candidate labels

###
class huggingface_hub.ZeroShotImageClassificationOutputElement

< source >

( label: str score: float )

Outputs of inference for the Zero Shot Image Classification task

###
class huggingface_hub.ZeroShotImageClassificationParameters

< source >

( hypothesis_template: Optional = None )

Additional inference parameters Additional inference parameters for Zero Shot Image Classification

##
zero_shot_object_detection

###
class huggingface_hub.ZeroShotObjectDetectionBoundingBox

< source >

( xmax: int xmin: int ymax: int ymin: int )

The predicted bounding box. Coordinates are relative to the top left corner of the input image.

###
class huggingface_hub.ZeroShotObjectDetectionInput

< source >

( inputs: ZeroShotObjectDetectionInputData parameters: Optional = None )

Inputs for Zero Shot Object Detection inference

###
class huggingface_hub.ZeroShotObjectDetectionInputData

< source >

( candidate_labels: List image: Any )

The input image data, with candidate labels

###
class huggingface_hub.ZeroShotObjectDetectionOutputElement

< source >

( box: ZeroShotObjectDetectionBoundingBox label: str score: float )

Outputs of inference for the Zero Shot Object Detection task

< > Update on GitHub