machineuser commited on
Commit
9d298eb
β€’
1 Parent(s): bc51005

Sync widgets demo

Browse files
This view is limited to 50 files because it contains too many changes. Β  See raw diff
Files changed (50) hide show
  1. packages/tasks/README.md +16 -2
  2. packages/tasks/package.json +1 -1
  3. packages/tasks/src/Types.ts +0 -64
  4. packages/tasks/src/const.ts +0 -62
  5. packages/{widgets/src/lib/interfaces/DefaultWidget.ts β†’ tasks/src/default-widget-inputs.ts} +2 -2
  6. packages/tasks/src/index.ts +35 -4
  7. packages/{widgets/src/lib/interfaces/LibrariesToTasks.ts β†’ tasks/src/library-to-tasks.ts} +2 -1
  8. packages/{widgets/src/lib/interfaces/Libraries.ts β†’ tasks/src/library-ui-elements.ts} +2 -3
  9. packages/{widgets/src/lib/components/InferenceWidget/shared/WidgetExample.ts β†’ tasks/src/model-data.ts} +125 -0
  10. packages/tasks/src/{modelLibraries.ts β†’ model-libraries.ts} +0 -0
  11. packages/{widgets/src/lib/inferenceSnippets/serveCurl.ts β†’ tasks/src/snippets/curl.ts} +2 -2
  12. packages/tasks/src/snippets/index.ts +6 -0
  13. packages/{widgets/src/lib/inferenceSnippets β†’ tasks/src/snippets}/inputs.ts +2 -2
  14. packages/{widgets/src/lib/inferenceSnippets/serveJs.ts β†’ tasks/src/snippets/js.ts} +2 -2
  15. packages/{widgets/src/lib/inferenceSnippets/servePython.ts β†’ tasks/src/snippets/python.ts} +2 -2
  16. packages/tasks/src/{audio-classification β†’ tasks/audio-classification}/about.md +0 -0
  17. packages/tasks/src/{audio-classification β†’ tasks/audio-classification}/data.ts +1 -1
  18. packages/tasks/src/{audio-to-audio β†’ tasks/audio-to-audio}/about.md +0 -0
  19. packages/tasks/src/{audio-to-audio β†’ tasks/audio-to-audio}/data.ts +1 -1
  20. packages/tasks/src/{automatic-speech-recognition β†’ tasks/automatic-speech-recognition}/about.md +0 -0
  21. packages/tasks/src/{automatic-speech-recognition β†’ tasks/automatic-speech-recognition}/data.ts +1 -1
  22. packages/tasks/src/{conversational β†’ tasks/conversational}/about.md +0 -0
  23. packages/tasks/src/{conversational β†’ tasks/conversational}/data.ts +1 -1
  24. packages/tasks/src/{depth-estimation β†’ tasks/depth-estimation}/about.md +0 -0
  25. packages/tasks/src/{depth-estimation β†’ tasks/depth-estimation}/data.ts +1 -1
  26. packages/tasks/src/{document-question-answering β†’ tasks/document-question-answering}/about.md +0 -0
  27. packages/tasks/src/{document-question-answering β†’ tasks/document-question-answering}/data.ts +1 -1
  28. packages/tasks/src/{feature-extraction β†’ tasks/feature-extraction}/about.md +0 -0
  29. packages/tasks/src/{feature-extraction β†’ tasks/feature-extraction}/data.ts +1 -1
  30. packages/tasks/src/{fill-mask β†’ tasks/fill-mask}/about.md +0 -0
  31. packages/tasks/src/{fill-mask β†’ tasks/fill-mask}/data.ts +1 -1
  32. packages/tasks/src/{image-classification β†’ tasks/image-classification}/about.md +0 -0
  33. packages/tasks/src/{image-classification β†’ tasks/image-classification}/data.ts +1 -1
  34. packages/tasks/src/{image-segmentation β†’ tasks/image-segmentation}/about.md +0 -0
  35. packages/tasks/src/{image-segmentation β†’ tasks/image-segmentation}/data.ts +1 -1
  36. packages/tasks/src/{image-to-image β†’ tasks/image-to-image}/about.md +0 -0
  37. packages/tasks/src/{image-to-image β†’ tasks/image-to-image}/data.ts +1 -1
  38. packages/tasks/src/{image-to-text β†’ tasks/image-to-text}/about.md +0 -0
  39. packages/tasks/src/{image-to-text β†’ tasks/image-to-text}/data.ts +1 -1
  40. packages/tasks/src/{tasksData.ts β†’ tasks/index.ts} +137 -15
  41. packages/tasks/src/{object-detection β†’ tasks/object-detection}/about.md +0 -0
  42. packages/tasks/src/{object-detection β†’ tasks/object-detection}/data.ts +1 -1
  43. packages/tasks/src/{placeholder β†’ tasks/placeholder}/about.md +0 -0
  44. packages/tasks/src/{placeholder β†’ tasks/placeholder}/data.ts +1 -1
  45. packages/tasks/src/{question-answering β†’ tasks/question-answering}/about.md +0 -0
  46. packages/tasks/src/{question-answering β†’ tasks/question-answering}/data.ts +1 -1
  47. packages/tasks/src/{reinforcement-learning β†’ tasks/reinforcement-learning}/about.md +0 -0
  48. packages/tasks/src/{reinforcement-learning β†’ tasks/reinforcement-learning}/data.ts +1 -1
  49. packages/tasks/src/{sentence-similarity β†’ tasks/sentence-similarity}/about.md +0 -0
  50. packages/tasks/src/{sentence-similarity β†’ tasks/sentence-similarity}/data.ts +1 -1
