Skip to content

Commit b2ccf35

Browse files
beurkingermerveenoyanosanseviero
authored
Task placeholder pages (#335)
* contribution guide added * Tasks placeholder pages and contribution guide added (#303) Co-authored-by: Omar Sanseviero <[email protected]> * Linting * Fix placeholders id, label and libraries * Update output * Update placeholder data * Update placeholder data * Update placeholder about.md * Clean up TaskData * Shorten fn name * Update modalities order * Update task modalities order * Don't show tasks with hideInModels * Clean up TASK_DATA and add comments * Update comment Co-authored-by: merveenoyan <[email protected]> Co-authored-by: Omar Sanseviero <[email protected]>
1 parent 7b97c2e commit b2ccf35

File tree

23 files changed

+215
-236
lines changed

23 files changed

+215
-236
lines changed

js/src/lib/interfaces/Types.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
// Warning: order of modalities here determine how they are listed on the /tasks page
12
export const MODALITIES = [
2-
"multimodal",
3+
"cv",
34
"nlp",
45
"audio",
5-
"cv",
6-
"rl",
76
"tabular",
7+
"multimodal",
8+
"rl",
89
"other",
910
] as const;
1011

tasks-contribution-guide.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## Contributing to Tasks
2+
3+
Welcome to the contribution guide to [Hugging Face Tasks](https://huggingface.co/tasks) and thank you for considering contributing to the community!
4+
5+
### Philosophy behind Tasks
6+
7+
The Task pages are made to lower the barrier of entry to understand a task that can be solved with machine learning and use or train a model to accomplish it. It's a collaborative documentation effort made to help out software developers, social scientists, or anyone with no background in machine learning that is interested in understanding how machine learning models can be used to solve a problem.
8+
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 [hub-docs repository](https://github.com/huggingface/hub-docs) to contribute a new documentation about a new task. Under `tasks/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+
![Anatomy of a Task Page](tasks/assets/contribution-guide/anatomy.png)
14+
We have `tasks/assets` that contains data used in the inference widget and images used in the markdown file. The last file is `const.ts`, which has the task to library mapping (e.g. spacy to token-classification) where you can add a library. They will look in the top right corner like below.
15+
![Libraries of a Task](tasks/assets/contribution-guide/libraries.png)
16+
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.
415 KB
Loading
23 KB
Loading

tasks/src/Types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface TaskData {
4444
datasets: ExampleRepo[];
4545
demo: TaskDemo;
4646
id: PipelineType;
47+
isPlaceholder?: boolean;
4748
label: string;
4849
libraries: Array<keyof typeof ModelLibrary>;
4950
metrics: ExampleRepo[];
@@ -52,3 +53,5 @@ export interface TaskData {
5253
widgetModels: string[];
5354
youtubeId: string;
5455
}
56+
57+
export type TaskDataCustom = Omit<TaskData, "id" | "label" | "libraries">;

tasks/src/audio-classification/data.ts

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import type { TaskData } from "../Types";
1+
import type { TaskDataCustom } from "../Types";
22

3-
import { PIPELINE_DATA } from "../../../js/src/lib/interfaces/Types";
4-
import { TASKS_MODEL_LIBRARIES } from "../const";
5-
6-
const taskData: TaskData = {
3+
const taskData: TaskDataCustom = {
74
datasets: [
85
{
96
description: "A benchmark of 10 different audio tasks.",
@@ -17,43 +14,38 @@ const taskData: TaskData = {
1714
type: "audio",
1815
},
1916
],
20-
outputs:
21-
[
17+
outputs: [
2218
{
2319
data: [
2420
{
25-
"label": "Up",
26-
"score": 0.2
21+
label: "Up",
22+
score: 0.2,
2723
},
2824
{
29-
"label": "Down",
30-
"score": 0.8
25+
label: "Down",
26+
score: 0.8,
3127
},
3228
],
33-
"type": "chart",
29+
type: "chart",
3430
},
3531
],
3632
},
37-
id: "audio-classification",
38-
label: PIPELINE_DATA["audio-classification"].name,
39-
libraries: TASKS_MODEL_LIBRARIES["audio-classification"],
40-
metrics: [
33+
metrics: [
4134
{
4235
description: "",
43-
id: "accuracy",
36+
id: "accuracy",
4437
},
4538
{
4639
description: "",
47-
id: "recall",
48-
40+
id: "recall",
4941
},
5042
{
5143
description: "",
52-
id: "precision",
44+
id: "precision",
5345
},
5446
{
5547
description: "",
56-
id: "f1",
48+
id: "f1",
5749
},
5850
],
5951
models: [
@@ -66,7 +58,8 @@ const taskData: TaskData = {
6658
id: "superb/hubert-large-superb-er",
6759
},
6860
],
69-
summary: "Audio classification is the task of assigning a label or class to a given audio. It can be used for recognizing which command a user is giving or the emotion of a statement, as well as identifying a speaker.",
61+
summary:
62+
"Audio classification is the task of assigning a label or class to a given audio. It can be used for recognizing which command a user is giving or the emotion of a statement, as well as identifying a speaker.",
7063
widgetModels: ["speechbrain/google_speech_command_xvector"],
7164
youtubeId: "KWwzcmG98Ds",
7265
};

tasks/src/audio-to-audio/data.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import type { TaskData } from "../Types";
1+
import type { TaskDataCustom } from "../Types";
22

3-
import { PIPELINE_DATA } from "../../../js/src/lib/interfaces/Types";
4-
import { TASKS_MODEL_LIBRARIES } from "../const";
5-
6-
const taskData: TaskData = {
3+
const taskData: TaskDataCustom = {
74
datasets: [
85
],
96
demo: {
@@ -24,10 +21,7 @@ const taskData: TaskData = {
2421
},
2522
],
2623
},
27-
id: "audio-to-audio",
28-
label: PIPELINE_DATA["audio-to-audio"].name,
29-
libraries: TASKS_MODEL_LIBRARIES["audio-to-audio"],
30-
metrics: [
24+
metrics: [
3125
{
3226
description: "The Signal-to-Noise ratio is the relationship between the target signal level and the background noise level. It is calculated as the logarithm of the target signal divided by the background noise, in decibels.",
3327
id: "snri",

tasks/src/automatic-speech-recognition/data.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import type { TaskData } from "../Types";
1+
import type { TaskDataCustom } from "../Types";
22

3-
import { PIPELINE_DATA } from "../../../js/src/lib/interfaces/Types";
4-
import { TASKS_MODEL_LIBRARIES } from "../const";
5-
6-
const taskData: TaskData = {
3+
const taskData: TaskDataCustom = {
74
datasets: [
85
{
96
description: "An English dataset with 1,000 hours of data.",
@@ -30,10 +27,7 @@ const taskData: TaskData = {
3027
},
3128
],
3229
},
33-
id: "automatic-speech-recognition",
34-
label: PIPELINE_DATA["automatic-speech-recognition"].name,
35-
libraries: TASKS_MODEL_LIBRARIES["automatic-speech-recognition"],
36-
metrics: [
30+
metrics: [
3731
{
3832
description: "",
3933
id: "wer",

tasks/src/fill-mask/data.ts

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import type { TaskData } from "../Types";
1+
import type { TaskDataCustom } from "../Types";
22

3-
import { PIPELINE_DATA } from "../../../js/src/lib/interfaces/Types";
4-
import { TASKS_MODEL_LIBRARIES } from "../const";
5-
6-
const taskData: TaskData = {
3+
const taskData: TaskDataCustom = {
74
datasets: [
85
{
96
description: "A common dataset that is used to train models for many languages.",
@@ -25,36 +22,33 @@ const taskData: TaskData = {
2522
],
2623
outputs: [
2724
{
28-
"type": "chart",
25+
type: "chart",
2926
data: [
3027
{
31-
"label": "wolf",
32-
"score": 0.487
28+
label: "wolf",
29+
score: 0.487,
3330
},
3431
{
35-
"label": "dog",
36-
"score": 0.061
32+
label: "dog",
33+
score: 0.061,
3734
},
3835
{
39-
"label": "cat",
40-
"score": 0.058
36+
label: "cat",
37+
score: 0.058,
4138
},
4239
{
43-
"label": "fox",
44-
"score": 0.047
40+
label: "fox",
41+
score: 0.047,
4542
},
4643
{
47-
"label": "squirrel",
48-
"score": 0.025
49-
}
50-
]
44+
label: "squirrel",
45+
score: 0.025,
46+
},
47+
],
5148
},
5249
],
5350
},
54-
id: "fill-mask",
55-
label: PIPELINE_DATA["fill-mask"].name,
56-
libraries: TASKS_MODEL_LIBRARIES["fill-mask"],
57-
metrics: [
51+
metrics: [
5852
{
5953
description: "Cross Entropy is a metric that calculates the difference between two probability distributions. Each probability distribution is the distribution of predicted words",
6054
id: "cross_entropy",

tasks/src/image-classification/data.ts

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
import type { TaskData } from "../Types";
1+
import type { TaskDataCustom } from "../Types";
22

3-
import { PIPELINE_DATA } from "../../../js/src/lib/interfaces/Types";
4-
import { TASKS_MODEL_LIBRARIES } from "../const";
5-
6-
const taskData: TaskData = {
3+
const taskData: TaskDataCustom = {
74
datasets: [
85
{
96
// TODO write proper description
@@ -25,28 +22,25 @@ const taskData: TaskData = {
2522
],
2623
outputs: [
2724
{
28-
"type": "chart",
25+
type: "chart",
2926
data: [
3027
{
31-
"label": "Egyptian cat",
32-
"score": 0.514
28+
label: "Egyptian cat",
29+
score: 0.514,
3330
},
3431
{
35-
"label": "Tabby cat",
36-
"score": 0.193
32+
label: "Tabby cat",
33+
score: 0.193,
3734
},
3835
{
39-
"label": "Tiger cat",
40-
"score": 0.068
36+
label: "Tiger cat",
37+
score: 0.068,
4138
},
42-
]
39+
],
4340
},
4441
],
4542
},
46-
id: "image-classification",
47-
label: PIPELINE_DATA["image-classification"].name,
48-
libraries: TASKS_MODEL_LIBRARIES["image-classification"],
49-
metrics: [
43+
metrics: [
5044
{
5145
description: "",
5246
id: "accuracy",

0 commit comments

Comments
 (0)