Hub Python 库文档

推理类型

Hugging Face's logo
加入 Hugging Face 社区

并获得增强的文档体验

开始使用

推理类型

此页面列出了 Hugging Face Hub 上支持的每个任务可用的类型(例如数据类)。每个任务都使用 JSON 模式指定,并且类型是从这些模式生成的 - 由于 Python 的要求进行了一些自定义。访问 @huggingface.js/tasks 查找每个任务的 JSON 模式。

库的这部分仍在开发中,将在未来的版本中进行改进。

音频分类

huggingface_hub.AudioClassificationInput

< >

( inputs: str parameters: Optional = None )

音频分类推理的输入

huggingface_hub.AudioClassificationOutputElement

< >

( 标签: str 分数: float )

音频分类推理的输出

huggingface_hub.AudioClassificationParameters

< >

( 应用函数: Optional = None 前k个: Optional = None )

其他推理参数 音频分类的其他推理参数

音频到音频

huggingface_hub.AudioToAudioInput

< >

( 输入: Any )

音频到音频推理的输入

huggingface_hub.AudioToAudioOutputElement

< >

( 二进制大对象: Any 内容类型: str 标签: str )

音频到音频任务推理的输出 生成的音频文件及其标签。

自动语音识别

huggingface_hub.AutomaticSpeechRecognitionGenerationParameters

< >

( 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 )

文本生成过程的参数化 文本生成过程的特别参数化

huggingface_hub.AutomaticSpeechRecognitionInput

< >

( inputs: str parameters: Optional = None )

自动语音识别推理的输入

huggingface_hub.AutomaticSpeechRecognitionOutput

< >

( text: str chunks: Optional = None )

自动语音识别任务的推理输出

huggingface_hub.AutomaticSpeechRecognitionOutputChunk

< >

( text: str timestamps: List )

huggingface_hub.AutomaticSpeechRecognitionParameters

< >

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

其他推理参数 用于自动语音识别的其他推理参数

聊天补全

huggingface_hub.ChatCompletionInput

< >

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

聊天补全输入。根据 TGI 规范自动生成。更多详情,请查看 https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.

huggingface_hub.ChatCompletionInputFunctionDefinition

< >

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

huggingface_hub.ChatCompletionInputFunctionName

< >

( name: str )

huggingface_hub.ChatCompletionInputGrammarType

< >

( type: ChatCompletionInputGrammarTypeType value: Any )

huggingface_hub.ChatCompletionInputMessage

< >

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

huggingface_hub.ChatCompletionInputMessageChunk

< >

( type: ChatCompletionInputMessageChunkType image_url: Optional = None text: Optional = None )

huggingface_hub.ChatCompletionInputStreamOptions

< >

( include_usage: bool )

huggingface_hub.ChatCompletionInputToolType

< >

( function: 可选 = 无 )

huggingface_hub.ChatCompletionInputURL

< >

( url: 字符串 )

huggingface_hub.ChatCompletionOutput

< >

( choices: 列表 created: 整数 id: 字符串 model: 字符串 system_fingerprint: 字符串 usage: ChatCompletionOutputUsage )

聊天完成输出。根据 TGI 规范自动生成。 更多详细信息,请查看 https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts

huggingface_hub.ChatCompletionOutputComplete

< >

( finish_reason: 字符串 index: 整数 message: ChatCompletionOutputMessage logprobs: 可选 = 无 )

huggingface_hub.ChatCompletionOutputFunctionDefinition

< >

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

huggingface_hub.ChatCompletionOutputLogprob

< >

( logprob: float token: str top_logprobs: List )

huggingface_hub.ChatCompletionOutputLogprobs

< >

( content: List )

huggingface_hub.ChatCompletionOutputMessage

< >

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

huggingface_hub.ChatCompletionOutputToolCall

< >

( function: ChatCompletionOutputFunctionDefinition id: str type: str )

huggingface_hub.ChatCompletionOutputTopLogprob

< >

( logprob: float token: str )

huggingface_hub.ChatCompletionOutputUsage

< >

( completion_tokens: int prompt_tokens: int total_tokens: int )

huggingface_hub.ChatCompletionStreamOutput

< >

( choices: List created: int id: str model: str system_fingerprint: str usage: Optional = None )

聊天补全流输出。根据 TGI 规范自动生成。有关更多详细信息,请查看 https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.

huggingface_hub.ChatCompletionStreamOutputChoice

< >

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

huggingface_hub.ChatCompletionStreamOutputDelta

< >

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