packages/tasks/README.md CHANGED
@@ -9,7 +9,7 @@ The Task pages are made to lower the barrier of entry to understand a task that
9
  The task pages avoid jargon to let everyone understand the documentation, and if specific terminology is needed, it is explained on the most basic level possible. This is important to understand before contributing to Tasks: at the end of every task page, the user is expected to be able to find and pull a model from the Hub and use it on their data and see if it works for their use case to come up with a proof of concept.
10
 
11
  ## How to Contribute
12
- You can open a pull request to contribute a new documentation about a new task. Under `src` we have a folder for every task that contains two files, `about.md` and `data.ts`. `about.md` contains the markdown part of the page, use cases, resources and minimal code block to infer a model that belongs to the task. `data.ts` contains redirections to canonical models and datasets, metrics, the schema of the task and the information the inference widget needs.
13
 
14
  ![Anatomy of a Task Page](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/contribution-guide/anatomy.png)
15
 
@@ -17,4 +17,18 @@ We have a [`dataset`](https://huggingface.co/datasets/huggingfacejs/tasks) that
17
 
18
  ![Libraries of a Task](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/contribution-guide/libraries.png)
19
 
20
- This might seem overwhelming, but you don't necessarily need to add all of these in one pull request or on your own, you can simply contribute one section. Feel free to ask for help whenever you need.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  The task pages avoid jargon to let everyone understand the documentation, and if specific terminology is needed, it is explained on the most basic level possible. This is important to understand before contributing to Tasks: at the end of every task page, the user is expected to be able to find and pull a model from the Hub and use it on their data and see if it works for their use case to come up with a proof of concept.
10
 
11
  ## How to Contribute
12
+ You can open a pull request to contribute a new documentation about a new task. Under `src/tasks` we have a folder for every task that contains two files, `about.md` and `data.ts`. `about.md` contains the markdown part of the page, use cases, resources and minimal code block to infer a model that belongs to the task. `data.ts` contains redirections to canonical models and datasets, metrics, the schema of the task and the information the inference widget needs.
13
 
14
  ![Anatomy of a Task Page](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/contribution-guide/anatomy.png)
15
 
 
17
 
18
  ![Libraries of a Task](https://huggingface.co/datasets/huggingfacejs/tasks/resolve/main/contribution-guide/libraries.png)
19
 
20
+ This might seem overwhelming, but you don't necessarily need to add all of these in one pull request or on your own, you can simply contribute one section. Feel free to ask for help whenever you need.
21
+
22
+ ## Other data
23
+
24
+ This package contains the definition files (written in Typescript) for the huggingface.co hub's:
25
+
26
+ - **pipeline types** a.k.a. **task types** (used to determine which widget to display on the model page, and which inference API to run)
27
+ - **default widget inputs** (when they aren't provided in the model card)
28
+ - definitions and UI elements for **third party libraries**.
29
+
30
+ Please add to any of those definitions by opening a PR. Thanks πŸ”₯
31
+
32
+ ⚠️ The hub's definitive doc is at https://huggingface.co/docs/hub.
33
+
34
+ ## Feedback (feature requests, bugs, etc.) is super welcome πŸ’™πŸ’šπŸ’›πŸ’œβ™₯️🧑
packages/tasks/package.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "name": "@huggingface/tasks",
3
  "packageManager": "pnpm@8.10.5",
4
- "version": "0.0.6",
5
  "description": "List of ML tasks for huggingface.co/tasks",
6
  "repository": "https://github.com/huggingface/huggingface.js.git",
7
  "publishConfig": {
 
1
  {
2
  "name": "@huggingface/tasks",
3
  "packageManager": "pnpm@8.10.5",
4
+ "version": "0.0.7",
5
  "description": "List of ML tasks for huggingface.co/tasks",
6
  "repository": "https://github.com/huggingface/huggingface.js.git",
7
  "publishConfig": {
packages/tasks/src/Types.ts DELETED
@@ -1,64 +0,0 @@
1
- import type { ModelLibraryKey } from "./modelLibraries";
2
- import type { PipelineType } from "./pipelines";
3
-
4
- export interface ExampleRepo {
5
- description: string;
6
- id: string;
7
- }
8
-
9
- export type TaskDemoEntry =
10
- | {
11
- filename: string;
12
- type: "audio";
13
- }
14
- | {
15
- data: Array<{
16
- label: string;
17
- score: number;
18
- }>;
19
- type: "chart";
20
- }
21
- | {
22
- filename: string;
23
- type: "img";
24
- }
25
- | {
26
- table: string[][];
27
- type: "tabular";
28
- }
29
- | {
30
- content: string;
31
- label: string;
32
- type: "text";
33
- }
34
- | {
35
- text: string;
36
- tokens: Array<{
37
- end: number;
38
- start: number;
39
- type: string;
40
- }>;
41
- type: "text-with-tokens";
42
- };
43
-
44
- export interface TaskDemo {
45
- inputs: TaskDemoEntry[];
46
- outputs: TaskDemoEntry[];
47
- }
48
-
49
- export interface TaskData {
50
- datasets: ExampleRepo[];
51
- demo: TaskDemo;
52
- id: PipelineType;
53
- isPlaceholder?: boolean;
54
- label: string;
55
- libraries: ModelLibraryKey[];
56
- metrics: ExampleRepo[];
57
- models: ExampleRepo[];
58
- spaces: ExampleRepo[];
59
- summary: string;
60
- widgetModels: string[];
61
- youtubeId?: string;
62
- }
63
-
64
- export type TaskDataCustom = Omit<TaskData, "id" | "label" | "libraries">;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
packages/tasks/src/const.ts DELETED
@@ -1,62 +0,0 @@
1
- import type { ModelLibraryKey } from "./modelLibraries";
2
- import type { PipelineType } from "./pipelines";
3
-
4
- /**
5
- * Model libraries compatible with each ML task
6
- */
7
- export const TASKS_MODEL_LIBRARIES: Record<PipelineType, ModelLibraryKey[]> = {
8
- "audio-classification": ["speechbrain", "transformers"],
9
- "audio-to-audio": ["asteroid", "speechbrain"],
10
- "automatic-speech-recognition": ["espnet", "nemo", "speechbrain", "transformers", "transformers.js"],
11
- conversational: ["transformers"],
12
- "depth-estimation": ["transformers"],
13
- "document-question-answering": ["transformers"],
14
- "feature-extraction": ["sentence-transformers", "transformers", "transformers.js"],
15
- "fill-mask": ["transformers", "transformers.js"],
16
- "graph-ml": ["transformers"],
17
- "image-classification": ["keras", "timm", "transformers", "transformers.js"],
18
- "image-segmentation": ["transformers", "transformers.js"],
19
- "image-to-image": ["diffusers"],
20
- "image-to-text": ["transformers.js"],
21
- "image-to-video": ["diffusers"],
22
- "video-classification": ["transformers"],
23
- "mask-generation": ["transformers"],
24
- "multiple-choice": ["transformers"],
25
- "object-detection": ["transformers", "transformers.js"],
26
- other: [],
27
- "question-answering": ["adapter-transformers", "allennlp", "transformers", "transformers.js"],
28
- robotics: [],
29
- "reinforcement-learning": ["transformers", "stable-baselines3", "ml-agents", "sample-factory"],
30
- "sentence-similarity": ["sentence-transformers", "spacy", "transformers.js"],
31
- summarization: ["transformers", "transformers.js"],
32
- "table-question-answering": ["transformers"],
33
- "table-to-text": ["transformers"],
34
- "tabular-classification": ["sklearn"],
35
- "tabular-regression": ["sklearn"],
36
- "tabular-to-text": ["transformers"],
37
- "text-classification": ["adapter-transformers", "spacy", "transformers", "transformers.js"],
38
- "text-generation": ["transformers", "transformers.js"],
39
- "text-retrieval": [],
40
- "text-to-image": ["diffusers"],
41
- "text-to-speech": ["espnet", "tensorflowtts", "transformers"],
42
- "text-to-audio": ["transformers"],
43
- "text-to-video": ["diffusers"],
44
- "text2text-generation": ["transformers", "transformers.js"],
45
- "time-series-forecasting": [],
46
- "token-classification": [
47
- "adapter-transformers",
48
- "flair",
49
- "spacy",
50
- "span-marker",
51
- "stanza",
52
- "transformers",
53
- "transformers.js",
54
- ],
55
- translation: ["transformers", "transformers.js"],
56
- "unconditional-image-generation": ["diffusers"],
57
- "visual-question-answering": ["transformers"],
58
- "voice-activity-detection": [],
59
- "zero-shot-classification": ["transformers", "transformers.js"],
60
- "zero-shot-image-classification": ["transformers", "transformers.js"],
61
- "zero-shot-object-detection": ["transformers"],
62
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
packages/{widgets/src/lib/interfaces/DefaultWidget.ts β†’ tasks/src/default-widget-inputs.ts} RENAMED
@@ -1,5 +1,5 @@
1
- import type { PipelineType } from "@huggingface/tasks";
2
- import type { WidgetExample } from "../components/InferenceWidget/shared/WidgetExample.js";
3
 
4
  type LanguageCode = string;
5
 
 
1
+ import type { WidgetExample } from "./model-data";
2
+ import type { PipelineType } from "./pipelines";
3
 
4
  type LanguageCode = string;
5
 
packages/tasks/src/index.ts CHANGED
@@ -1,5 +1,8 @@
1
- export type { TaskData, TaskDemo, TaskDemoEntry, ExampleRepo } from "./Types";
2
- export { TASKS_DATA } from "./tasksData";
 
 
 
3
  export {
4
  PIPELINE_DATA,
5
  PIPELINE_TYPES,
@@ -11,7 +14,35 @@ export {
11
  SUBTASK_TYPES,
12
  PIPELINE_TYPES_SET,
13
  } from "./pipelines";
14
- export { ModelLibrary, ALL_DISPLAY_MODEL_LIBRARY_KEYS } from "./modelLibraries";
15
- export type { ModelLibraryKey } from "./modelLibraries";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  export { TAG_NFAA_CONTENT, OTHER_TAGS_SUGGESTIONS, TAG_TEXT_GENERATION_INFERENCE, TAG_CUSTOM_CODE } from "./tags";
 
 
 
 
 
 
1
+ export { LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS } from "./library-to-tasks";
2
+ export { MODEL_LIBRARIES_UI_ELEMENTS } from "./library-ui-elements";
3
+ export { MAPPING_DEFAULT_WIDGET } from "./default-widget-inputs";
4
+ export type { TaskData, TaskDemo, TaskDemoEntry, ExampleRepo } from "./tasks";
5
+ export * from "./tasks";
6
  export {
7
  PIPELINE_DATA,
8
  PIPELINE_TYPES,
 
14
  SUBTASK_TYPES,
15
  PIPELINE_TYPES_SET,
16
  } from "./pipelines";
17
+ export { ModelLibrary, ALL_DISPLAY_MODEL_LIBRARY_KEYS } from "./model-libraries";
18
+ export type { ModelLibraryKey } from "./model-libraries";
19
+ export {
20
+ ModelData,
21
+ TransformersInfo,
22
+ WidgetExample,
23
+ WidgetExampleAttribute,
24
+ WidgetExampleAssetAndPromptInput,
25
+ WidgetExampleAssetAndTextInput,
26
+ WidgetExampleAssetAndZeroShotInput,
27
+ WidgetExampleAssetInput,
28
+ WidgetExampleSentenceSimilarityInput,
29
+ WidgetExampleStructuredDataInput,
30
+ WidgetExampleTableDataInput,
31
+ WidgetExampleTextAndContextInput,
32
+ WidgetExampleTextAndTableInput,
33
+ WidgetExampleTextInput,
34
+ WidgetExampleZeroShotTextInput,
35
+ WidgetExampleOutput,
36
+ WidgetExampleOutputUrl,
37
+ WidgetExampleOutputLabels,
38
+ WidgetExampleOutputAnswerScore,
39
+ WidgetExampleOutputText,
40
+ } from "./model-data";
41
+ export { InferenceDisplayability } from "./model-data";
42
 
43
  export { TAG_NFAA_CONTENT, OTHER_TAGS_SUGGESTIONS, TAG_TEXT_GENERATION_INFERENCE, TAG_CUSTOM_CODE } from "./tags";
44
+
45
+ import * as snippets from "./snippets";
46
+ export { snippets };
47
+
48
+ export type { LibraryUiElement } from "./library-ui-elements";
packages/{widgets/src/lib/interfaces/LibrariesToTasks.ts β†’ tasks/src/library-to-tasks.ts} RENAMED
@@ -1,4 +1,5 @@
1
- import type { ModelLibraryKey, PipelineType } from "@huggingface/tasks";
 
2
 
3
  /**
4
  * Mapping from library name (excluding Transformers) to its supported tasks.
 
1
+ import type { ModelLibraryKey } from "./model-libraries";
2
+ import type { PipelineType } from "./pipelines";
3
 
4
  /**
5
  * Mapping from library name (excluding Transformers) to its supported tasks.
packages/{widgets/src/lib/interfaces/Libraries.ts β†’ tasks/src/library-ui-elements.ts} RENAMED
@@ -1,6 +1,5 @@
1
- import type { ModelLibraryKey } from "@huggingface/tasks";
2
- /* eslint-disable @typescript-eslint/naming-convention */
3
- import type { ModelData } from "./Types.js";
4
 
5
  /**
6
  * Elements configurable by a model library.
 
1
+ import type { ModelData } from "./model-data";
2
+ import type { ModelLibraryKey } from "./model-libraries";
 
3
 
4
  /**
5
  * Elements configurable by a model library.
packages/{widgets/src/lib/components/InferenceWidget/shared/WidgetExample.ts β†’ tasks/src/model-data.ts} RENAMED
@@ -1,3 +1,5 @@
 
 
1
  type TableData = Record<string, (string | number)[]>;
2
 
3
  //#region outputs
@@ -112,3 +114,126 @@ export type WidgetExample<TOutput = WidgetExampleOutput> =
112
  type KeysOfUnion<T> = T extends unknown ? keyof T : never;
113
 
114
  export type WidgetExampleAttribute = KeysOfUnion<WidgetExample>;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { PipelineType } from "./pipelines";
2
+
3
  type TableData = Record<string, (string | number)[]>;
4
 
5
  //#region outputs
 
114
  type KeysOfUnion<T> = T extends unknown ? keyof T : never;
115
 
116
  export type WidgetExampleAttribute = KeysOfUnion<WidgetExample>;
117
+
118
+ export enum InferenceDisplayability {
119
+ /**
120
+ * Yes
121
+ */
122
+ Yes = "Yes",
123
+ /**
124
+ * And then, all the possible reasons why it's no:
125
+ */
126
+ ExplicitOptOut = "ExplicitOptOut",
127
+ CustomCode = "CustomCode",
128
+ LibraryNotDetected = "LibraryNotDetected",
129
+ PipelineNotDetected = "PipelineNotDetected",
130
+ PipelineLibraryPairNotSupported = "PipelineLibraryPairNotSupported",
131
+ }
132
+
133
+ /**
134
+ * Public interface for model metadata
135
+ */
136
+ export interface ModelData {
137
+ /**
138
+ * id of model (e.g. 'user/repo_name')
139
+ */
140
+ id: string;
141
+ /**
142
+ * Kept for backward compatibility
143
+ */
144
+ modelId?: string;
145
+ /**
146
+ * Whether or not to enable inference widget for this model
147
+ */
148
+ inference: InferenceDisplayability;
149
+ /**
150
+ * is this model private?
151
+ */
152
+ private?: boolean;
153
+ /**
154
+ * this dictionary has useful information about the model configuration
155
+ */
156
+ config?: Record<string, unknown> & {
157
+ adapter_transformers?: { model_class?: string; model_name?: string };
158
+ architectures?: string[];
159
+ sklearn?: {
160
+ filename?: string;
161
+ model_format?: string;
162
+ };
163
+ speechbrain?: {
164
+ interface?: string;
165
+ };
166
+ peft?: {
167
+ base_model_name?: string;
168
+ task_type?: string;
169
+ };
170
+ };
171
+ /**
172
+ * all the model tags
173
+ */
174
+ tags?: string[];
175
+ /**
176
+ * transformers-specific info to display in the code sample.
177
+ */
178
+ transformersInfo?: TransformersInfo;
179
+ /**
180
+ * Pipeline type
181
+ */
182
+ pipeline_tag?: PipelineType | undefined;
183
+ /**
184
+ * for relevant models, get mask token
185
+ */
186
+ mask_token?: string | undefined;
187
+ /**
188
+ * Example data that will be fed into the widget.
189
+ *
190
+ * can be set in the model card metadata (under `widget`),
191
+ * or by default in `DefaultWidget.ts`
192
+ */
193
+ widgetData?: WidgetExample[] | undefined;
194
+ /**
195
+ * Parameters that will be used by the widget when calling Inference API
196
+ * https://huggingface.co/docs/api-inference/detailed_parameters
197
+ *
198
+ * can be set in the model card metadata (under `inference/parameters`)
199
+ * Example:
200
+ * inference:
201
+ * parameters:
202
+ * key: val
203
+ */
204
+ cardData?: {
205
+ inference?:
206
+ | boolean
207
+ | {
208
+ parameters?: Record<string, unknown>;
209
+ };
210
+ base_model?: string;
211
+ };
212
+ /**
213
+ * Library name
214
+ * Example: transformers, SpeechBrain, Stanza, etc.
215
+ */
216
+ library_name?: string;
217
+ }
218
+
219
+ /**
220
+ * transformers-specific info to display in the code sample.
221
+ */
222
+ export interface TransformersInfo {
223
+ /**
224
+ * e.g. AutoModelForSequenceClassification
225
+ */
226
+ auto_model: string;
227
+ /**
228
+ * if set in config.json's auto_map
229
+ */
230
+ custom_class?: string;
231
+ /**
232
+ * e.g. text-classification
233
+ */
234
+ pipeline_tag?: PipelineType;
235
+ /**
236
+ * e.g. "AutoTokenizer" | "AutoFeatureExtractor" | "AutoProcessor"
237
+ */
238
+ processor?: string;
239
+ }
packages/tasks/src/{modelLibraries.ts β†’ model-libraries.ts} RENAMED
File without changes
packages/{widgets/src/lib/inferenceSnippets/serveCurl.ts β†’ tasks/src/snippets/curl.ts} RENAMED
@@ -1,5 +1,5 @@
1
- import type { PipelineType } from "@huggingface/tasks";
2
- import type { ModelData } from "../interfaces/Types.js";
3
  import { getModelInputSnippet } from "./inputs.js";
4
 
5
  export const snippetBasic = (model: ModelData, accessToken: string): string =>
 
1
+ import type { ModelData } from "../model-data.js";
2
+ import type { PipelineType } from "../pipelines.js";
3
  import { getModelInputSnippet } from "./inputs.js";
4
 
5
  export const snippetBasic = (model: ModelData, accessToken: string): string =>
packages/tasks/src/snippets/index.ts ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import * as inputs from "./inputs";
2
+ import * as curl from "./curl";
3
+ import * as python from "./python";
4
+ import * as js from "./js";
5
+
6
+ export { inputs, curl, python, js };
packages/{widgets/src/lib/inferenceSnippets β†’ tasks/src/snippets}/inputs.ts RENAMED
@@ -1,5 +1,5 @@
1
- import type { PipelineType } from "@huggingface/tasks";
2
- import type { ModelData } from "../interfaces/Types.js";
3
 
4
  const inputsZeroShotClassification = () =>
5
  `"Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"`;
 
1
+ import type { ModelData } from "../model-data";
2
+ import type { PipelineType } from "../pipelines";
3
 
4
  const inputsZeroShotClassification = () =>
5
  `"Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!"`;
packages/{widgets/src/lib/inferenceSnippets/serveJs.ts β†’ tasks/src/snippets/js.ts} RENAMED
@@ -1,5 +1,5 @@
1
- import type { PipelineType } from "@huggingface/tasks";
2
- import type { ModelData } from "../interfaces/Types.js";
3
  import { getModelInputSnippet } from "./inputs.js";
4
 
5
  export const snippetBasic = (model: ModelData, accessToken: string): string =>
 
1
+ import type { ModelData } from "../model-data.js";
2
+ import type { PipelineType } from "../pipelines.js";
3
  import { getModelInputSnippet } from "./inputs.js";
4
 
5
  export const snippetBasic = (model: ModelData, accessToken: string): string =>
packages/{widgets/src/lib/inferenceSnippets/servePython.ts β†’ tasks/src/snippets/python.ts} RENAMED
@@ -1,5 +1,5 @@
1
- import type { PipelineType } from "@huggingface/tasks";
2
- import type { ModelData } from "../interfaces/Types.js";
3
  import { getModelInputSnippet } from "./inputs.js";
4
 
5
  export const snippetZeroShotClassification = (model: ModelData): string =>
 
1
+ import type { ModelData } from "../model-data.js";
2
+ import type { PipelineType } from "../pipelines.js";
3
  import { getModelInputSnippet } from "./inputs.js";
4
 
5
  export const snippetZeroShotClassification = (model: ModelData): string =>
packages/tasks/src/{audio-classification β†’ tasks/audio-classification}/about.md RENAMED
File without changes
packages/tasks/src/{audio-classification β†’ tasks/audio-classification}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{audio-to-audio β†’ tasks/audio-to-audio}/about.md RENAMED
File without changes
packages/tasks/src/{audio-to-audio β†’ tasks/audio-to-audio}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{automatic-speech-recognition β†’ tasks/automatic-speech-recognition}/about.md RENAMED
File without changes
packages/tasks/src/{automatic-speech-recognition β†’ tasks/automatic-speech-recognition}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{conversational β†’ tasks/conversational}/about.md RENAMED
File without changes
packages/tasks/src/{conversational β†’ tasks/conversational}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{depth-estimation β†’ tasks/depth-estimation}/about.md RENAMED
File without changes
packages/tasks/src/{depth-estimation β†’ tasks/depth-estimation}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{document-question-answering β†’ tasks/document-question-answering}/about.md RENAMED
File without changes
packages/tasks/src/{document-question-answering β†’ tasks/document-question-answering}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{feature-extraction β†’ tasks/feature-extraction}/about.md RENAMED
File without changes
packages/tasks/src/{feature-extraction β†’ tasks/feature-extraction}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{fill-mask β†’ tasks/fill-mask}/about.md RENAMED
File without changes
packages/tasks/src/{fill-mask β†’ tasks/fill-mask}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{image-classification β†’ tasks/image-classification}/about.md RENAMED
File without changes
packages/tasks/src/{image-classification β†’ tasks/image-classification}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{image-segmentation β†’ tasks/image-segmentation}/about.md RENAMED
File without changes
packages/tasks/src/{image-segmentation β†’ tasks/image-segmentation}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{image-to-image β†’ tasks/image-to-image}/about.md RENAMED
File without changes
packages/tasks/src/{image-to-image β†’ tasks/image-to-image}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{image-to-text β†’ tasks/image-to-text}/about.md RENAMED
File without changes
packages/tasks/src/{image-to-text β†’ tasks/image-to-text}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{tasksData.ts β†’ tasks/index.ts} RENAMED
@@ -1,5 +1,4 @@
1
- import { type PipelineType, PIPELINE_DATA } from "./pipelines";
2
- import type { TaskDataCustom, TaskData } from "./Types";
3
 
4
  import audioClassification from "./audio-classification/data";
5
  import audioToAudio from "./audio-to-audio/data";
@@ -34,7 +33,82 @@ import videoClassification from "./video-classification/data";
34
  import visualQuestionAnswering from "./visual-question-answering/data";
35
  import zeroShotClassification from "./zero-shot-classification/data";
36
  import zeroShotImageClassification from "./zero-shot-image-classification/data";
37
- import { TASKS_MODEL_LIBRARIES } from "./const";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
 
39
  // To make comparisons easier, task order is the same as in const.ts
40
  // Tasks set to undefined won't have an associated task page.
@@ -89,16 +163,64 @@ export const TASKS_DATA: Record<PipelineType, TaskData | undefined> = {
89
  "zero-shot-object-detection": getData("zero-shot-object-detection", placeholder),
90
  } as const;
91
 
92
- /**
93
- * Return the whole TaskData object for a certain task.
94
- * If the partialTaskData argument is left undefined,
95
- * the default placholder data will be used.
96
- */
97
- function getData(type: PipelineType, partialTaskData: TaskDataCustom = placeholder): TaskData {
98
- return {
99
- ...partialTaskData,
100
- id: type,
101
- label: PIPELINE_DATA[type].name,
102
- libraries: TASKS_MODEL_LIBRARIES[type],
103
- };
104
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { type PipelineType, PIPELINE_DATA } from "../pipelines";
 
2
 
3
  import audioClassification from "./audio-classification/data";
4
  import audioToAudio from "./audio-to-audio/data";
 
33
  import visualQuestionAnswering from "./visual-question-answering/data";
34
  import zeroShotClassification from "./zero-shot-classification/data";
35
  import zeroShotImageClassification from "./zero-shot-image-classification/data";
36
+
37
+ import type { ModelLibraryKey } from "../model-libraries";
38
+
39
+ /**
40
+ * Model libraries compatible with each ML task
41
+ */
42
+ export const TASKS_MODEL_LIBRARIES: Record<PipelineType, ModelLibraryKey[]> = {
43
+ "audio-classification": ["speechbrain", "transformers"],
44
+ "audio-to-audio": ["asteroid", "speechbrain"],
45
+ "automatic-speech-recognition": ["espnet", "nemo", "speechbrain", "transformers", "transformers.js"],
46
+ conversational: ["transformers"],
47
+ "depth-estimation": ["transformers"],
48
+ "document-question-answering": ["transformers"],
49
+ "feature-extraction": ["sentence-transformers", "transformers", "transformers.js"],
50
+ "fill-mask": ["transformers", "transformers.js"],
51
+ "graph-ml": ["transformers"],
52
+ "image-classification": ["keras", "timm", "transformers", "transformers.js"],
53
+ "image-segmentation": ["transformers", "transformers.js"],
54
+ "image-to-image": ["diffusers"],
55
+ "image-to-text": ["transformers.js"],
56
+ "image-to-video": ["diffusers"],
57
+ "video-classification": ["transformers"],
58
+ "mask-generation": ["transformers"],
59
+ "multiple-choice": ["transformers"],
60
+ "object-detection": ["transformers", "transformers.js"],
61
+ other: [],
62
+ "question-answering": ["adapter-transformers", "allennlp", "transformers", "transformers.js"],
63
+ robotics: [],
64
+ "reinforcement-learning": ["transformers", "stable-baselines3", "ml-agents", "sample-factory"],
65
+ "sentence-similarity": ["sentence-transformers", "spacy", "transformers.js"],
66
+ summarization: ["transformers", "transformers.js"],
67
+ "table-question-answering": ["transformers"],
68
+ "table-to-text": ["transformers"],
69
+ "tabular-classification": ["sklearn"],
70
+ "tabular-regression": ["sklearn"],
71
+ "tabular-to-text": ["transformers"],
72
+ "text-classification": ["adapter-transformers", "spacy", "transformers", "transformers.js"],
73
+ "text-generation": ["transformers", "transformers.js"],
74
+ "text-retrieval": [],
75
+ "text-to-image": ["diffusers"],
76
+ "text-to-speech": ["espnet", "tensorflowtts", "transformers"],
77
+ "text-to-audio": ["transformers"],
78
+ "text-to-video": ["diffusers"],
79
+ "text2text-generation": ["transformers", "transformers.js"],
80
+ "time-series-forecasting": [],
81
+ "token-classification": [
82
+ "adapter-transformers",
83
+ "flair",
84
+ "spacy",
85
+ "span-marker",
86
+ "stanza",
87
+ "transformers",
88
+ "transformers.js",
89
+ ],
90
+ translation: ["transformers", "transformers.js"],
91
+ "unconditional-image-generation": ["diffusers"],
92
+ "visual-question-answering": ["transformers"],
93
+ "voice-activity-detection": [],
94
+ "zero-shot-classification": ["transformers", "transformers.js"],
95
+ "zero-shot-image-classification": ["transformers", "transformers.js"],
96
+ "zero-shot-object-detection": ["transformers"],
97
+ };
98
+
99
+ /**
100
+ * Return the whole TaskData object for a certain task.
101
+ * If the partialTaskData argument is left undefined,
102
+ * the default placholder data will be used.
103
+ */
104
+ function getData(type: PipelineType, partialTaskData: TaskDataCustom = placeholder): TaskData {
105
+ return {
106
+ ...partialTaskData,
107
+ id: type,
108
+ label: PIPELINE_DATA[type].name,
109
+ libraries: TASKS_MODEL_LIBRARIES[type],
110
+ };
111
+ }
112
 
113
  // To make comparisons easier, task order is the same as in const.ts
114
  // Tasks set to undefined won't have an associated task page.
 
163
  "zero-shot-object-detection": getData("zero-shot-object-detection", placeholder),
164
  } as const;
165
 
166
+ export interface ExampleRepo {
167
+ description: string;
168
+ id: string;
 
 
 
 
 
 
 
 
 
169
  }
170
+
171
+ export type TaskDemoEntry =
172
+ | {
173
+ filename: string;
174
+ type: "audio";
175
+ }
176
+ | {
177
+ data: Array<{
178
+ label: string;
179
+ score: number;
180
+ }>;
181
+ type: "chart";
182
+ }
183
+ | {
184
+ filename: string;
185
+ type: "img";
186
+ }
187
+ | {
188
+ table: string[][];
189
+ type: "tabular";
190
+ }
191
+ | {
192
+ content: string;
193
+ label: string;
194
+ type: "text";
195
+ }
196
+ | {
197
+ text: string;
198
+ tokens: Array<{
199
+ end: number;
200
+ start: number;
201
+ type: string;
202
+ }>;
203
+ type: "text-with-tokens";
204
+ };
205
+
206
+ export interface TaskDemo {
207
+ inputs: TaskDemoEntry[];
208
+ outputs: TaskDemoEntry[];
209
+ }
210
+
211
+ export interface TaskData {
212
+ datasets: ExampleRepo[];
213
+ demo: TaskDemo;
214
+ id: PipelineType;
215
+ isPlaceholder?: boolean;
216
+ label: string;
217
+ libraries: ModelLibraryKey[];
218
+ metrics: ExampleRepo[];
219
+ models: ExampleRepo[];
220
+ spaces: ExampleRepo[];
221
+ summary: string;
222
+ widgetModels: string[];
223
+ youtubeId?: string;
224
+ }
225
+
226
+ export type TaskDataCustom = Omit<TaskData, "id" | "label" | "libraries">;
packages/tasks/src/{object-detection β†’ tasks/object-detection}/about.md RENAMED
File without changes
packages/tasks/src/{object-detection β†’ tasks/object-detection}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{placeholder β†’ tasks/placeholder}/about.md RENAMED
File without changes
packages/tasks/src/{placeholder β†’ tasks/placeholder}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [],
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [],
packages/tasks/src/{question-answering β†’ tasks/question-answering}/about.md RENAMED
File without changes
packages/tasks/src/{question-answering β†’ tasks/question-answering}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{reinforcement-learning β†’ tasks/reinforcement-learning}/about.md RENAMED
File without changes
packages/tasks/src/{reinforcement-learning β†’ tasks/reinforcement-learning}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
packages/tasks/src/{sentence-similarity β†’ tasks/sentence-similarity}/about.md RENAMED
File without changes
packages/tasks/src/{sentence-similarity β†’ tasks/sentence-similarity}/data.ts RENAMED
@@ -1,4 +1,4 @@
1
- import type { TaskDataCustom } from "../Types";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [
 
1
+ import type { TaskDataCustom } from "..";
2
 
3
  const taskData: TaskDataCustom = {
4
  datasets: [