Skip to content

Commit 32e3e48

Browse files
authored
Limit which tasks transformers has support for (#591)
Until now, the Hub assumes `transformers` has support for all tasks for which there's API, such as `audio-to-audio` (and there's no `AudioToAudioPipeline` in `transformers`). This list is derived from https://github.com/huggingface/api-inference/blob/main/shard/app/validation/__init__.py#L24 This will hide widgets/snippets for tasks not supported here
1 parent 1398ffb commit 32e3e48

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

packages/tasks/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export { LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS } from "./library-to-tasks";
1+
export { LIBRARY_TASK_MAPPING } from "./library-to-tasks";
22
export { MAPPING_DEFAULT_WIDGET } from "./default-widget-inputs";
33
export type { TaskData, TaskDemo, TaskDemoEntry, ExampleRepo } from "./tasks";
44
export * from "./tasks";

packages/tasks/src/library-to-tasks.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import type { ModelLibraryKey } from "./model-libraries";
22
import type { PipelineType } from "./pipelines";
33

44
/**
5-
* Mapping from library name (excluding Transformers) to its supported tasks.
5+
* Mapping from library name to its supported tasks.
66
* Inference API (serverless) should be disabled for all other (library, task) pairs beyond this mapping.
7-
* As an exception, we assume Transformers supports all inference tasks.
8-
* This mapping is generated automatically by "python-api-export-tasks" action in huggingface/api-inference-community repo upon merge.
9-
* Ref: https://github.com/huggingface/api-inference-community/pull/158
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.
1010
*/
11-
export const LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS: Partial<Record<ModelLibraryKey, PipelineType[]>> = {
11+
export const LIBRARY_TASK_MAPPING: Partial<Record<ModelLibraryKey, PipelineType[]>> = {
1212
"adapter-transformers": ["question-answering", "text-classification", "token-classification"],
1313
allennlp: ["question-answering"],
1414
asteroid: [
@@ -44,5 +44,23 @@ export const LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS: Partial<Record<ModelLi
4444
],
4545
stanza: ["token-classification"],
4646
timm: ["image-classification"],
47+
transformers: [
48+
"audio-classification",
49+
"automatic-speech-recognition",
50+
"depth-estimation",
51+
"document-question-answering",
52+
"fill-mask",
53+
"image-classification",
54+
"image-segmentation",
55+
"image-to-text",
56+
"image-to-image",
57+
"object-detection",
58+
"question-answering",
59+
"text-generation",
60+
"text2text-generation",
61+
"visual-question-answering",
62+
"zero-shot-classification",
63+
"zero-shot-image-classification",
64+
],
4765
mindspore: ["image-classification"],
4866
};

0 commit comments

Comments
 (0)