huggingface_hub.ChatCompletionStreamOutputDeltaToolCall

< >

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

huggingface_hub.ChatCompletionStreamOutputFunction

< >

( 参数: str 名称: 可选 = 无 )

huggingface_hub.ChatCompletionStreamOutputLogprob

< >

( logprob: float token: str top_logprobs: List )

huggingface_hub.ChatCompletionStreamOutputLogprobs

< >

( content: List )

huggingface_hub.ChatCompletionStreamOutputTopLogprob

< >

( logprob: float token: str )

huggingface_hub.ChatCompletionStreamOutputUsage

< >

( completion_tokens: int prompt_tokens: int total_tokens: int )

huggingface_hub.ToolElement

< >

( 函数: ChatCompletionInputFunctionDefinition 类型: str )

深度估计

huggingface_hub.DepthEstimationInput

< >

( inputs: Any parameters: Optional = None )

深度估计推理的输入

class huggingface_hub.DepthEstimationOutput

< >

( depth: Any predicted_depth: Any )

深度估计任务的推理输出

文档问答

class huggingface_hub.DocumentQuestionAnsweringInput

< >

( inputs: DocumentQuestionAnsweringInputData parameters: Optional = None )

文档问答推理的输入

class huggingface_hub.DocumentQuestionAnsweringInputData

< >

( image: Any question: str )

需要回答的一个(文档,问题)对

class huggingface_hub.DocumentQuestionAnsweringOutputElement

< >

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

文档问答任务的推理输出

huggingface_hub.DocumentQuestionAnsweringParameters

< >

( 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 )

附加推理参数 文档问答的附加推理参数

特征提取

huggingface_hub.FeatureExtractionInput

< >

( inputs: str normalize: Optional = None prompt_name: Optional = None truncate: Optional = None truncation_direction: Optional = None )

特征提取输入。根据 TEI 规范自动生成。更多详情,请查看 https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tei-import.ts

填空

huggingface_hub.FillMaskInput

< >

( inputs: str parameters: Optional = None )

填空推理的输入

huggingface_hub.FillMaskOutputElement

< >

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

掩码填充任务的推理输出

huggingface_hub.FillMaskParameters

< >

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

额外的推理参数 掩码填充的额外推理参数

图像分类

huggingface_hub.ImageClassificationInput

< >

( inputs: str parameters: Optional = None )

图像分类推理的输入

huggingface_hub.ImageClassificationOutputElement

< >

( 标签: str 分数: float )

图像分类任务的推理输出

huggingface_hub.ImageClassificationParameters

< >

( 应用函数: Optional = None 前k个: Optional = None )

额外的推理参数 图像分类的额外推理参数

图像分割

huggingface_hub.ImageSegmentationInput

< >

( inputs: str parameters: Optional = None )

图像分割推理的输入

huggingface_hub.ImageSegmentationOutputElement

< >

( 标签: str 掩码: str 分数: Optional = None )

图像分割任务推理的输出 预测的掩码/片段

huggingface_hub.ImageSegmentationParameters

< >

( 掩码阈值: Optional = None 重叠掩码区域阈值: Optional = None 子任务: Optional = None 阈值: Optional = None )

其他推理参数 图像分割的其他推理参数

图像到图像

huggingface_hub.ImageToImageInput

< >

( inputs: str parameters: Optional = None )

图像到图像推理的输入

huggingface_hub.ImageToImageOutput

< >

( image: Any )

图像到图像任务的推理输出

huggingface_hub.ImageToImageParameters

< >

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

附加推理参数 图像到图像的附加推理参数

huggingface_hub.ImageToImageTargetSize

< >

( height: int width: int )

输出图像的像素大小。

image_to_text

huggingface_hub.ImageToTextGenerationParameters

< >

( 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 )

文本生成过程的参数化 文本生成过程的特别参数化

huggingface_hub.ImageToTextInput

< >

( inputs: Any parameters: Optional = None )

图像到文本推理的输入

huggingface_hub.ImageToTextOutput

< >

( generated_text: Any image_to_text_output_generated_text: Optional = None )

图像到文本任务的推理输出

huggingface_hub.ImageToTextParameters

< >

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

图像到文本的附加推理参数

目标检测

huggingface_hub.ObjectDetectionBoundingBox

< >

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

预测的边界框。坐标相对于输入图像的左上角。

huggingface_hub.ObjectDetectionInput

< >

( inputs: str parameters: Optional = None )

目标检测推理的输入

huggingface_hub.ObjectDetectionOutputElement

< >

