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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7026e84
b2ecf7d
 
7026e84
f108317
7026e84
 
 
 
b2ecf7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7026e84
b2ecf7d
 
6c7ce80
 
 
 
 
 
 
 
 
 
62d2745
 
7026e84
62d2745
 
 
 
7026e84
62d2745
 
7026e84
 
 
 
 
b2ecf7d
 
 
 
 
 
 
 
 
 
6c7ce80
7026e84
 
b2ecf7d
6c7ce80
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
export const MODALITIES = ["cv", "nlp", "audio", "tabular", "multimodal", "rl", "other"] as const;

export type Modality = (typeof MODALITIES)[number];

export const MODALITY_LABELS = {
	multimodal: "Multimodal",
	nlp: "Natural Language Processing",
	audio: "Audio",
	cv: "Computer Vision",
	rl: "Reinforcement Learning",
	tabular: "Tabular",
	other: "Other",
} satisfies Record<Modality, string>;

/**
 * Public interface for a sub task.
 *
 * This can be used in a model card's `model-index` metadata.
 * and is more granular classification that can grow significantly
 * over time as new tasks are added.
 */
export interface SubTask {
	/**
	 * type of the task (e.g. audio-source-separation)
	 */
	type: string;
	/**
	 * displayed name of the task (e.g. Audio Source Separation)
	 */
	name: string;
}

/**
 * Public interface for a PipelineData.
 *
 * This information corresponds to a pipeline type (aka task)
 * in the Hub.
 */
export interface PipelineData {
	/**
	 * displayed name of the task (e.g. Text Classification)
	 */
	name: string;
	subtasks?: SubTask[];
	modality: Modality;
	/**
	 * color for the tag icon.
	 */
	color: "blue" | "green" | "indigo" | "orange" | "red" | "yellow";
	/**
	 * whether to hide in /models filters
	 */
	hideInModels?: boolean;
	/**
	 * whether to hide in /datasets filters
	 */
	hideInDatasets?: boolean;
}

