@huggingface/tasks 0.6.1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +23 -4
- package/dist/index.d.ts +50 -7
- package/dist/index.js +22 -3
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/library-to-tasks.ts +24 -5
- package/src/tasks/index.ts +3 -1
- package/src/tokenizer-data.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23,7 +23,7 @@ __export(src_exports, {
|
|
|
23
23
|
ALL_DISPLAY_MODEL_LIBRARY_KEYS: () => ALL_DISPLAY_MODEL_LIBRARY_KEYS,
|
|
24
24
|
ALL_MODEL_LIBRARY_KEYS: () => ALL_MODEL_LIBRARY_KEYS,
|
|
25
25
|
InferenceDisplayability: () => InferenceDisplayability,
|
|
26
|
-
|
|
26
|
+
LIBRARY_TASK_MAPPING: () => LIBRARY_TASK_MAPPING,
|
|
27
27
|
MAPPING_DEFAULT_WIDGET: () => MAPPING_DEFAULT_WIDGET,
|
|
28
28
|
MODALITIES: () => MODALITIES,
|
|
29
29
|
MODALITY_LABELS: () => MODALITY_LABELS,
|
|
@@ -40,7 +40,7 @@ __export(src_exports, {
|
|
|
40
40
|
module.exports = __toCommonJS(src_exports);
|
|
41
41
|
|
|
42
42
|
// src/library-to-tasks.ts
|
|
43
|
-
var
|
|
43
|
+
var LIBRARY_TASK_MAPPING = {
|
|
44
44
|
"adapter-transformers": ["question-answering", "text-classification", "token-classification"],
|
|
45
45
|
allennlp: ["question-answering"],
|
|
46
46
|
asteroid: [
|
|
@@ -76,6 +76,25 @@ var LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS = {
|
|
|
76
76
|
],
|
|
77
77
|
stanza: ["token-classification"],
|
|
78
78
|
timm: ["image-classification"],
|
|
79
|
+
transformers: [
|
|
80
|
+
"audio-classification",
|
|
81
|
+
"automatic-speech-recognition",
|
|
82
|
+
"depth-estimation",
|
|
83
|
+
"document-question-answering",
|
|
84
|
+
"feature-extraction",
|
|
85
|
+
"fill-mask",
|
|
86
|
+
"image-classification",
|
|
87
|
+
"image-segmentation",
|
|
88
|
+
"image-to-text",
|
|
89
|
+
"image-to-image",
|
|
90
|
+
"object-detection",
|
|
91
|
+
"question-answering",
|
|
92
|
+
"text-generation",
|
|
93
|
+
"text2text-generation",
|
|
94
|
+
"visual-question-answering",
|
|
95
|
+
"zero-shot-classification",
|
|
96
|
+
"zero-shot-image-classification"
|
|
97
|
+
],
|
|
79
98
|
mindspore: ["image-classification"]
|
|
80
99
|
};
|
|
81
100
|
|
|
@@ -3847,7 +3866,7 @@ var data_default34 = taskData34;
|
|
|
3847
3866
|
// src/tasks/index.ts
|
|
3848
3867
|
var TASKS_MODEL_LIBRARIES = {
|
|
3849
3868
|
"audio-classification": ["speechbrain", "transformers", "transformers.js"],
|
|
3850
|
-
"audio-to-audio": ["asteroid", "speechbrain"],
|
|
3869
|
+
"audio-to-audio": ["asteroid", "fairseq", "speechbrain"],
|
|
3851
3870
|
"automatic-speech-recognition": ["espnet", "nemo", "speechbrain", "transformers", "transformers.js"],
|
|
3852
3871
|
"depth-estimation": ["transformers", "transformers.js"],
|
|
3853
3872
|
"document-question-answering": ["transformers", "transformers.js"],
|
|
@@ -5324,7 +5343,7 @@ function hasJsInferenceSnippet(model) {
|
|
|
5324
5343
|
ALL_DISPLAY_MODEL_LIBRARY_KEYS,
|
|
5325
5344
|
ALL_MODEL_LIBRARY_KEYS,
|
|
5326
5345
|
InferenceDisplayability,
|
|
5327
|
-
|
|
5346
|
+
LIBRARY_TASK_MAPPING,
|
|
5328
5347
|
MAPPING_DEFAULT_WIDGET,
|
|
5329
5348
|
MODALITIES,
|
|
5330
5349
|
MODALITY_LABELS,
|
package/dist/index.d.ts
CHANGED
|
@@ -507,7 +507,10 @@ type SpecialTokensMap = {
|
|
|
507
507
|
*/
|
|
508
508
|
interface TokenizerConfig extends SpecialTokensMap {
|
|
509
509
|
use_default_system_prompt?: boolean;
|
|
510
|
-
chat_template?: string
|
|
510
|
+
chat_template?: string | Array<{
|
|
511
|
+
name: string;
|
|
512
|
+
template: string;
|
|
513
|
+
}>;
|
|
511
514
|
}
|
|
512
515
|
|
|
513
516
|
declare enum InferenceDisplayability {
|
|
@@ -1145,13 +1148,13 @@ declare const ALL_MODEL_LIBRARY_KEYS: ("sklearn" | "adapter-transformers" | "all
|
|
|
1145
1148
|
declare const ALL_DISPLAY_MODEL_LIBRARY_KEYS: ("sklearn" | "adapter-transformers" | "allennlp" | "asteroid" | "audiocraft" | "bertopic" | "diffusers" | "doctr" | "espnet" | "fairseq" | "fastai" | "fasttext" | "flair" | "gliner" | "grok" | "keras" | "k2" | "mindspore" | "ml-agents" | "mlx" | "mlx-image" | "nemo" | "open_clip" | "paddlenlp" | "peft" | "pyannote-audio" | "pythae" | "sample-factory" | "sentence-transformers" | "setfit" | "spacy" | "span-marker" | "speechbrain" | "stable-baselines3" | "stanza" | "tensorflowtts" | "timm" | "transformers" | "transformers.js" | "unity-sentis" | "whisperkit")[];
|
|
1146
1149
|
|
|
1147
1150
|
/**
|
|
1148
|
-
* Mapping from library name
|
|
1151
|
+
* Mapping from library name to its supported tasks.
|
|
1149
1152
|
* Inference API (serverless) should be disabled for all other (library, task) pairs beyond this mapping.
|
|
1150
|
-
*
|
|
1151
|
-
*
|
|
1152
|
-
*
|
|
1153
|
+
* This mapping is partially generated automatically by "python-api-export-tasks" action in
|
|
1154
|
+
* huggingface/api-inference-community repo upon merge. For transformers, the mapping is manually
|
|
1155
|
+
* based on api-inference.
|
|
1153
1156
|
*/
|
|
1154
|
-
declare const
|
|
1157
|
+
declare const LIBRARY_TASK_MAPPING: Partial<Record<ModelLibraryKey, PipelineType[]>>;
|
|
1155
1158
|
|
|
1156
1159
|
type PerLanguageMapping = Map<WidgetType, string[] | WidgetExample[]>;
|
|
1157
1160
|
declare const MAPPING_DEFAULT_WIDGET: Map<string, PerLanguageMapping>;
|
|
@@ -2977,6 +2980,46 @@ interface TextGenerationOutputToken {
|
|
|
2977
2980
|
text: string;
|
|
2978
2981
|
[property: string]: unknown;
|
|
2979
2982
|
}
|
|
2983
|
+
/**
|
|
2984
|
+
* Text Generation Stream Output
|
|
2985
|
+
*/
|
|
2986
|
+
interface TextGenerationStreamOutput {
|
|
2987
|
+
/**
|
|
2988
|
+
* Generation details. Only available when the generation is finished.
|
|
2989
|
+
*/
|
|
2990
|
+
details?: TextGenerationStreamDetails;
|
|
2991
|
+
/**
|
|
2992
|
+
* The complete generated text. Only available when the generation is finished.
|
|
2993
|
+
*/
|
|
2994
|
+
generated_text?: string;
|
|
2995
|
+
/**
|
|
2996
|
+
* The token index within the stream. Optional to support older clients that omit it.
|
|
2997
|
+
*/
|
|
2998
|
+
index?: number;
|
|
2999
|
+
/**
|
|
3000
|
+
* Generated token.
|
|
3001
|
+
*/
|
|
3002
|
+
token: TextGenerationOutputToken;
|
|
3003
|
+
[property: string]: unknown;
|
|
3004
|
+
}
|
|
3005
|
+
/**
|
|
3006
|
+
* Generation details. Only available when the generation is finished.
|
|
3007
|
+
*/
|
|
3008
|
+
interface TextGenerationStreamDetails {
|
|
3009
|
+
/**
|
|
3010
|
+
* The reason why the generation was stopped.
|
|
3011
|
+
*/
|
|
3012
|
+
finish_reason: TextGenerationFinishReason;
|
|
3013
|
+
/**
|
|
3014
|
+
* The number of generated tokens
|
|
3015
|
+
*/
|
|
3016
|
+
generated_tokens: number;
|
|
3017
|
+
/**
|
|
3018
|
+
* The random seed used for generation
|
|
3019
|
+
*/
|
|
3020
|
+
seed: number;
|
|
3021
|
+
[property: string]: unknown;
|
|
3022
|
+
}
|
|
2980
3023
|
|
|
2981
3024
|
/**
|
|
2982
3025
|
* Inference code generated from the JSON schema spec in ./spec
|
|
@@ -3471,4 +3514,4 @@ declare namespace index {
|
|
|
3471
3514
|
};
|
|
3472
3515
|
}
|
|
3473
3516
|
|
|
3474
|
-
export { ALL_DISPLAY_MODEL_LIBRARY_KEYS, ALL_MODEL_LIBRARY_KEYS, AddedToken, AudioClassificationInput, AudioClassificationOutput, AudioClassificationOutputElement, AudioClassificationParameters, AutomaticSpeechRecognitionInput, AutomaticSpeechRecognitionOutput, AutomaticSpeechRecognitionOutputChunk, AutomaticSpeechRecognitionParameters, BoundingBox, ChatCompletionFinishReason, ChatCompletionInput, ChatCompletionInputMessage, ChatCompletionOutput, ChatCompletionOutputChoice, ChatCompletionOutputChoiceMessage, ChatCompletionStreamOutput, ChatCompletionStreamOutputChoice, ChatCompletionStreamOutputDelta, ChatMessage, ClassificationOutputTransform$1 as ClassificationOutputTransform, DepthEstimationInput, DepthEstimationOutput, DocumentQuestionAnsweringInput, DocumentQuestionAnsweringInputData, DocumentQuestionAnsweringOutput, DocumentQuestionAnsweringOutputElement, DocumentQuestionAnsweringParameters, EarlyStoppingUnion$2 as EarlyStoppingUnion, ExampleRepo, FeatureExtractionInput, FeatureExtractionOutput, FillMaskInput, FillMaskOutput, FillMaskOutputElement, FillMaskParameters, GenerationParameters$2 as GenerationParameters, ImageClassificationInput, ImageClassificationOutput, ImageClassificationOutputElement, ImageClassificationParameters, ImageSegmentationInput, ImageSegmentationOutput, ImageSegmentationOutputElement, ImageSegmentationParameters, ImageSegmentationSubtask, ImageToImageInput, ImageToImageOutput, ImageToImageParameters, ImageToTextInput, ImageToTextOutput, ImageToTextParameters, InferenceDisplayability,
|
|
3517
|
+
export { ALL_DISPLAY_MODEL_LIBRARY_KEYS, ALL_MODEL_LIBRARY_KEYS, AddedToken, AudioClassificationInput, AudioClassificationOutput, AudioClassificationOutputElement, AudioClassificationParameters, AutomaticSpeechRecognitionInput, AutomaticSpeechRecognitionOutput, AutomaticSpeechRecognitionOutputChunk, AutomaticSpeechRecognitionParameters, BoundingBox, ChatCompletionFinishReason, ChatCompletionInput, ChatCompletionInputMessage, ChatCompletionOutput, ChatCompletionOutputChoice, ChatCompletionOutputChoiceMessage, ChatCompletionStreamOutput, ChatCompletionStreamOutputChoice, ChatCompletionStreamOutputDelta, ChatMessage, ClassificationOutputTransform$1 as ClassificationOutputTransform, DepthEstimationInput, DepthEstimationOutput, DocumentQuestionAnsweringInput, DocumentQuestionAnsweringInputData, DocumentQuestionAnsweringOutput, DocumentQuestionAnsweringOutputElement, DocumentQuestionAnsweringParameters, EarlyStoppingUnion$2 as EarlyStoppingUnion, ExampleRepo, FeatureExtractionInput, FeatureExtractionOutput, FillMaskInput, FillMaskOutput, FillMaskOutputElement, FillMaskParameters, GenerationParameters$2 as GenerationParameters, ImageClassificationInput, ImageClassificationOutput, ImageClassificationOutputElement, ImageClassificationParameters, ImageSegmentationInput, ImageSegmentationOutput, ImageSegmentationOutputElement, ImageSegmentationParameters, ImageSegmentationSubtask, ImageToImageInput, ImageToImageOutput, ImageToImageParameters, ImageToTextInput, ImageToTextOutput, ImageToTextParameters, InferenceDisplayability, LIBRARY_TASK_MAPPING, LibraryUiElement, MAPPING_DEFAULT_WIDGET, MODALITIES, MODALITY_LABELS, MODEL_LIBRARIES_UI_ELEMENTS, Modality, ModelData, ModelLibraryKey, ObjectDetectionInput, ObjectDetectionOutput, ObjectDetectionOutputElement, ObjectDetectionParameters, PIPELINE_DATA, PIPELINE_TYPES, PIPELINE_TYPES_SET, PipelineData, PipelineType, QuestionAnsweringInput, QuestionAnsweringInputData, QuestionAnsweringOutput, QuestionAnsweringOutputElement, QuestionAnsweringParameters, SPECIAL_TOKENS_ATTRIBUTES, SUBTASK_TYPES, SentenceSimilarityInput, SentenceSimilarityInputData, SentenceSimilarityOutput, SpecialTokensMap, SummarizationInput, SummarizationOutput, TASKS_DATA, TASKS_MODEL_LIBRARIES, TableQuestionAnsweringInput, TableQuestionAnsweringInputData, TableQuestionAnsweringOutput, TableQuestionAnsweringOutputElement, TargetSize$1 as TargetSize, TaskData, TaskDataCustom, TaskDemo, TaskDemoEntry, Text2TextGenerationParameters, Text2TextGenerationTruncationStrategy, TextClassificationInput, TextClassificationOutput, TextClassificationOutputElement, TextClassificationParameters, TextGenerationFinishReason, TextGenerationInput, TextGenerationOutput, TextGenerationOutputDetails, TextGenerationOutputSequenceDetails, TextGenerationOutputToken, TextGenerationParameters, TextGenerationPrefillToken, TextGenerationStreamDetails, TextGenerationStreamOutput, TextToAudioParameters, TextToImageInput, TextToImageOutput, TextToImageParameters, TextToSpeechInput, TextToSpeechOutput, TokenClassificationAggregationStrategy, TokenClassificationInput, TokenClassificationOutput, TokenClassificationOutputElement, TokenClassificationParameters, TokenizerConfig, TransformersInfo, TranslationInput, TranslationOutput, VideoClassificationInput, VideoClassificationOutput, VideoClassificationOutputElement, VideoClassificationParameters, VisualQuestionAnsweringInput, VisualQuestionAnsweringInputData, VisualQuestionAnsweringOutput, VisualQuestionAnsweringOutputElement, VisualQuestionAnsweringParameters, WidgetExample, WidgetExampleAssetAndPromptInput, WidgetExampleAssetAndTextInput, WidgetExampleAssetAndZeroShotInput, WidgetExampleAssetInput, WidgetExampleAttribute, WidgetExampleChatInput, WidgetExampleOutput, WidgetExampleOutputAnswerScore, WidgetExampleOutputLabels, WidgetExampleOutputText, WidgetExampleOutputUrl, WidgetExampleSentenceSimilarityInput, WidgetExampleStructuredDataInput, WidgetExampleTableDataInput, WidgetExampleTextAndContextInput, WidgetExampleTextAndTableInput, WidgetExampleTextInput, WidgetExampleZeroShotTextInput, WidgetType, WordBox, ZeroShotClassificationInput, ZeroShotClassificationInputData, ZeroShotClassificationOutput, ZeroShotClassificationOutputElement, ZeroShotClassificationParameters, ZeroShotImageClassificationInput, ZeroShotImageClassificationInputData, ZeroShotImageClassificationOutput, ZeroShotImageClassificationOutputElement, ZeroShotImageClassificationParameters, ZeroShotObjectDetectionInput, ZeroShotObjectDetectionInputData, ZeroShotObjectDetectionOutput, ZeroShotObjectDetectionOutputElement, index as snippets };
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/library-to-tasks.ts
|
|
8
|
-
var
|
|
8
|
+
var LIBRARY_TASK_MAPPING = {
|
|
9
9
|
"adapter-transformers": ["question-answering", "text-classification", "token-classification"],
|
|
10
10
|
allennlp: ["question-answering"],
|
|
11
11
|
asteroid: [
|
|
@@ -41,6 +41,25 @@ var LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS = {
|
|
|
41
41
|
],
|
|
42
42
|
stanza: ["token-classification"],
|
|
43
43
|
timm: ["image-classification"],
|
|
44
|
+
transformers: [
|
|
45
|
+
"audio-classification",
|
|
46
|
+
"automatic-speech-recognition",
|
|
47
|
+
"depth-estimation",
|
|
48
|
+
"document-question-answering",
|
|
49
|
+
"feature-extraction",
|
|
50
|
+
"fill-mask",
|
|
51
|
+
"image-classification",
|
|
52
|
+
"image-segmentation",
|
|
53
|
+
"image-to-text",
|
|
54
|
+
"image-to-image",
|
|
55
|
+
"object-detection",
|
|
56
|
+
"question-answering",
|
|
57
|
+
"text-generation",
|
|
58
|
+
"text2text-generation",
|
|
59
|
+
"visual-question-answering",
|
|
60
|
+
"zero-shot-classification",
|
|
61
|
+
"zero-shot-image-classification"
|
|
62
|
+
],
|
|
44
63
|
mindspore: ["image-classification"]
|
|
45
64
|
};
|
|
46
65
|
|
|
@@ -3812,7 +3831,7 @@ var data_default34 = taskData34;
|
|
|
3812
3831
|
// src/tasks/index.ts
|
|
3813
3832
|
var TASKS_MODEL_LIBRARIES = {
|
|
3814
3833
|
"audio-classification": ["speechbrain", "transformers", "transformers.js"],
|
|
3815
|
-
"audio-to-audio": ["asteroid", "speechbrain"],
|
|
3834
|
+
"audio-to-audio": ["asteroid", "fairseq", "speechbrain"],
|
|
3816
3835
|
"automatic-speech-recognition": ["espnet", "nemo", "speechbrain", "transformers", "transformers.js"],
|
|
3817
3836
|
"depth-estimation": ["transformers", "transformers.js"],
|
|
3818
3837
|
"document-question-answering": ["transformers", "transformers.js"],
|
|
@@ -5288,7 +5307,7 @@ export {
|
|
|
5288
5307
|
ALL_DISPLAY_MODEL_LIBRARY_KEYS,
|
|
5289
5308
|
ALL_MODEL_LIBRARY_KEYS,
|
|
5290
5309
|
InferenceDisplayability,
|
|
5291
|
-
|
|
5310
|
+
LIBRARY_TASK_MAPPING,
|
|
5292
5311
|
MAPPING_DEFAULT_WIDGET,
|
|
5293
5312
|
MODALITIES,
|
|
5294
5313
|
MODALITY_LABELS,
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { LIBRARY_TASK_MAPPING } from "./library-to-tasks";
|
|
2
2
|
export { MAPPING_DEFAULT_WIDGET } from "./default-widget-inputs";
|
|
3
3
|
export type { TaskData, TaskDemo, TaskDemoEntry, ExampleRepo } from "./tasks";
|
|
4
4
|
export * from "./tasks";
|
package/src/library-to-tasks.ts
CHANGED
|
@@ -2,13 +2,13 @@ import type { ModelLibraryKey } from "./model-libraries";
|
|
|
2
2
|
import type { PipelineType } from "./pipelines";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* Mapping from library name
|
|
5
|
+
* Mapping from library name to its supported tasks.
|
|
6
6
|
* Inference API (serverless) should be disabled for all other (library, task) pairs beyond this mapping.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* This mapping is partially generated automatically by "python-api-export-tasks" action in
|
|
8
|
+
* huggingface/api-inference-community repo upon merge. For transformers, the mapping is manually
|
|
9
|
+
* based on api-inference.
|
|
10
10
|
*/
|
|
11
|
-
export const
|
|
11
|
+
export const LIBRARY_TASK_MAPPING: Partial<Record<ModelLibraryKey, PipelineType[]>> = {
|
|
12
12
|
"adapter-transformers": ["question-answering", "text-classification", "token-classification"],
|
|
13
13
|
allennlp: ["question-answering"],
|
|
14
14
|
asteroid: [
|
|
@@ -44,5 +44,24 @@ export const LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS: Partial<Record<ModelLi
|
|
|
44
44
|
],
|
|
45
45
|
stanza: ["token-classification"],
|
|
46
46
|
timm: ["image-classification"],
|
|
47
|
+
transformers: [
|
|
48
|
+
"audio-classification",
|
|
49
|
+
"automatic-speech-recognition",
|
|
50
|
+
"depth-estimation",
|
|
51
|
+
"document-question-answering",
|
|
52
|
+
"feature-extraction",
|
|
53
|
+
"fill-mask",
|
|
54
|
+
"image-classification",
|
|
55
|
+
"image-segmentation",
|
|
56
|
+
"image-to-text",
|
|
57
|
+
"image-to-image",
|
|
58
|
+
"object-detection",
|
|
59
|
+
"question-answering",
|
|
60
|
+
"text-generation",
|
|
61
|
+
"text2text-generation",
|
|
62
|
+
"visual-question-answering",
|
|
63
|
+
"zero-shot-classification",
|
|
64
|
+
"zero-shot-image-classification",
|
|
65
|
+
],
|
|
47
66
|
mindspore: ["image-classification"],
|
|
48
67
|
};
|
package/src/tasks/index.ts
CHANGED
|
@@ -92,6 +92,8 @@ export type {
|
|
|
92
92
|
TextGenerationParameters,
|
|
93
93
|
TextGenerationOutputSequenceDetails,
|
|
94
94
|
TextGenerationOutputToken,
|
|
95
|
+
TextGenerationStreamDetails,
|
|
96
|
+
TextGenerationStreamOutput,
|
|
95
97
|
} from "./text-generation/inference";
|
|
96
98
|
export type * from "./video-classification/inference";
|
|
97
99
|
export type * from "./visual-question-answering/inference";
|
|
@@ -112,7 +114,7 @@ import type { ModelLibraryKey } from "../model-libraries";
|
|
|
112
114
|
*/
|
|
113
115
|
export const TASKS_MODEL_LIBRARIES: Record<PipelineType, ModelLibraryKey[]> = {
|
|
114
116
|
"audio-classification": ["speechbrain", "transformers", "transformers.js"],
|
|
115
|
-
"audio-to-audio": ["asteroid", "speechbrain"],
|
|
117
|
+
"audio-to-audio": ["asteroid", "fairseq", "speechbrain"],
|
|
116
118
|
"automatic-speech-recognition": ["espnet", "nemo", "speechbrain", "transformers", "transformers.js"],
|
|
117
119
|
"depth-estimation": ["transformers", "transformers.js"],
|
|
118
120
|
"document-question-answering": ["transformers", "transformers.js"],
|
package/src/tokenizer-data.ts
CHANGED