Skip to content

Limit which tasks transformers has support for #591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/tasks/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS } from "./library-to-tasks";
export { LIBRARY_TASK_MAPPING } from "./library-to-tasks";
export { MAPPING_DEFAULT_WIDGET } from "./default-widget-inputs";
export type { TaskData, TaskDemo, TaskDemoEntry, ExampleRepo } from "./tasks";
export * from "./tasks";
Expand Down
28 changes: 23 additions & 5 deletions packages/tasks/src/library-to-tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import type { ModelLibraryKey } from "./model-libraries";
import type { PipelineType } from "./pipelines";

/**
* Mapping from library name (excluding Transformers) to its supported tasks.
* Mapping from library name to its supported tasks.
* Inference API (serverless) should be disabled for all other (library, task) pairs beyond this mapping.
* As an exception, we assume Transformers supports all inference tasks.
* This mapping is generated automatically by "python-api-export-tasks" action in huggingface/api-inference-community repo upon merge.
* Ref: https://github.com/huggingface/api-inference-community/pull/158
* This mapping is partially generated automatically by "python-api-export-tasks" action in
* huggingface/api-inference-community repo upon merge. For transformers, the mapping is manually
* based on api-inference.
*/
export const LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS: Partial<Record<ModelLibraryKey, PipelineType[]>> = {
export const LIBRARY_TASK_MAPPING: Partial<Record<ModelLibraryKey, PipelineType[]>> = {
"adapter-transformers": ["question-answering", "text-classification", "token-classification"],
allennlp: ["question-answering"],
asteroid: [
Expand Down Expand Up @@ -44,5 +44,23 @@ export const LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS: Partial<Record<ModelLi
],
stanza: ["token-classification"],
timm: ["image-classification"],
transformers: [
"audio-classification",
"automatic-speech-recognition",
"depth-estimation",
"document-question-answering",
"fill-mask",
"image-classification",
"image-segmentation",
"image-to-text",
"image-to-image",
"object-detection",
"question-answering",
"text-generation",
"text2text-generation",
"visual-question-answering",
"zero-shot-classification",
"zero-shot-image-classification",
],
mindspore: ["image-classification"],
};