( box: ObjectDetectionBoundingBox label: str score: float )

目标检测任务的推理输出

huggingface_hub.ObjectDetectionParameters

< >

( threshold: 可选 = 无 )

用于目标检测的附加推理参数

问答

huggingface_hub.QuestionAnsweringInput

< >

( inputs: QuestionAnsweringInputData parameters: 可选 = 无 )

问答推理的输入

huggingface_hub.QuestionAnsweringInputData

< >

( context: 字符串 question: 字符串 )

一个 (上下文, 问题) 对,用于回答

huggingface_hub.QuestionAnsweringOutputElement

< >

( answer: 字符串 end: 整数 score: 浮点数 start: 整数 )

问答任务推理的输出

huggingface_hub.QuestionAnsweringParameters

< >

( 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 )

其他推理参数 问答任务的其他推理参数

句子相似度

huggingface_hub.SentenceSimilarityInput

< >

( inputs: SentenceSimilarityInputData parameters: Optional = None )

句子相似度推理的输入

huggingface_hub.SentenceSimilarityInputData

< >

( sentences: List source_sentence: str )

摘要

huggingface_hub.SummarizationInput

< >

( inputs: str parameters: Optional = None )

摘要推理的输入

huggingface_hub.SummarizationOutput

< >

( summary_text: str )

摘要任务的推理输出

huggingface_hub.SummarizationParameters

< >

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

其他推理参数。用于摘要的其他推理参数。

表格问答

huggingface_hub.TableQuestionAnsweringInput

< >

( inputs: TableQuestionAnsweringInputData parameters: Optional = None )

表格问答推理的输入

huggingface_hub.TableQuestionAnsweringInputData

< >

( question: str table: Dict )

一个 (表格,问题) 对需要回答

huggingface_hub.TableQuestionAnsweringOutputElement

< >

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

表格问答任务的推理输出

文本到文本生成

huggingface_hub.Text2TextGenerationInput

< >

( inputs: str parameters: Optional = None )

文本到文本生成推理的输入

huggingface_hub.Text2TextGenerationOutput

< >

( generated_text: Any text2_text_generation_output_generated_text: 可选 = None )

文本到文本生成任务的推理输出

huggingface_hub.Text2TextGenerationParameters

< >

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

其他推理参数 文本到文本生成的附加推理参数

文本分类

huggingface_hub.TextClassificationInput

< >

( inputs: str parameters: Optional = None )

文本分类推理的输入

huggingface_hub.TextClassificationOutputElement

< >

( 标签: str 分数: float )

文本分类任务的推理输出

huggingface_hub.TextClassificationParameters

< >

( 应用函数: Optional = None 前k个: Optional = None )

文本分类的附加推理参数。

文本生成

huggingface_hub.TextGenerationInput

< >

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

文本生成输入。根据 TGI 规范自动生成。更多详情,请查看 https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts

huggingface_hub.TextGenerationInputGenerateParameters

< >

( adapter_id: Optional = None 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 )

huggingface_hub.TextGenerationInputGrammarType

< >

( type: TypeEnum value: Any )

huggingface_hub.TextGenerationOutput

< >

( generated_text: str details: Optional = None )

文本生成输出。根据 TGI 规范自动生成。更多详情,请查看 https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts

huggingface_hub.TextGenerationOutputBestOfSequence

< >

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

huggingface_hub.TextGenerationOutputDetails

< >

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

huggingface_hub.TextGenerationOutputPrefillToken

< >

( id: int logprob: float text: str )

huggingface_hub.TextGenerationOutputToken

< >

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

huggingface_hub.TextGenerationStreamOutput

< >

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

文本生成流输出。根据 TGI 规范自动生成。更多详细信息,请查看 https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts

huggingface_hub.TextGenerationStreamOutputStreamDetails

< >

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

huggingface_hub.TextGenerationStreamOutputToken

< >

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

文本到音频

huggingface_hub.TextToAudioGenerationParameters

< >

( 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 )

文本生成过程的参数化 文本生成过程的特别参数化

huggingface_hub.TextToAudioInput

< >

( inputs: str parameters: Optional = None )

文字转音频推理的输入

huggingface_hub.TextToAudioOutput

< >

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

文字转音频任务的推理输出

huggingface_hub.TextToAudioParameters

< >

( generate: Optional = None )

附加推理参数 文字转音频的附加推理参数

text_to_image

huggingface_hub.TextToImageInput

< >

( inputs: str parameters: Optional = None )

文字转图像推理的输入

