@huggingface/inference
Classes
Interfaces
- AudioClassificationOutputValue
- AudioToAudioOutputValue
- AutomaticSpeechRecognitionOutput
- BaseArgs
- ConversationalOutput
- DocumentQuestionAnsweringOutput
- ImageClassificationOutputValue
- ImageSegmentationOutputValue
- ImageToTextOutput
- ObjectDetectionOutputValue
- Options
- QuestionAnsweringOutput
- SummarizationOutput
- TableQuestionAnsweringOutput
- TextGenerationOutput
- TextGenerationStreamBestOfSequence
- TextGenerationStreamDetails
- TextGenerationStreamOutput
- TextGenerationStreamPrefillToken
- TextGenerationStreamToken
- TokenClassificationOutputValue
- TranslationOutput
- VisualQuestionAnsweringOutput
- ZeroShotClassificationOutputValue
- ZeroShotImageClassificationOutputValue
Type Aliases
AudioClassificationArgs
Ƭ AudioClassificationArgs: BaseArgs & { data: Blob | ArrayBuffer }
Defined in
inference/src/tasks/audio/audioClassification.ts:5
AudioClassificationReturn
Ƭ AudioClassificationReturn: AudioClassificationOutputValue[]
Defined in
inference/src/tasks/audio/audioClassification.ts:24
AudioToAudioArgs
Ƭ AudioToAudioArgs: BaseArgs & { data: Blob | ArrayBuffer }
Defined in
inference/src/tasks/audio/audioToAudio.ts:5
AudioToAudioReturn
Ƭ AudioToAudioReturn: AudioToAudioOutputValue[]
Defined in
inference/src/tasks/audio/audioToAudio.ts:29
AutomaticSpeechRecognitionArgs
Ƭ AutomaticSpeechRecognitionArgs: BaseArgs & { data: Blob | ArrayBuffer }
Defined in
inference/src/tasks/audio/automaticSpeechRecognition.ts:5
ConversationalArgs
Ƭ ConversationalArgs: BaseArgs & { inputs: { generated_responses?: string[] ; past_user_inputs?: string[] ; text: string } ; parameters?: { max_length?: number ; max_time?: number ; min_length?: number ; repetition_penalty?: number ; temperature?: number ; top_k?: number ; top_p?: number } }
Defined in
inference/src/tasks/nlp/conversational.ts:5
DocumentQuestionAnsweringArgs
Ƭ DocumentQuestionAnsweringArgs: BaseArgs & { inputs: { image: Blob | ArrayBuffer ; question: string } }
Defined in
inference/src/tasks/multimodal/documentQuestionAnswering.ts:8
FeatureExtractionArgs
Ƭ FeatureExtractionArgs: BaseArgs & { inputs: string | string[] }
Defined in
inference/src/tasks/nlp/featureExtraction.ts:6
FeatureExtractionOutput
Ƭ FeatureExtractionOutput: (number | number[] | number[][])[]
Returned values are a multidimensional array of floats (dimension depending on if you sent a string or a list of string, and if the automatic reduction, usually mean_pooling for instance was applied for you or not. This should be explained on the model’s README).
Defined in
inference/src/tasks/nlp/featureExtraction.ts:19
FillMaskArgs
Ƭ FillMaskArgs: BaseArgs & { inputs: string }
Defined in
inference/src/tasks/nlp/fillMask.ts:5
FillMaskOutput
Ƭ FillMaskOutput: { score: number ; sequence: string ; token: number ; token_str: string }[]
Defined in
inference/src/tasks/nlp/fillMask.ts:9
ImageClassificationArgs
Ƭ ImageClassificationArgs: BaseArgs & { data: Blob | ArrayBuffer }
Defined in
inference/src/tasks/cv/imageClassification.ts:5
ImageClassificationOutput
Ƭ ImageClassificationOutput: ImageClassificationOutputValue[]
Defined in
inference/src/tasks/cv/imageClassification.ts:23
ImageSegmentationArgs
Ƭ ImageSegmentationArgs: BaseArgs & { data: Blob | ArrayBuffer }
Defined in
inference/src/tasks/cv/imageSegmentation.ts:5
ImageSegmentationOutput
Ƭ ImageSegmentationOutput: ImageSegmentationOutputValue[]
Defined in
inference/src/tasks/cv/imageSegmentation.ts:27
ImageToImageArgs
Ƭ ImageToImageArgs: BaseArgs & { inputs: Blob | ArrayBuffer ; parameters?: { guess_mode?: boolean ; guidance_scale?: number ; height?: number ; negative_prompt?: string ; num_inference_steps?: number ; prompt?: string ; strength?: number ; width?: number } }
Defined in
inference/src/tasks/cv/imageToImage.ts:6
ImageToImageOutput
Ƭ ImageToImageOutput: Blob
Defined in
inference/src/tasks/cv/imageToImage.ts:55
ImageToTextArgs
Ƭ ImageToTextArgs: BaseArgs & { data: Blob | ArrayBuffer }
Defined in
inference/src/tasks/cv/imageToText.ts:5
InferenceTask
Ƭ InferenceTask: "audio-classification" | "audio-to-audio" | "automatic-speech-recognition" | "conversational" | "depth-estimation" | "document-question-answering" | "feature-extraction" | "fill-mask" | "image-classification" | "image-segmentation" | "image-to-image" | "image-to-text" | "object-detection" | "video-classification" | "question-answering" | "reinforcement-learning" | "sentence-similarity" | "summarization" | "table-question-answering" | "tabular-classification" | "tabular-regression" | "text-classification" | "text-generation" | "text-to-image" | "text-to-speech" | "text-to-video" | "token-classification" | "translation" | "unconditional-image-generation" | "visual-question-answering" | "zero-shot-classification" | "zero-shot-image-classification"
Defined in
ObjectDetectionArgs
Ƭ ObjectDetectionArgs: BaseArgs & { data: Blob | ArrayBuffer }
Defined in
inference/src/tasks/cv/objectDetection.ts:5
ObjectDetectionOutput
Ƭ ObjectDetectionOutput: ObjectDetectionOutputValue[]
Defined in
inference/src/tasks/cv/objectDetection.ts:33
QuestionAnsweringArgs
Ƭ QuestionAnsweringArgs: BaseArgs & { inputs: { context: string ; question: string } }
Defined in
inference/src/tasks/nlp/questionAnswering.ts:5
RequestArgs
Ƭ RequestArgs: BaseArgs & { data: Blob | ArrayBuffer } | { inputs: unknown } & { accessToken?: string ; parameters?: Record<string, unknown> }
Defined in
SentenceSimilarityArgs
Ƭ SentenceSimilarityArgs: BaseArgs & { inputs: Record<string, unknown> | Record<string, unknown>[] }
Defined in
inference/src/tasks/nlp/sentenceSimilarity.ts:6
SentenceSimilarityOutput
Ƭ SentenceSimilarityOutput: number[]
Returned values are a list of floats
Defined in
inference/src/tasks/nlp/sentenceSimilarity.ts:19
SummarizationArgs
Ƭ SummarizationArgs: BaseArgs & { inputs: string ; parameters?: { max_length?: number ; max_time?: number ; min_length?: number ; repetition_penalty?: number ; temperature?: number ; top_k?: number ; top_p?: number } }
Defined in
inference/src/tasks/nlp/summarization.ts:5
TableQuestionAnsweringArgs
Ƭ TableQuestionAnsweringArgs: BaseArgs & { inputs: { query: string ; table: Record<string, string[]> } }
Defined in
inference/src/tasks/nlp/tableQuestionAnswering.ts:5
TabularClassificationArgs
Ƭ TabularClassificationArgs: BaseArgs & { inputs: { data: Record<string, string[]> } }
Defined in
inference/src/tasks/tabular/tabularClassification.ts:5
TabularClassificationOutput
Ƭ TabularClassificationOutput: number[]
A list of predicted labels for each row
Defined in
inference/src/tasks/tabular/tabularClassification.ts:17
TabularRegressionArgs
Ƭ TabularRegressionArgs: BaseArgs & { inputs: { data: Record<string, string[]> } }
Defined in
inference/src/tasks/tabular/tabularRegression.ts:5
TabularRegressionOutput
Ƭ TabularRegressionOutput: number[]
a list of predicted values for each row
Defined in
inference/src/tasks/tabular/tabularRegression.ts:17
TextClassificationArgs
Ƭ TextClassificationArgs: BaseArgs & { inputs: string }
Defined in
inference/src/tasks/nlp/textClassification.ts:5
TextClassificationOutput
Ƭ TextClassificationOutput: { label: string ; score: number }[]
Defined in
inference/src/tasks/nlp/textClassification.ts:12
TextGenerationArgs
Ƭ TextGenerationArgs: BaseArgs & { inputs: string ; parameters?: { do_sample?: boolean ; max_new_tokens?: number ; max_time?: number ; num_return_sequences?: number ; repetition_penalty?: number ; return_full_text?: boolean ; temperature?: number ; top_k?: number ; top_p?: number ; truncate?: number } }
Defined in
inference/src/tasks/nlp/textGeneration.ts:5
TextGenerationStreamFinishReason
Ƭ TextGenerationStreamFinishReason: "length" | "eos_token" | "stop_sequence"
Defined in
inference/src/tasks/nlp/textGenerationStream.ts:46
TextToImageArgs
Ƭ TextToImageArgs: BaseArgs & { inputs: string ; parameters?: { guidance_scale?: number ; height?: number ; negative_prompt?: string ; num_inference_steps?: number ; width?: number } }
Defined in
inference/src/tasks/cv/textToImage.ts:5
TextToImageOutput
Ƭ TextToImageOutput: Blob
Defined in
inference/src/tasks/cv/textToImage.ts:35
TextToSpeechArgs
Ƭ TextToSpeechArgs: BaseArgs & { inputs: string }
Defined in
inference/src/tasks/audio/textToSpeech.ts:5
TextToSpeechOutput
Ƭ TextToSpeechOutput: Blob
Defined in
inference/src/tasks/audio/textToSpeech.ts:12
TokenClassificationArgs
Ƭ TokenClassificationArgs: BaseArgs & { inputs: string ; parameters?: { aggregation_strategy?: "none" | "simple" | "first" | "average" | "max" } }
Defined in
inference/src/tasks/nlp/tokenClassification.ts:6
TokenClassificationOutput
Ƭ TokenClassificationOutput: TokenClassificationOutputValue[]
Defined in
inference/src/tasks/nlp/tokenClassification.ts:52
TranslationArgs
Ƭ TranslationArgs: BaseArgs & { inputs: string }
Defined in
inference/src/tasks/nlp/translation.ts:5
VisualQuestionAnsweringArgs
Ƭ VisualQuestionAnsweringArgs: BaseArgs & { inputs: { image: Blob | ArrayBuffer ; question: string } }
Defined in
inference/src/tasks/multimodal/visualQuestionAnswering.ts:6
ZeroShotClassificationArgs
Ƭ ZeroShotClassificationArgs: BaseArgs & { inputs: string | string[] ; parameters: { candidate_labels: string[] ; multi_label?: boolean } }
Defined in
inference/src/tasks/nlp/zeroShotClassification.ts:6
ZeroShotClassificationOutput
Ƭ ZeroShotClassificationOutput: ZeroShotClassificationOutputValue[]
Defined in
inference/src/tasks/nlp/zeroShotClassification.ts:29
ZeroShotImageClassificationArgs
Ƭ ZeroShotImageClassificationArgs: BaseArgs & { inputs: { image: Blob | ArrayBuffer } ; parameters: { candidate_labels: string[] } }
Defined in
inference/src/tasks/cv/zeroShotImageClassification.ts:7
ZeroShotImageClassificationOutput
Ƭ ZeroShotImageClassificationOutput: ZeroShotImageClassificationOutputValue[]
Defined in
inference/src/tasks/cv/zeroShotImageClassification.ts:27
Functions
audioClassification
▸ audioClassification(args, options?): Promise<AudioClassificationReturn>
This task reads some audio input and outputs the likelihood of classes. Recommended model: superb/hubert-large-superb-er
Parameters
| Name | Type |
|---|---|
args |
AudioClassificationArgs |
options? |
Options |
Returns
Promise<AudioClassificationReturn>
Defined in
inference/src/tasks/audio/audioClassification.ts:30
audioToAudio
▸ audioToAudio(args, options?): Promise<AudioToAudioReturn>
This task reads some audio input and outputs one or multiple audio files. Example model: speechbrain/sepformer-wham does audio source separation.
Parameters
| Name | Type |
|---|---|
args |
AudioToAudioArgs |
options? |
Options |
Returns
Promise<AudioToAudioReturn>
Defined in
inference/src/tasks/audio/audioToAudio.ts:35
automaticSpeechRecognition
▸ automaticSpeechRecognition(args, options?): Promise<AutomaticSpeechRecognitionOutput>
This task reads some audio input and outputs the said words within the audio files. Recommended model (english language): facebook/wav2vec2-large-960h-lv60-self
Parameters
| Name | Type |
|---|---|
args |
AutomaticSpeechRecognitionArgs |
options? |
Options |
Returns
Promise<AutomaticSpeechRecognitionOutput>
Defined in
inference/src/tasks/audio/automaticSpeechRecognition.ts:23
conversational
▸ conversational(args, options?): Promise<ConversationalOutput>
This task corresponds to any chatbot like structure. Models tend to have shorter max_length, so please check with caution when using a given model if you need long range dependency or not. Recommended model: microsoft/DialoGPT-large.
Parameters
| Name | Type |
|---|---|
args |
ConversationalArgs |
options? |
Options |
Returns
Promise<ConversationalOutput>
Defined in
inference/src/tasks/nlp/conversational.ts:65
documentQuestionAnswering
▸ documentQuestionAnswering(args, options?): Promise<DocumentQuestionAnsweringOutput>
Answers a question on a document image. Recommended model: impira/layoutlm-document-qa.
Parameters
| Name | Type |
|---|---|
args |
DocumentQuestionAnsweringArgs |
options? |
Options |
Returns
Promise<DocumentQuestionAnsweringOutput>
Defined in
inference/src/tasks/multimodal/documentQuestionAnswering.ts:42
featureExtraction
▸ featureExtraction(args, options?): Promise<FeatureExtractionOutput>
This task reads some text and outputs raw float values, that are usually consumed as part of a semantic database/semantic search.
Parameters
| Name | Type |
|---|---|
args |
FeatureExtractionArgs |
options? |
Options |
Returns
Promise<FeatureExtractionOutput>
Defined in
inference/src/tasks/nlp/featureExtraction.ts:24
fillMask
▸ fillMask(args, options?): Promise<FillMaskOutput>
Tries to fill in a hole with a missing word (token to be precise). That’s the base task for BERT models.
Parameters
| Name | Type |
|---|---|
args |
FillMaskArgs |
options? |
Options |
Returns
Promise<FillMaskOutput>
Defined in
inference/src/tasks/nlp/fillMask.ts:31
imageClassification
▸ imageClassification(args, options?): Promise<ImageClassificationOutput>
This task reads some image input and outputs the likelihood of classes. Recommended model: google/vit-base-patch16-224
Parameters
| Name | Type |
|---|---|
args |
ImageClassificationArgs |
options? |
Options |
Returns
Promise<ImageClassificationOutput>
Defined in
inference/src/tasks/cv/imageClassification.ts:29
imageSegmentation
▸ imageSegmentation(args, options?): Promise<ImageSegmentationOutput>
This task reads some image input and outputs the likelihood of classes & bounding boxes of detected objects. Recommended model: facebook/detr-resnet-50-panoptic
Parameters
| Name | Type |
|---|---|
args |
ImageSegmentationArgs |
options? |
Options |
Returns
Promise<ImageSegmentationOutput>
Defined in
inference/src/tasks/cv/imageSegmentation.ts:33
imageToImage
▸ imageToImage(args, options?): Promise<ImageToImageOutput>
This task reads some text input and outputs an image. Recommended model: lllyasviel/sd-controlnet-depth
Parameters
| Name | Type |
|---|---|
args |
ImageToImageArgs |
options? |
Options |
Returns
Promise<ImageToImageOutput>
Defined in
inference/src/tasks/cv/imageToImage.ts:61
imageToText
▸ imageToText(args, options?): Promise<ImageToTextOutput>
This task reads some image input and outputs the text caption.
Parameters
| Name | Type |
|---|---|
args |
ImageToTextArgs |
options? |
Options |
Returns
Promise<ImageToTextOutput>
Defined in
inference/src/tasks/cv/imageToText.ts:22
objectDetection
▸ objectDetection(args, options?): Promise<ObjectDetectionOutput>
This task reads some image input and outputs the likelihood of classes & bounding boxes of detected objects. Recommended model: facebook/detr-resnet-50
Parameters
| Name | Type |
|---|---|
args |
ObjectDetectionArgs |
options? |
Options |
Returns
Promise<ObjectDetectionOutput>
Defined in
inference/src/tasks/cv/objectDetection.ts:39
questionAnswering
▸ questionAnswering(args, options?): Promise<QuestionAnsweringOutput>
Want to have a nice know-it-all bot that can answer any question?. Recommended model: deepset/roberta-base-squad2
Parameters
| Name | Type |
|---|---|
args |
QuestionAnsweringArgs |
options? |
Options |
Returns
Promise<QuestionAnsweringOutput>
Defined in
inference/src/tasks/nlp/questionAnswering.ts:34
request
▸ request<T>(args, options?): Promise<T>
Primitive to make custom calls to the inference API
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type |
|---|---|
args |
RequestArgs |
options? |
Options & { includeCredentials?: boolean ; task?: string ; taskHint?: InferenceTask } |
Returns
Promise<T>
Defined in
inference/src/tasks/custom/request.ts:7
sentenceSimilarity
▸ sentenceSimilarity(args, options?): Promise<SentenceSimilarityOutput>
Calculate the semantic similarity between one text and a list of other sentences by comparing their embeddings.
Parameters
| Name | Type |
|---|---|
args |
SentenceSimilarityArgs |
options? |
Options |
Returns
Promise<SentenceSimilarityOutput>
Defined in
inference/src/tasks/nlp/sentenceSimilarity.ts:24
streamingRequest
▸ streamingRequest<T>(args, options?): AsyncGenerator<T>
Primitive to make custom inference calls that expect server-sent events, and returns the response through a generator
Type parameters
| Name |
|---|
T |
Parameters
| Name | Type |
|---|---|
args |
RequestArgs |
options? |
Options & { includeCredentials?: boolean ; task?: string ; taskHint?: InferenceTask } |
Returns
AsyncGenerator<T>
Defined in
inference/src/tasks/custom/streamingRequest.ts:9
summarization
▸ summarization(args, options?): Promise<SummarizationOutput>
This task is well known to summarize longer text into shorter text. Be careful, some models have a maximum length of input. That means that the summary cannot handle full books for instance. Be careful when choosing your model.
Parameters
| Name | Type |
|---|---|
args |
SummarizationArgs |
options? |
Options |
Returns
Promise<SummarizationOutput>
Defined in
inference/src/tasks/nlp/summarization.ts:52
tableQuestionAnswering
▸ tableQuestionAnswering(args, options?): Promise<TableQuestionAnsweringOutput>
Don’t know SQL? Don’t want to dive into a large spreadsheet? Ask questions in plain english! Recommended model: google/tapas-base-finetuned-wtq.
Parameters
| Name | Type |
|---|---|
args |
TableQuestionAnsweringArgs |
options? |
Options |
Returns
Promise<TableQuestionAnsweringOutput>
Defined in
inference/src/tasks/nlp/tableQuestionAnswering.ts:40
tabularClassification
▸ tabularClassification(args, options?): Promise<TabularClassificationOutput>
Predicts target label for a given set of features in tabular form. Typically, you will want to train a classification model on your training data and use it with your new data of the same format. Example model: vvmnnnkv/wine-quality
Parameters
| Name | Type |
|---|---|
args |
TabularClassificationArgs |
options? |
Options |
Returns
Promise<TabularClassificationOutput>
Defined in
inference/src/tasks/tabular/tabularClassification.ts:24
tabularRegression
▸ tabularRegression(args, options?): Promise<TabularRegressionOutput>
Predicts target value for a given set of features in tabular form. Typically, you will want to train a regression model on your training data and use it with your new data of the same format. Example model: scikit-learn/Fish-Weight
Parameters
| Name | Type |
|---|---|
args |
TabularRegressionArgs |
options? |
Options |
Returns
Promise<TabularRegressionOutput>
Defined in
inference/src/tasks/tabular/tabularRegression.ts:24
textClassification
▸ textClassification(args, options?): Promise<TextClassificationOutput>
Usually used for sentiment-analysis this will output the likelihood of classes of an input. Recommended model: distilbert-base-uncased-finetuned-sst-2-english
Parameters
| Name | Type |
|---|---|
args |
TextClassificationArgs |
options? |
Options |
Returns
Promise<TextClassificationOutput>
Defined in
inference/src/tasks/nlp/textClassification.ts:26
textGeneration
▸ textGeneration(args, options?): Promise<TextGenerationOutput>
Use to continue text from a prompt. This is a very generic task. Recommended model: gpt2 (it’s a simple model, but fun to play with).
Parameters
| Name | Type |
|---|---|
args |
TextGenerationArgs |
options? |
Options |
Returns
Promise<TextGenerationOutput>
Defined in
inference/src/tasks/nlp/textGeneration.ts:64
textGenerationStream
▸ textGenerationStream(args, options?): AsyncGenerator<TextGenerationStreamOutput>
Use to continue text from a prompt. Same as textGeneration but returns generator that can be read one token at a time
Parameters
| Name | Type |
|---|---|
args |
TextGenerationArgs |
options? |
Options |
Returns
AsyncGenerator<TextGenerationStreamOutput>
Defined in
inference/src/tasks/nlp/textGenerationStream.ts:87
textToImage
▸ textToImage(args, options?): Promise<TextToImageOutput>
This task reads some text input and outputs an image. Recommended model: stabilityai/stable-diffusion-2
Parameters
| Name | Type |
|---|---|
args |
TextToImageArgs |
options? |
Options |
Returns
Promise<TextToImageOutput>
Defined in
inference/src/tasks/cv/textToImage.ts:41
textToSpeech
▸ textToSpeech(args, options?): Promise<TextToSpeechOutput>
This task synthesize an audio of a voice pronouncing a given text. Recommended model: espnet/kan-bayashi_ljspeech_vits
Parameters
| Name | Type |
|---|---|
args |
TextToSpeechArgs |
options? |
Options |
Returns
Promise<TextToSpeechOutput>
Defined in
inference/src/tasks/audio/textToSpeech.ts:18
tokenClassification
▸ tokenClassification(args, options?): Promise<TokenClassificationOutput>
Usually used for sentence parsing, either grammatical, or Named Entity Recognition (NER) to understand keywords contained within text. Recommended model: dbmdz/bert-large-cased-finetuned-conll03-english
Parameters
| Name | Type |
|---|---|
args |
TokenClassificationArgs |
options? |
Options |
Returns
Promise<TokenClassificationOutput>
Defined in
inference/src/tasks/nlp/tokenClassification.ts:57
translation
▸ translation(args, options?): Promise<TranslationOutput>
This task is well known to translate text from one language to another. Recommended model: Helsinki-NLP/opus-mt-ru-en.
Parameters
| Name | Type |
|---|---|
args |
TranslationArgs |
options? |
Options |
Returns
Promise<TranslationOutput>
Defined in
inference/src/tasks/nlp/translation.ts:22
visualQuestionAnswering
▸ visualQuestionAnswering(args, options?): Promise<VisualQuestionAnsweringOutput>
Answers a question on an image. Recommended model: dandelin/vilt-b32-finetuned-vqa.
Parameters
| Name | Type |
|---|---|
args |
VisualQuestionAnsweringArgs |
options? |
Options |
Returns
Promise<VisualQuestionAnsweringOutput>
Defined in
inference/src/tasks/multimodal/visualQuestionAnswering.ts:32
zeroShotClassification
▸ zeroShotClassification(args, options?): Promise<ZeroShotClassificationOutput>
This task is super useful to try out classification with zero code, you simply pass a sentence/paragraph and the possible labels for that sentence, and you get a result. Recommended model: facebook/bart-large-mnli.
Parameters
| Name | Type |
|---|---|
args |
ZeroShotClassificationArgs |
options? |
Options |
Returns
Promise<ZeroShotClassificationOutput>
Defined in
inference/src/tasks/nlp/zeroShotClassification.ts:34
zeroShotImageClassification
▸ zeroShotImageClassification(args, options?): Promise<ZeroShotImageClassificationOutput>
Classify an image to specified classes. Recommended model: openai/clip-vit-large-patch14-336
Parameters
| Name | Type |
|---|---|
args |
ZeroShotImageClassificationArgs |
options? |
Options |
Returns
Promise<ZeroShotImageClassificationOutput>