Huggingface.js 文档
@huggingface/inference
并获得增强的文档体验
开始使用
@huggingface/inference
命名空间
类
- HfInference
- InferenceClient
- InferenceClientEndpoint
- InferenceClientError
- InferenceClientHubApiError
- InferenceClientInputError
- InferenceClientProviderApiError
- InferenceClientProviderOutputError
接口
- AudioToAudioOutput
- AudioToAudioOutputElem
- BaseArgs
- BodyParams
- HeaderParams
- InferenceProviderMappingEntry
- Logger
- Options
- TextGenerationInput
- TextGenerationOutput
- TextGenerationStreamBestOfSequence
- TextGenerationStreamDetails
- TextGenerationStreamOutput
- TextGenerationStreamPrefillToken
- TextGenerationStreamToken
- UrlParams
类型别名
AudioClassificationArgs
Ƭ AudioClassificationArgs: BaseArgs
& AudioClassificationInput
| LegacyAudioInput
定义于
inference/src/tasks/audio/audioClassification.ts:9
AudioToAudioArgs
Ƭ AudioToAudioArgs: BaseArgs
& { inputs
: Blob
} | LegacyAudioInput
定义于
inference/src/tasks/audio/audioToAudio.ts:8
AuthMethod
Ƭ AuthMethod: "none"
| "hf-token"
| "credentials-include"
| "provider-key"
定义于
AutomaticSpeechRecognitionArgs
Ƭ AutomaticSpeechRecognitionArgs: BaseArgs
& AutomaticSpeechRecognitionInput
| LegacyAudioInput
定义于
inference/src/tasks/audio/automaticSpeechRecognition.ts:9
DocumentQuestionAnsweringArgs
Ƭ DocumentQuestionAnsweringArgs: BaseArgs
& DocumentQuestionAnsweringInput
& { inputs
: DocumentQuestionAnsweringInputData
& { image
: Blob
} }
定义于
inference/src/tasks/multimodal/documentQuestionAnswering.ts:13
FeatureExtractionArgs
Ƭ FeatureExtractionArgs: BaseArgs
& FeatureExtractionInput
& FeatureExtractionOAICompatInput
定义于
inference/src/tasks/nlp/featureExtraction.ts:12
FeatureExtractionOutput
Ƭ FeatureExtractionOutput: (number
| number
[] | number
[][])[]
返回值为浮点型多维数组(维度取决于您发送的是字符串还是字符串列表,以及是否对您应用了自动降维,例如 mean_pooling。这应该在模型的 README 中解释)。
定义于
inference/src/tasks/nlp/featureExtraction.ts:17
FillMaskArgs
Ƭ FillMaskArgs: BaseArgs
& FillMaskInput
定义于
inference/src/tasks/nlp/fillMask.ts:7
ImageClassificationArgs
Ƭ ImageClassificationArgs: BaseArgs
& ImageClassificationInput
| LegacyImageInput
定义于
inference/src/tasks/cv/imageClassification.ts:8
ImageSegmentationArgs
Ƭ ImageSegmentationArgs: BaseArgs
& ImageSegmentationInput
定义于
inference/src/tasks/cv/imageSegmentation.ts:8
ImageToImageArgs
Ƭ ImageToImageArgs: BaseArgs
& ImageToImageInput
定义于
inference/src/tasks/cv/imageToImage.ts:8
ImageToTextArgs
Ƭ ImageToTextArgs: BaseArgs
& ImageToTextInput
| LegacyImageInput
定义于
inference/src/tasks/cv/imageToText.ts:9
ImageToVideoArgs
Ƭ ImageToVideoArgs: BaseArgs
& ImageToVideoInput
定义于
inference/src/tasks/cv/imageToVideo.ts:8
InferenceProvider
Ƭ InferenceProvider: typeof INFERENCE_PROVIDERS
[number
]
定义于
InferenceProviderOrPolicy
Ƭ InferenceProviderOrPolicy: typeof PROVIDERS_OR_POLICIES
[number
]
定义于
InferenceTask
Ƭ InferenceTask: Exclude
\<PipelineType
, "other"
> | "conversational"
定义于
ModelId
Ƭ ModelId: string
HF 模型 ID,例如“meta-llama/Llama-3.3-70B-Instruct”
定义于
ObjectDetectionArgs
Ƭ ObjectDetectionArgs: BaseArgs
& ObjectDetectionInput
| LegacyImageInput
定义于
inference/src/tasks/cv/objectDetection.ts:8
QuestionAnsweringArgs
Ƭ QuestionAnsweringArgs: BaseArgs
& QuestionAnsweringInput
定义于
inference/src/tasks/nlp/questionAnswering.ts:8
RequestArgs
Ƭ RequestArgs: BaseArgs
& { data
: Blob
| ArrayBuffer
} | { inputs
: unknown
} | { prompt
: string
} | { text
: string
} | { audio_url
: string
} | ChatCompletionInput
& { parameters?
: Record
\<string
, unknown
> }
定义于
SentenceSimilarityArgs
Ƭ SentenceSimilarityArgs: BaseArgs
& SentenceSimilarityInput
定义于
inference/src/tasks/nlp/sentenceSimilarity.ts:7
SummarizationArgs
Ƭ SummarizationArgs: BaseArgs
& SummarizationInput
定义于
inference/src/tasks/nlp/summarization.ts:7
TableQuestionAnsweringArgs
Ƭ TableQuestionAnsweringArgs: BaseArgs
& TableQuestionAnsweringInput
定义于
inference/src/tasks/nlp/tableQuestionAnswering.ts:7
TabularClassificationArgs
Ƭ TabularClassificationArgs: BaseArgs
& { inputs
: { data
: Record
\<string
, string
[]> } }
定义于
inference/src/tasks/tabular/tabularClassification.ts:6
TabularClassificationOutput
Ƭ TabularClassificationOutput: number
[]
每行的预测标签列表
定义于
inference/src/tasks/tabular/tabularClassification.ts:18
TabularRegressionArgs
Ƭ TabularRegressionArgs: BaseArgs
& { inputs
: { data
: Record
\<string
, string
[]> } }
定义于
inference/src/tasks/tabular/tabularRegression.ts:6
TabularRegressionOutput
Ƭ TabularRegressionOutput: number
[]
每行的预测值列表
定义于
inference/src/tasks/tabular/tabularRegression.ts:18
TextClassificationArgs
Ƭ TextClassificationArgs: BaseArgs
& TextClassificationInput
定义于
inference/src/tasks/nlp/textClassification.ts:7
TextGenerationStreamFinishReason
Ƭ TextGenerationStreamFinishReason: "length"
| "eos_token"
| "stop_sequence"
定义于
inference/src/tasks/nlp/textGenerationStream.ts:48
TextToImageArgs
Ƭ TextToImageArgs: BaseArgs
& TextToImageInput
定义于
inference/src/tasks/cv/textToImage.ts:8
TextToVideoArgs
Ƭ TextToVideoArgs: BaseArgs
& TextToVideoInput
定义于
inference/src/tasks/cv/textToVideo.ts:11
TextToVideoOutput
Ƭ TextToVideoOutput: Blob
定义于
inference/src/tasks/cv/textToVideo.ts:13
TokenClassificationArgs
Ƭ TokenClassificationArgs: BaseArgs
& TokenClassificationInput
定义于
inference/src/tasks/nlp/tokenClassification.ts:7
TranslationArgs
Ƭ TranslationArgs: BaseArgs
& TranslationInput
定义于
inference/src/tasks/nlp/translation.ts:7
VisualQuestionAnsweringArgs
Ƭ VisualQuestionAnsweringArgs: BaseArgs
& VisualQuestionAnsweringInput
& { inputs
: VisualQuestionAnsweringInputData
& { image
: Blob
} }
定义于
inference/src/tasks/multimodal/visualQuestionAnswering.ts:13
ZeroShotClassificationArgs
Ƭ ZeroShotClassificationArgs: BaseArgs
& ZeroShotClassificationInput
定义于
inference/src/tasks/nlp/zeroShotClassification.ts:7
ZeroShotImageClassificationArgs
Ƭ ZeroShotImageClassificationArgs: BaseArgs
& ZeroShotImageClassificationInput
| LegacyZeroShotImageClassificationInput
定义于
inference/src/tasks/cv/zeroShotImageClassification.ts:15
变量
INFERENCE _ PROVIDERS
• Const
INFERENCE_PROVIDERS: 只读 ["black-forest-labs"
, "cerebras"
, "cohere"
, "fal-ai"
, "featherless-ai"
, "fireworks-ai"
, "groq"
, "hf-inference"
, "hyperbolic"
, "nebius"
, "novita"
, "nscale"
, "openai"
, "ovhcloud"
, "replicate"
, "sambanova"
, "together"
]
定义于
PROVIDERS
• Const
PROVIDERS: Record
\<InferenceProvider
, Partial
\<Record
\<InferenceTask
, TaskProviderHelper
>>>
定义于
inference/src/lib/getProviderHelper.ts:54
PROVIDERS _ OR _ POLICIES
• Const
PROVIDERS_OR_POLICIES: 只读 ["black-forest-labs"
, "cerebras"
, "cohere"
, "fal-ai"
, "featherless-ai"
, "fireworks-ai"
, "groq"
, "hf-inference"
, "hyperbolic"
, "nebius"
, ""novita"
, "nscale"
, "openai"
, "ovhcloud"
, "replicate"
, "sambanova"
, "together"
, "auto"
]
定义于
函数
audioClassification
▸ audioClassification(args
, options?
): Promise
\<AudioClassificationOutput
>
此任务读取音频输入并输出类别的可能性。推荐模型:superb/hubert-large-superb-er
参数
名称 | 类型 |
---|---|
args | AudioClassificationArgs |
options? | Options |
返回值
Promise
\<AudioClassificationOutput
>
定义于
inference/src/tasks/audio/audioClassification.ts:15
audioToAudio
▸ audioToAudio(args
, options?
): Promise
\<AudioToAudioOutput
[]>
此任务读取音频输入并输出一个或多个音频文件。示例模型:speechbrain/sepformer-wham 进行音频源分离。
参数
名称 | 类型 |
---|---|
args | AudioToAudioArgs |
options? | Options |
返回值
Promise
\<AudioToAudioOutput
[]>
定义于
inference/src/tasks/audio/audioToAudio.ts:39
automaticSpeechRecognition
▸ automaticSpeechRecognition(args
, options?
): Promise
\<AutomaticSpeechRecognitionOutput
>
此任务读取音频输入并输出音频文件中的口语单词。推荐模型(英语):facebook/wav2vec2-large-960h-lv60-self
参数
名称 | 类型 |
---|---|
args | AutomaticSpeechRecognitionArgs |
options? | Options |
返回值
Promise
\<AutomaticSpeechRecognitionOutput
>
定义于
inference/src/tasks/audio/automaticSpeechRecognition.ts:14
chatCompletion
▸ chatCompletion(args
, options?
): Promise
\<ChatCompletionOutput
>
使用聊天完成端点生成对提示的响应,使用 OpenAI 消息完成 API,无流
参数
名称 | 类型 |
---|---|
args | BaseArgs & ChatCompletionInput |
options? | Options |
返回值
Promise
\<ChatCompletionOutput
>
定义于
inference/src/tasks/nlp/chatCompletion.ts:10
chatCompletionStream
▸ chatCompletionStream(args
, options?
): AsyncGenerator
\<ChatCompletionStreamOutput
>
用于从提示继续文本。与 textGeneration
相同,但返回一个可一次读取一个 token 的生成器
参数
名称 | 类型 |
---|---|
args | BaseArgs & ChatCompletionInput |
options? | Options |
返回值
AsyncGenerator
\<ChatCompletionStreamOutput
>
定义于
inference/src/tasks/nlp/chatCompletionStream.ts:10
documentQuestionAnswering
▸ documentQuestionAnswering(args
, options?
): Promise
\<DocumentQuestionAnsweringOutput
[number
]>
回答文档图像上的问题。推荐模型:impira/layoutlm-document-qa。
参数
名称 | 类型 |
---|---|
args | DocumentQuestionAnsweringArgs |
options? | Options |
返回值
Promise
\<DocumentQuestionAnsweringOutput
[number
]>
定义于
inference/src/tasks/multimodal/documentQuestionAnswering.ts:19
featureExtraction
▸ featureExtraction(args
, options?
): Promise
\<FeatureExtractionOutput
>
此任务读取一些文本并输出原始浮点值,这些值通常作为语义数据库/语义搜索的一部分被使用。
参数
名称 | 类型 |
---|---|
args | FeatureExtractionArgs |
options? | Options |
返回值
Promise
\<FeatureExtractionOutput
>
定义于
inference/src/tasks/nlp/featureExtraction.ts:22
fillMask
▸ fillMask(args
, options?
): Promise
\<FillMaskOutput
>
尝试用缺失的单词(准确地说是标记)填充空白。这是 BERT 模型的基本任务。
参数
名称 | 类型 |
---|---|
args | FillMaskArgs |
options? | Options |
返回
Promise
\<FillMaskOutput
>
定义于
inference/src/tasks/nlp/fillMask.ts:12
getProviderHelper
▸ getProviderHelper(provider
, task
): TextToImageTaskHelper
& TaskProviderHelper
通过名称和任务获取提供者辅助实例
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "text-to-image" |
返回
TextToImageTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:161
▸ getProviderHelper(provider
, task
): ConversationalTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "conversational" |
返回
ConversationalTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:165
▸ getProviderHelper(provider
, task
): TextGenerationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "text-generation" |
返回
TextGenerationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:169
▸ getProviderHelper(provider
, task
): TextToSpeechTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "text-to-speech" |
返回
TextToSpeechTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:173
▸ getProviderHelper(provider
, task
): TextToAudioTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "text-to-audio" |
返回
TextToAudioTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:177
▸ getProviderHelper(provider
, task
): AutomaticSpeechRecognitionTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "automatic-speech-recognition" |
返回
AutomaticSpeechRecognitionTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:181
▸ getProviderHelper(provider
, task
): TextToVideoTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "text-to-video" |
返回
TextToVideoTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:185
▸ getProviderHelper(provider
, task
): TextClassificationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "text-classification" |
返回
TextClassificationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:189
▸ getProviderHelper(provider
, task
): QuestionAnsweringTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "question-answering" |
返回
QuestionAnsweringTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:193
▸ getProviderHelper(provider
, task
): AudioClassificationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "audio-classification" |
返回
AudioClassificationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:197
▸ getProviderHelper(provider
, task
): AudioToAudioTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "audio-to-audio" |
返回
AudioToAudioTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:201
▸ getProviderHelper(provider
, task
): FillMaskTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "fill-mask" |
返回
FillMaskTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:205
▸ getProviderHelper(provider
, task
): FeatureExtractionTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "feature-extraction" |
返回
FeatureExtractionTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:209
▸ getProviderHelper(provider
, task
): ImageClassificationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "image-classification" |
返回
ImageClassificationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:213
▸ getProviderHelper(provider
, task
): ImageSegmentationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "image-segmentation" |
返回
ImageSegmentationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:217
▸ getProviderHelper(provider
, task
): DocumentQuestionAnsweringTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "document-question-answering" |
返回
DocumentQuestionAnsweringTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:221
▸ getProviderHelper(provider
, task
): ImageToTextTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "image-to-text" |
返回
ImageToTextTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:225
▸ getProviderHelper(provider
, task
): ObjectDetectionTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "object-detection" |
返回
ObjectDetectionTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:229
▸ getProviderHelper(provider
, task
): ZeroShotImageClassificationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "zero-shot-image-classification" |
返回
ZeroShotImageClassificationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:233
▸ getProviderHelper(provider
, task
): ZeroShotClassificationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "zero-shot-classification" |
返回
ZeroShotClassificationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:237
▸ getProviderHelper(provider
, task
): ImageToImageTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "image-to-image" |
返回
ImageToImageTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:241
▸ getProviderHelper(provider
, task
): ImageToVideoTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "image-to-video" |
返回
ImageToVideoTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:245
▸ getProviderHelper(provider
, task
): SentenceSimilarityTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "sentence-similarity" |
返回
SentenceSimilarityTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:249
▸ getProviderHelper(provider
, task
): TableQuestionAnsweringTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "table-question-answering" |
返回
TableQuestionAnsweringTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:253
▸ getProviderHelper(provider
, task
): TabularClassificationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "tabular-classification" |
返回
TabularClassificationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:257
▸ getProviderHelper(provider
, task
): TabularRegressionTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "tabular-regression" |
返回
TabularRegressionTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:261
▸ getProviderHelper(provider
, task
): TokenClassificationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "token-classification" |
返回
TokenClassificationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:265
▸ getProviderHelper(provider
, task
): TranslationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "translation" |
返回
TranslationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:269
▸ getProviderHelper(provider
, task
): SummarizationTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "summarization" |
返回
SummarizationTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:273
▸ getProviderHelper(provider
, task
): VisualQuestionAnsweringTaskHelper
& TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | "visual-question-answering" |
返回
VisualQuestionAnsweringTaskHelper
& TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:277
▸ getProviderHelper(provider
, task
): TaskProviderHelper
参数
名称 | 类型 |
---|---|
提供者 | "black-forest-labs" | "cerebras" | "cohere" | "fal-ai" | "featherless-ai" | "fireworks-ai" | "groq" | "hf-inference" | "hyperbolic" | "nebius" | "novita" | "nscale" | "openai" | "ovhcloud" | "replicate" | "sambanova" | "together" | "auto" |
任务 | undefined | InferenceTask |
返回
TaskProviderHelper
定义于
inference/src/lib/getProviderHelper.ts:281
imageClassification
▸ imageClassification(args
, options?
): Promise
\<ImageClassificationOutput
>
此任务读取图像输入并输出类别的可能性。推荐模型:google/vit-base-patch16-224
参数
名称 | 类型 |
---|---|
args | ImageClassificationArgs |
options? | Options |
返回
Promise
\<ImageClassificationOutput
>
定义于
inference/src/tasks/cv/imageClassification.ts:14
imageSegmentation
▸ imageSegmentation(args
, options?
): Promise
\<ImageSegmentationOutput
>
此任务读取图像输入并输出检测到对象的类别可能性和边界框。推荐模型:facebook/detr-resnet-50-panoptic
参数
名称 | 类型 |
---|---|
args | ImageSegmentationArgs |
options? | Options |
返回
Promise
\<ImageSegmentationOutput
>
定义于
inference/src/tasks/cv/imageSegmentation.ts:14
imageToImage
▸ imageToImage(args
, options?
): Promise
\<Blob
>
此任务读取文本输入并输出图像。推荐模型:lllyasviel/sd-controlnet-depth
参数
名称 | 类型 |
---|---|
args | ImageToImageArgs |
options? | Options |
返回
Promise
\<Blob
>
定义于
inference/src/tasks/cv/imageToImage.ts:14
imageToText
▸ imageToText(args
, options?
): Promise
\<ImageToTextOutput
>
此任务读取图像输入并输出文本描述。
参数
名称 | 类型 |
---|---|
args | ImageToTextArgs |
options? | Options |
返回
Promise
\<ImageToTextOutput
>
定义于
inference/src/tasks/cv/imageToText.ts:13
imageToVideo
▸ imageToVideo(args
, options?
): Promise
\<Blob
>
此任务读取文本输入并输出图像。推荐模型:Wan-AI/Wan2.1-I2V-14B-720P
参数
名称 | 类型 |
---|---|
args | ImageToVideoArgs |
options? | Options |
返回
Promise
\<Blob
>
定义于
inference/src/tasks/cv/imageToVideo.ts:14
makeRequestOptions
▸ makeRequestOptions(args
, providerHelper
, options?
): Promise
\<{ info
: RequestInit
; url
: string
}>
辅助函数,用于准备请求参数。此异步版本处理模型 ID 解析步骤。
参数
名称 | 类型 |
---|---|
args | RequestArgs & { data? : Blob | ArrayBuffer ; stream? : boolean } |
providerHelper | TaskProviderHelper |
options? | Options & { task? : InferenceTask } |
返回
Promise
\<{ info
: RequestInit
; url
: string
}>
定义于
inference/src/lib/makeRequestOptions.ts:19
makeRequestOptionsFromResolvedModel
▸ makeRequestOptionsFromResolvedModel(resolvedModel
, providerHelper
, args
, mapping
, options?
): Object
辅助函数,用于准备请求参数。- 仅供内部使用。此同步版本跳过模型 ID 解析步骤。
参数
名称 | 类型 |
---|---|
resolvedModel | 字符串 |
providerHelper | TaskProviderHelper |
args | RequestArgs & { data? : Blob | ArrayBuffer ; stream? : boolean } |
mapping | undefined | InferenceProviderMappingEntry |
options? | Options & { task? : InferenceTask } |
返回
Object
名称 | 类型 |
---|---|
info | RequestInit |
url | 字符串 |
定义于
inference/src/lib/makeRequestOptions.ts:105
objectDetection
▸ objectDetection(args
, options?
): Promise
\<ObjectDetectionOutput
>
此任务读取图像输入并输出检测到对象的类别可能性和边界框。推荐模型:facebook/detr-resnet-50
参数
名称 | 类型 |
---|---|
args | ObjectDetectionArgs |
options? | Options |
返回
Promise
\<ObjectDetectionOutput
>
定义于
inference/src/tasks/cv/objectDetection.ts:14
questionAnswering
▸ questionAnswering(args
, options?
): Promise
\<QuestionAnsweringOutput
[number
]>
想要一个无所不知的机器人,可以回答任何问题?推荐模型:deepset/roberta-base-squad2
参数
名称 | 类型 |
---|---|
args | QuestionAnsweringArgs |
options? | Options |
返回
Promise
\<QuestionAnsweringOutput
[number
]>
定义于
inference/src/tasks/nlp/questionAnswering.ts:13
request
▸ request\<T
>(args
, options?
): Promise
\<T
>
用于向推理提供者进行自定义调用的原语
类型参数
名称 |
---|
T |
参数
名称 | 类型 |
---|---|
args | RequestArgs |
options? | Options & { task? : InferenceTask } |
返回
Promise
\<T
>
已弃用
请改用特定的任务函数。此函数将在未来版本中移除。
定义于
inference/src/tasks/custom/request.ts:11
sentenceSimilarity
▸ sentenceSimilarity(args
, options?
): Promise
\<SentenceSimilarityOutput
>
通过比较嵌入来计算一段文本与另一组句子之间的语义相似度。
参数
名称 | 类型 |
---|---|
args | SentenceSimilarityArgs |
options? | Options |
返回
Promise
\<SentenceSimilarityOutput
>
定义于
inference/src/tasks/nlp/sentenceSimilarity.ts:12
setLogger
▸ setLogger(logger
): void
参数
名称 | 类型 |
---|---|
logger | Logger |
返回
空
定义于
streamingRequest
▸ streamingRequest\<T
>(args
, options?
): AsyncGenerator
\<T
>
用于进行自定义推理调用的原语,该调用期望服务器发送事件,并通过生成器返回响应
类型参数
名称 |
---|
T |
参数
名称 | 类型 |
---|---|
args | RequestArgs |
options? | Options & { task? : InferenceTask } |
返回
AsyncGenerator
\<T
>
已弃用
请改用特定的任务函数。此函数将在未来版本中移除。
定义于
inference/src/tasks/custom/streamingRequest.ts:11
summarization
▸ summarization(args
, options?
): Promise
\<SummarizationOutput
>
此任务以将较长文本总结为较短文本而闻名。请注意,某些模型的输入长度有最大限制。这意味着摘要无法处理完整的书籍等。选择模型时请谨慎。
参数
名称 | 类型 |
---|---|
args | SummarizationArgs |
options? | Options |
返回
Promise
\<SummarizationOutput
>
定义于
inference/src/tasks/nlp/summarization.ts:12
tableQuestionAnswering
▸ tableQuestionAnswering(args
, options?
): Promise
\<TableQuestionAnsweringOutput
[number
]\>
不懂SQL?不想深入研究大型电子表格?用普通英语提问!推荐模型:google/tapas-base-finetuned-wtq。
参数
名称 | 类型 |
---|---|
args | TableQuestionAnsweringArgs |
options? | Options |
返回
Promise
\<TableQuestionAnsweringOutput
[number
]\>
定义于
inference/src/tasks/nlp/tableQuestionAnswering.ts:12
tabularClassification
▸ tabularClassification(args
, options?
): Promise
\<TabularClassificationOutput
\>
根据给定的表格形式特征集预测目标标签。通常,您会希望在训练数据上训练一个分类模型,并将其与相同格式的新数据一起使用。示例模型:vvmnnnkv/wine-quality
参数
名称 | 类型 |
---|---|
args | TabularClassificationArgs |
options? | Options |
返回
Promise
\<TabularClassificationOutput
\>
定义于
inference/src/tasks/tabular/tabularClassification.ts:25
tabularRegression
▸ tabularRegression(args
, options?
): Promise
\<TabularRegressionOutput
\>
为给定表格形式的特征集预测目标值。通常,您会希望在训练数据上训练回归模型,并将其与格式相同的新数据一起使用。示例模型:scikit-learn/Fish-Weight
参数
名称 | 类型 |
---|---|
args | TabularRegressionArgs |
options? | Options |
返回
Promise
\<TabularRegressionOutput
\>
定义于
inference/src/tasks/tabular/tabularRegression.ts:25
textClassification
▸ textClassification(args
, options?
): Promise
\<TextClassificationOutput
\>
通常用于情感分析,它将输出输入类的可能性。推荐模型:distilbert-base-uncased-finetuned-sst-2-english
参数
名称 | 类型 |
---|---|
args | TextClassificationArgs |
options? | Options |
返回
Promise
\<TextClassificationOutput
\>
定义于
inference/src/tasks/nlp/textClassification.ts:12
textGeneration
▸ textGeneration(args
, options?
): Promise
\<TextGenerationOutput
\>
用于从提示符继续文本。这是一个非常通用的任务。推荐模型:gpt2(一个简单的模型,但很有趣)。
参数
名称 | 类型 |
---|---|
args | BaseArgs \& TextGenerationInput |
options? | Options |
返回
Promise
\<TextGenerationOutput
\>
定义于
inference/src/tasks/nlp/textGeneration.ts:13
textGenerationStream
▸ textGenerationStream(args
, options?
): AsyncGenerator
\<TextGenerationStreamOutput
\>
用于从提示继续文本。与 textGeneration
相同,但返回一个可一次读取一个 token 的生成器
参数
名称 | 类型 |
---|---|
args | BaseArgs \& TextGenerationInput |
options? | Options |
返回
AsyncGenerator
\<TextGenerationStreamOutput
\>
定义于
inference/src/tasks/nlp/textGenerationStream.ts:90
textToImage
▸ textToImage(args
, options?
): Promise
\<string
\>
此任务读取一些文本输入并输出图像。推荐模型:stabilityai/stable-diffusion-2
参数
名称 | 类型 |
---|---|
args | TextToImageArgs |
options? | TextToImageOptions \& { outputType : "url" } |
返回
Promise
\<string
\>
定义于
inference/src/tasks/cv/textToImage.ts:18
▸ textToImage(args
, options?
): Promise
\<Blob
\>
参数
名称 | 类型 |
---|---|
args | TextToImageArgs |
options? | TextToImageOptions \& { outputType? : "blob" } |
返回
Promise
\<Blob
>
定义于
inference/src/tasks/cv/textToImage.ts:22
▸ textToImage(args
, options?
): Promise
\<Record
\<string
, unknown
\>\>
参数
名称 | 类型 |
---|---|
args | TextToImageArgs |
options? | TextToImageOptions \& { outputType? : "json" } |
返回
Promise
\<Record
\<string
, unknown
\>\>
定义于
inference/src/tasks/cv/textToImage.ts:26
textToSpeech
▸ textToSpeech(args
, options?
): Promise
\<Blob
\>
此任务合成语音音频,发出给定文本。推荐模型:espnet/kan-bayashi_ljspeech_vits
参数
名称 | 类型 |
---|---|
args | TextToSpeechArgs |
options? | Options |
返回
Promise
\<Blob
>
定义于
inference/src/tasks/audio/textToSpeech.ts:15
textToVideo
▸ textToVideo(args
, options?
): Promise
\<TextToVideoOutput
\>
参数
名称 | 类型 |
---|---|
args | TextToVideoArgs |
options? | Options |
返回
Promise
\<TextToVideoOutput
\>
定义于
inference/src/tasks/cv/textToVideo.ts:15
tokenClassification
▸ tokenClassification(args
, options?
): Promise
\<TokenClassificationOutput
\>
通常用于句子解析,可以是语法分析,也可以是命名实体识别(NER)以理解文本中包含的关键词。推荐模型:dbmdz/bert-large-cased-finetuned-conll03-english
参数
名称 | 类型 |
---|---|
args | TokenClassificationArgs |
options? | Options |
返回
Promise
\<TokenClassificationOutput
\>
定义于
inference/src/tasks/nlp/tokenClassification.ts:12
translation
▸ translation(args
, options?
): Promise
\<TranslationOutput
\>
此任务众所周知可将文本从一种语言翻译成另一种语言。推荐模型:Helsinki-NLP/opus-mt-ru-en。
参数
名称 | 类型 |
---|---|
args | TranslationArgs |
options? | Options |
返回
Promise
\<TranslationOutput
\>
定义于
inference/src/tasks/nlp/translation.ts:11
visualQuestionAnswering
▸ visualQuestionAnswering(args
, options?
): Promise
\<VisualQuestionAnsweringOutput
[number
]\>
回答图像上的问题。推荐模型:dandelin/vilt-b32-finetuned-vqa。
参数
名称 | 类型 |
---|---|
args | VisualQuestionAnsweringArgs |
options? | Options |
返回
Promise
\<VisualQuestionAnsweringOutput
[number
]\>
定义于
inference/src/tasks/multimodal/visualQuestionAnswering.ts:19
zeroShotClassification
▸ zeroShotClassification(args
, options?
): Promise
\<ZeroShotClassificationOutput
\>
此任务在零代码的情况下进行分类非常有用,您只需传递一个句子/段落和该句子的可能标签,即可获得结果。推荐模型:facebook/bart-large-mnli。
参数
名称 | 类型 |
---|---|
args | ZeroShotClassificationArgs |
options? | Options |
返回
Promise
\<ZeroShotClassificationOutput
\>
定义于
inference/src/tasks/nlp/zeroShotClassification.ts:12
zeroShotImageClassification
▸ zeroShotImageClassification(args
, options?
): Promise
\<ZeroShotImageClassificationOutput
\>
将图像分类到指定的类别中。推荐模型:openai/clip-vit-large-patch14-336
参数
名称 | 类型 |
---|---|
args | ZeroShotImageClassificationArgs |
options? | Options |
返回
Promise
\<ZeroShotImageClassificationOutput
\>
定义于
inference/src/tasks/cv/zeroShotImageClassification.ts:44
< > 在 GitHub 上更新