huggingface_hub.TextToImageOutput

< >

( image: Any )

文本到图像任务的推理输出

huggingface_hub.TextToImageParameters

< >

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

附加推理参数 文本到图像的附加推理参数

huggingface_hub.TextToImageTargetSize

< >

( height: int width: int )

输出图像的像素大小

文本到语音

huggingface_hub.TextToSpeechGenerationParameters

< >

( 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 )

文本生成过程的参数化 文本生成过程的特别参数化

huggingface_hub.TextToSpeechInput

< >

( inputs: str parameters: Optional = None )

文本到语音推理的输入

huggingface_hub.TextToSpeechOutput

< >

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

文本转语音推理的输出 文本转音频任务的推理输出

huggingface_hub.TextToSpeechParameters

< >

( generate: Optional = None )

附加推理参数 文本转语音的附加推理参数

token_classification

huggingface_hub.TokenClassificationInput

< >

( inputs: str parameters: Optional = None )

标记分类推理的输入

huggingface_hub.TokenClassificationOutputElement

< >

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

标记分类任务的推理输出

huggingface_hub.TokenClassificationParameters

< >

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

其他推理参数 用于标记分类的其他推理参数

翻译

huggingface_hub.TranslationInput

< >

( inputs: str parameters: Optional = None )

翻译推理的输入

huggingface_hub.TranslationOutput

< >

( translation_text: str )

翻译任务的推理输出

huggingface_hub.TranslationParameters

< >

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

其他推理参数 用于翻译的其他推理参数

视频分类

huggingface_hub.VideoClassificationInput

< >

( inputs: Any parameters: Optional = None )

视频分类推理的输入

huggingface_hub.VideoClassificationOutputElement

< >

( 标签: str 分数: float )

视频分类任务的推理输出

huggingface_hub.VideoClassificationParameters

< >

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

额外的推理参数 视频分类的额外推理参数

视觉问答

huggingface_hub.VisualQuestionAnsweringInput

< >

( inputs: VisualQuestionAnsweringInputData parameters: Optional = None )

视觉问答推理的输入

huggingface_hub.VisualQuestionAnsweringInputData

< >

( image: Any question: Any )

一个需要回答的(图像,问题)对

huggingface_hub.VisualQuestionAnsweringOutputElement

< >

( 标签: Any 得分: float 答案: Optional = None )

视觉问答任务的推理输出

huggingface_hub.VisualQuestionAnsweringParameters

< >

( top_k: Optional = None )

附加推理参数 视觉问答的附加推理参数

零样本分类

huggingface_hub.ZeroShotClassificationInput

< >

( 输入: ZeroShotClassificationInputData 参数: Optional = None )

零样本分类推理的输入

huggingface_hub.ZeroShotClassificationInputData

< >

( 候选标签: List 文本: str )

输入文本数据,以及候选标签

huggingface_hub.ZeroShotClassificationOutputElement

< >

( 标签: str 分数: float )

零样本分类任务的推理输出

huggingface_hub.ZeroShotClassificationParameters

< >

( hypothesis_template: 可选 = 无 multi_label: 可选 = 无 )

附加推理参数 零样本分类的附加推理参数

零样本图像分类

huggingface_hub.ZeroShotImageClassificationInput

< >

( inputs: ZeroShotImageClassificationInputData parameters: 可选 = 无 )

零样本图像分类推理的输入

huggingface_hub.ZeroShotImageClassificationInputData

< >

( candidate_labels: 列表 image: 任意 )

输入图像数据,包含候选标签

huggingface_hub.ZeroShotImageClassificationOutputElement

< >

( 标签: str 分数: float )

零样本图像分类任务的推理输出

huggingface_hub.ZeroShotImageClassificationParameters

< >

( hypothesis_template: Optional = None )

零样本图像分类的附加推理参数

zero_shot_object_detection

huggingface_hub.ZeroShotObjectDetectionBoundingBox

< >

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

预测的边界框。坐标相对于输入图像的左上角。

huggingface_hub.ZeroShotObjectDetectionInput

< >

( inputs: ZeroShotObjectDetectionInputData parameters: Optional = None )

零样本目标检测推理的输入

huggingface_hub.ZeroShotObjectDetectionInputData

< >

( candidate_labels: 列表 image: 任意 )

输入图像数据,包含候选标签

huggingface_hub.ZeroShotObjectDetectionOutputElement

< >

( box: ZeroShotObjectDetectionBoundingBox label: str score: float )

零样本目标检测任务的推理输出

< > 在 GitHub 上更新