/// Coarse-grained taxonomy of tasks
///
/// This type is used in multiple places in the Hugging Face
/// ecosystem:
///  - To determine which widget to show.
///  - To determine which endpoint of Inference Endpoints to use.
///  - As filters at the left of models and datasets page.
///
/// Note that this is sensitive to order.
/// For each domain, the order should be of decreasing specificity.
/// This will impact the default pipeline tag of a model when not
/// specified.
export const PIPELINE_DATA = {
	"text-classification": {
		name: "Text Classification",
		subtasks: [
			{
				type: "acceptability-classification",
				name: "Acceptability Classification",
			},
			{
				type: "entity-linking-classification",
				name: "Entity Linking Classification",
			},
			{
				type: "fact-checking",
				name: "Fact Checking",
			},
			{
				type: "intent-classification",
				name: "Intent Classification",
			},
			{
				type: "language-identification",
				name: "Language Identification",
			},
			{
				type: "multi-class-classification",
				name: "Multi Class Classification",
			},
			{
				type: "multi-label-classification",
				name: "Multi Label Classification",
			},
			{
				type: "multi-input-text-classification",
				name: "Multi-input Text Classification",
			},
			{
				type: "natural-language-inference",
				name: "Natural Language Inference",
			},
			{
				type: "semantic-similarity-classification",
				name: "Semantic Similarity Classification",
			},
			{
				type: "sentiment-classification",
				name: "Sentiment Classification",
			},
			{
				type: "topic-classification",
				name: "Topic Classification",
			},
			{
				type: "semantic-similarity-scoring",
				name: "Semantic Similarity Scoring",
			},
			{
				type: "sentiment-scoring",
				name: "Sentiment Scoring",
			},
			{
				type: "sentiment-analysis",
				name: "Sentiment Analysis",
			},
			{
				type: "hate-speech-detection",
				name: "Hate Speech Detection",
			},
			{
				type: "text-scoring",
				name: "Text Scoring",
			},
		],
		modality: "nlp",
		color: "orange",
	},
	"token-classification": {
		name: "Token Classification",
		subtasks: [
			{
				type: "named-entity-recognition",
				name: "Named Entity Recognition",
			},
			{
				type: "part-of-speech",
				name: "Part of Speech",
			},
			{
				type: "parsing",
				name: "Parsing",
			},
			{
				type: "lemmatization",
				name: "Lemmatization",
			},
			{
				type: "word-sense-disambiguation",
				name: "Word Sense Disambiguation",
			},
			{
				type: "coreference-resolution",
				name: "Coreference-resolution",
			},
		],
		modality: "nlp",
		color: "blue",
	},
	"table-question-answering": {
		name: "Table Question Answering",
		modality: "nlp",
		color: "green",
	},
	"question-answering": {
		name: "Question Answering",
		subtasks: [
			{
				type: "extractive-qa",
				name: "Extractive QA",
			},
			{
				type: "open-domain-qa",
				name: "Open Domain QA",
			},
			{
				type: "closed-domain-qa",
				name: "Closed Domain QA",
			},
		],
		modality: "nlp",
		color: "blue",
	},
	"zero-shot-classification": {
		name: "Zero-Shot Classification",
		modality: "nlp",
		color: "yellow",
	},
	translation: {
		name: "Translation",
		modality: "nlp",
		color: "green",
	},
	summarization: {
		name: "Summarization",
		subtasks: [
			{
				type: "news-articles-summarization",
				name: "News Articles Summarization",
			},
			{
				type: "news-articles-headline-generation",
				name: "News Articles Headline Generation",
			},
		],
		modality: "nlp",
		color: "indigo",
	},
	"feature-extraction": {
		name: "Feature Extraction",
		modality: "nlp",
		color: "red",
	},
	"text-generation": {
		name: "Text Generation",
		subtasks: [
			{
				type: "dialogue-modeling",
				name: "Dialogue Modeling",
			},
			{
				type: "dialogue-generation",
				name: "Dialogue Generation",
			},
			{
				type: "conversational",
				name: "Conversational",
			},
			{
				type: "language-modeling",
				name: "Language Modeling",
			},
		],
		modality: "nlp",
		color: "indigo",
	},
	"text2text-generation": {
		name: "Text2Text Generation",
		subtasks: [
			{
				type: "text-simplification",
				name: "Text simplification",
			},
			{
				type: "explanation-generation",
				name: "Explanation Generation",
			},
			{
				type: "abstractive-qa",
				name: "Abstractive QA",
			},
			{
				type: "open-domain-abstractive-qa",
				name: "Open Domain Abstractive QA",
			},
			{
				type: "closed-domain-qa",
				name: "Closed Domain QA",
			},
			{
				type: "open-book-qa",
				name: "Open Book QA",
			},
			{
				type: "closed-book-qa",
				name: "Closed Book QA",
			},
		],
		modality: "nlp",
		color: "indigo",
	},
	"fill-mask": {
		name: "Fill-Mask",
		subtasks: [
			{
				type: "slot-filling",
				name: "Slot Filling",
			},
			{
				type: "masked-language-modeling",
				name: "Masked Language Modeling",
			},
		],
		modality: "nlp",
		color: "red",
	},
	"sentence-similarity": {
		name: "Sentence Similarity",
		modality: "nlp",
		color: "yellow",
	},
	"text-to-speech": {
		name: "Text-to-Speech",
		modality: "audio",
		color: "yellow",
	},
	"text-to-audio": {
		name: "Text-to-Audio",
		modality: "audio",
		color: "yellow",
	},
	"automatic-speech-recognition": {
		name: "Automatic Speech Recognition",
		modality: "audio",
		color: "yellow",
	},
	"audio-to-audio": {
		name: "Audio-to-Audio",
		modality: "audio",
		color: "blue",
	},
	"audio-classification": {
		name: "Audio Classification",
		subtasks: [
			{
				type: "keyword-spotting",
				name: "Keyword Spotting",
			},
			{
				type: "speaker-identification",
				name: "Speaker Identification",
			},
			{
				type: "audio-intent-classification",
				name: "Audio Intent Classification",
			},
			{
				type: "audio-emotion-recognition",
				name: "Audio Emotion Recognition",
			},
			{
				type: "audio-language-identification",
				name: "Audio Language Identification",
			},
		],
		modality: "audio",
		color: "green",
	},
	"voice-activity-detection": {
		name: "Voice Activity Detection",
		modality: "audio",
		color: "red",
	},
	"depth-estimation": {
		name: "Depth Estimation",
		modality: "cv",
		color: "yellow",
	},
	"image-classification": {
		name: "Image Classification",
		subtasks: [
			{
				type: "multi-label-image-classification",
				name: "Multi Label Image Classification",
			},
			{
				type: "multi-class-image-classification",
				name: "Multi Class Image Classification",
			},
		],
		modality: "cv",
		color: "blue",
	},
	"object-detection": {
		name: "Object Detection",
		subtasks: [
			{
				type: "face-detection",
				name: "Face Detection",
			},
			{
				type: "vehicle-detection",
				name: "Vehicle Detection",
			},
		],
		modality: "cv",
		color: "yellow",
	},
	"image-segmentation": {
		name: "Image Segmentation",
		subtasks: [
			{
				type: "instance-segmentation",
				name: "Instance Segmentation",
			},
			{
				type: "semantic-segmentation",
				name: "Semantic Segmentation",
			},
			{
				type: "panoptic-segmentation",
				name: "Panoptic Segmentation",
			},
		],
		modality: "cv",
		color: "green",
	},
	"text-to-image": {
		name: "Text-to-Image",
		modality: "cv",
		color: "yellow",
	},
	"image-to-text": {
		name: "Image-to-Text",
		subtasks: [
			{
				type: "image-captioning",
				name: "Image Captioning",
			},
		],
		modality: "cv",
		color: "red",
	},
	"image-to-image": {
		name: "Image-to-Image",
		subtasks: [
			{
				type: "image-inpainting",
				name: "Image Inpainting",
			},
			{
				type: "image-colorization",
				name: "Image Colorization",
			},
			{
				type: "super-resolution",
				name: "Super Resolution",
			},
		],
		modality: "cv",
		color: "indigo",
	},
	"image-to-video": {
		name: "Image-to-Video",
		modality: "cv",
		color: "indigo",
	},
	"unconditional-image-generation": {
		name: "Unconditional Image Generation",
		modality: "cv",
		color: "green",
	},
	"video-classification": {
		name: "Video Classification",
		modality: "cv",
		color: "blue",
	},
	"reinforcement-learning": {
		name: "Reinforcement Learning",
		modality: "rl",
		color: "red",
	},
	robotics: {
		name: "Robotics",
		modality: "rl",
		subtasks: [
			{
				type: "grasping",
				name: "Grasping",
			},
			{
				type: "task-planning",
				name: "Task Planning",
			},
		],
		color: "blue",
	},
	"tabular-classification": {
		name: "Tabular Classification",
		modality: "tabular",
		subtasks: [
			{
				type: "tabular-multi-class-classification",
				name: "Tabular Multi Class Classification",
			},
			{
				type: "tabular-multi-label-classification",
				name: "Tabular Multi Label Classification",
			},
		],
		color: "blue",
	},
	"tabular-regression": {
		name: "Tabular Regression",
		modality: "tabular",
		subtasks: [
			{
				type: "tabular-single-column-regression",
				name: "Tabular Single Column Regression",
			},
		],
		color: "blue",
	},
	"tabular-to-text": {
		name: "Tabular to Text",
		modality: "tabular",
		subtasks: [
			{
				type: "rdf-to-text",
				name: "RDF to text",
			},
		],
		color: "blue",
		hideInModels: true,
	},
	"table-to-text": {
		name: "Table to Text",
		modality: "nlp",
		color: "blue",
		hideInModels: true,
	},
	"multiple-choice": {
		name: "Multiple Choice",
		subtasks: [
			{
				type: "multiple-choice-qa",
				name: "Multiple Choice QA",
			},
			{
				type: "multiple-choice-coreference-resolution",
				name: "Multiple Choice Coreference Resolution",
			},
		],
		modality: "nlp",
		color: "blue",
		hideInModels: true,
	},
	"text-retrieval": {
		name: "Text Retrieval",
		subtasks: [
			{
				type: "document-retrieval",
				name: "Document Retrieval",
			},
			{
				type: "utterance-retrieval",
				name: "Utterance Retrieval",
			},
			{
				type: "entity-linking-retrieval",
				name: "Entity Linking Retrieval",
			},
			{
				type: "fact-checking-retrieval",
				name: "Fact Checking Retrieval",
			},
		],
		modality: "nlp",
		color: "indigo",
		hideInModels: true,
	},
	"time-series-forecasting": {
		name: "Time Series Forecasting",
		modality: "tabular",
		subtasks: [
			{
				type: "univariate-time-series-forecasting",
				name: "Univariate Time Series Forecasting",
			},
			{
				type: "multivariate-time-series-forecasting",
				name: "Multivariate Time Series Forecasting",
			},
		],
		color: "blue",
		hideInModels: true,
	},
	"text-to-video": {
		name: "Text-to-Video",
		modality: "cv",
		color: "green",
	},
	"image-text-to-text": {
		name: "Image-Text-to-Text",
		modality: "multimodal",
		color: "red",
		hideInDatasets: true,
	},
	"visual-question-answering": {
		name: "Visual Question Answering",
		subtasks: [
			{
				type: "visual-question-answering",
				name: "Visual Question Answering",
			},
		],
		modality: "multimodal",
		color: "red",
	},
	"document-question-answering": {
		name: "Document Question Answering",
		subtasks: [
			{
				type: "document-question-answering",
				name: "Document Question Answering",
			},
		],
		modality: "multimodal",
		color: "blue",
		hideInDatasets: true,
	},
	"zero-shot-image-classification": {
		name: "Zero-Shot Image Classification",
		modality: "cv",
		color: "yellow",
	},
	"graph-ml": {
		name: "Graph Machine Learning",
		modality: "other",
		color: "green",
	},
	"mask-generation": {
		name: "Mask Generation",
		modality: "cv",
		color: "indigo",
	},
	"zero-shot-object-detection": {
		name: "Zero-Shot Object Detection",
		modality: "cv",
		color: "yellow",
	},
	"text-to-3d": {
		name: "Text-to-3D",
		modality: "cv",
		color: "yellow",
	},
	"image-to-3d": {
		name: "Image-to-3D",
		modality: "cv",
		color: "green",
	},
	"image-feature-extraction": {
		name: "Image Feature Extraction",
		modality: "cv",
		color: "indigo",
	},
	other: {
		name: "Other",
		modality: "other",
		color: "blue",
		hideInModels: true,
		hideInDatasets: true,
	},
} satisfies Record<string, PipelineData>;

export type PipelineType = keyof typeof PIPELINE_DATA;

export type WidgetType = PipelineType | "conversational";

export const PIPELINE_TYPES = Object.keys(PIPELINE_DATA) as PipelineType[];

export const SUBTASK_TYPES = Object.values(PIPELINE_DATA)
	.flatMap((data) => ("subtasks" in data ? data.subtasks : []))
	.map((s) => s.type);

export const PIPELINE_TYPES_SET = new Set(PIPELINE_TYPES);