@huggingface/tasks 0.13.1-test → 0.13.1-test2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -2
- package/src/dataset-libraries.ts +89 -0
- package/src/default-widget-inputs.ts +718 -0
- package/src/gguf.ts +40 -0
- package/src/hardware.ts +482 -0
- package/src/index.ts +59 -0
- package/src/library-to-tasks.ts +76 -0
- package/src/local-apps.ts +412 -0
- package/src/model-data.ts +149 -0
- package/src/model-libraries-downloads.ts +18 -0
- package/src/model-libraries-snippets.ts +1128 -0
- package/src/model-libraries.ts +820 -0
- package/src/pipelines.ts +698 -0
- package/src/snippets/common.ts +39 -0
- package/src/snippets/curl.spec.ts +94 -0
- package/src/snippets/curl.ts +120 -0
- package/src/snippets/index.ts +7 -0
- package/src/snippets/inputs.ts +167 -0
- package/src/snippets/js.spec.ts +148 -0
- package/src/snippets/js.ts +305 -0
- package/src/snippets/python.spec.ts +144 -0
- package/src/snippets/python.ts +321 -0
- package/src/snippets/types.ts +16 -0
- package/src/tasks/audio-classification/about.md +86 -0
- package/src/tasks/audio-classification/data.ts +81 -0
- package/src/tasks/audio-classification/inference.ts +52 -0
- package/src/tasks/audio-classification/spec/input.json +35 -0
- package/src/tasks/audio-classification/spec/output.json +11 -0
- package/src/tasks/audio-to-audio/about.md +56 -0
- package/src/tasks/audio-to-audio/data.ts +70 -0
- package/src/tasks/automatic-speech-recognition/about.md +90 -0
- package/src/tasks/automatic-speech-recognition/data.ts +82 -0
- package/src/tasks/automatic-speech-recognition/inference.ts +160 -0
- package/src/tasks/automatic-speech-recognition/spec/input.json +35 -0
- package/src/tasks/automatic-speech-recognition/spec/output.json +38 -0
- package/src/tasks/chat-completion/inference.ts +322 -0
- package/src/tasks/chat-completion/spec/input.json +350 -0
- package/src/tasks/chat-completion/spec/output.json +206 -0
- package/src/tasks/chat-completion/spec/stream_output.json +213 -0
- package/src/tasks/common-definitions.json +100 -0
- package/src/tasks/depth-estimation/about.md +45 -0
- package/src/tasks/depth-estimation/data.ts +70 -0
- package/src/tasks/depth-estimation/inference.ts +35 -0
- package/src/tasks/depth-estimation/spec/input.json +25 -0
- package/src/tasks/depth-estimation/spec/output.json +16 -0
- package/src/tasks/document-question-answering/about.md +53 -0
- package/src/tasks/document-question-answering/data.ts +85 -0
- package/src/tasks/document-question-answering/inference.ts +110 -0
- package/src/tasks/document-question-answering/spec/input.json +85 -0
- package/src/tasks/document-question-answering/spec/output.json +36 -0
- package/src/tasks/feature-extraction/about.md +72 -0
- package/src/tasks/feature-extraction/data.ts +57 -0
- package/src/tasks/feature-extraction/inference.ts +40 -0
- package/src/tasks/feature-extraction/spec/input.json +47 -0
- package/src/tasks/feature-extraction/spec/output.json +15 -0
- package/src/tasks/fill-mask/about.md +51 -0
- package/src/tasks/fill-mask/data.ts +79 -0
- package/src/tasks/fill-mask/inference.ts +62 -0
- package/src/tasks/fill-mask/spec/input.json +38 -0
- package/src/tasks/fill-mask/spec/output.json +29 -0
- package/src/tasks/image-classification/about.md +50 -0
- package/src/tasks/image-classification/data.ts +88 -0
- package/src/tasks/image-classification/inference.ts +52 -0
- package/src/tasks/image-classification/spec/input.json +35 -0
- package/src/tasks/image-classification/spec/output.json +11 -0
- package/src/tasks/image-feature-extraction/about.md +23 -0
- package/src/tasks/image-feature-extraction/data.ts +59 -0
- package/src/tasks/image-segmentation/about.md +63 -0
- package/src/tasks/image-segmentation/data.ts +99 -0
- package/src/tasks/image-segmentation/inference.ts +69 -0
- package/src/tasks/image-segmentation/spec/input.json +45 -0
- package/src/tasks/image-segmentation/spec/output.json +26 -0
- package/src/tasks/image-text-to-text/about.md +76 -0
- package/src/tasks/image-text-to-text/data.ts +102 -0
- package/src/tasks/image-to-3d/about.md +62 -0
- package/src/tasks/image-to-3d/data.ts +75 -0
- package/src/tasks/image-to-image/about.md +129 -0
- package/src/tasks/image-to-image/data.ts +101 -0
- package/src/tasks/image-to-image/inference.ts +68 -0
- package/src/tasks/image-to-image/spec/input.json +55 -0
- package/src/tasks/image-to-image/spec/output.json +12 -0
- package/src/tasks/image-to-text/about.md +61 -0
- package/src/tasks/image-to-text/data.ts +82 -0
- package/src/tasks/image-to-text/inference.ts +143 -0
- package/src/tasks/image-to-text/spec/input.json +34 -0
- package/src/tasks/image-to-text/spec/output.json +14 -0
- package/src/tasks/index.ts +312 -0
- package/src/tasks/keypoint-detection/about.md +57 -0
- package/src/tasks/keypoint-detection/data.ts +50 -0
- package/src/tasks/mask-generation/about.md +65 -0
- package/src/tasks/mask-generation/data.ts +55 -0
- package/src/tasks/object-detection/about.md +37 -0
- package/src/tasks/object-detection/data.ts +86 -0
- package/src/tasks/object-detection/inference.ts +75 -0
- package/src/tasks/object-detection/spec/input.json +31 -0
- package/src/tasks/object-detection/spec/output.json +50 -0
- package/src/tasks/placeholder/about.md +15 -0
- package/src/tasks/placeholder/data.ts +21 -0
- package/src/tasks/placeholder/spec/input.json +35 -0
- package/src/tasks/placeholder/spec/output.json +17 -0
- package/src/tasks/question-answering/about.md +56 -0
- package/src/tasks/question-answering/data.ts +75 -0
- package/src/tasks/question-answering/inference.ts +99 -0
- package/src/tasks/question-answering/spec/input.json +67 -0
- package/src/tasks/question-answering/spec/output.json +29 -0
- package/src/tasks/reinforcement-learning/about.md +167 -0
- package/src/tasks/reinforcement-learning/data.ts +75 -0
- package/src/tasks/sentence-similarity/about.md +97 -0
- package/src/tasks/sentence-similarity/data.ts +101 -0
- package/src/tasks/sentence-similarity/inference.ts +32 -0
- package/src/tasks/sentence-similarity/spec/input.json +40 -0
- package/src/tasks/sentence-similarity/spec/output.json +12 -0
- package/src/tasks/summarization/about.md +58 -0
- package/src/tasks/summarization/data.ts +76 -0
- package/src/tasks/summarization/inference.ts +57 -0
- package/src/tasks/summarization/spec/input.json +42 -0
- package/src/tasks/summarization/spec/output.json +14 -0
- package/src/tasks/table-question-answering/about.md +43 -0
- package/src/tasks/table-question-answering/data.ts +59 -0
- package/src/tasks/table-question-answering/inference.ts +61 -0
- package/src/tasks/table-question-answering/spec/input.json +44 -0
- package/src/tasks/table-question-answering/spec/output.json +40 -0
- package/src/tasks/tabular-classification/about.md +65 -0
- package/src/tasks/tabular-classification/data.ts +68 -0
- package/src/tasks/tabular-regression/about.md +87 -0
- package/src/tasks/tabular-regression/data.ts +57 -0
- package/src/tasks/text-classification/about.md +173 -0
- package/src/tasks/text-classification/data.ts +103 -0
- package/src/tasks/text-classification/inference.ts +51 -0
- package/src/tasks/text-classification/spec/input.json +35 -0
- package/src/tasks/text-classification/spec/output.json +11 -0
- package/src/tasks/text-generation/about.md +154 -0
- package/src/tasks/text-generation/data.ts +114 -0
- package/src/tasks/text-generation/inference.ts +200 -0
- package/src/tasks/text-generation/spec/input.json +219 -0
- package/src/tasks/text-generation/spec/output.json +179 -0
- package/src/tasks/text-generation/spec/stream_output.json +103 -0
- package/src/tasks/text-to-3d/about.md +62 -0
- package/src/tasks/text-to-3d/data.ts +56 -0
- package/src/tasks/text-to-audio/inference.ts +143 -0
- package/src/tasks/text-to-audio/spec/input.json +31 -0
- package/src/tasks/text-to-audio/spec/output.json +17 -0
- package/src/tasks/text-to-image/about.md +96 -0
- package/src/tasks/text-to-image/data.ts +100 -0
- package/src/tasks/text-to-image/inference.ts +75 -0
- package/src/tasks/text-to-image/spec/input.json +63 -0
- package/src/tasks/text-to-image/spec/output.json +13 -0
- package/src/tasks/text-to-speech/about.md +63 -0
- package/src/tasks/text-to-speech/data.ts +79 -0
- package/src/tasks/text-to-speech/inference.ts +145 -0
- package/src/tasks/text-to-speech/spec/input.json +31 -0
- package/src/tasks/text-to-speech/spec/output.json +7 -0
- package/src/tasks/text-to-video/about.md +41 -0
- package/src/tasks/text-to-video/data.ts +102 -0
- package/src/tasks/text2text-generation/inference.ts +55 -0
- package/src/tasks/text2text-generation/spec/input.json +55 -0
- package/src/tasks/text2text-generation/spec/output.json +14 -0
- package/src/tasks/token-classification/about.md +76 -0
- package/src/tasks/token-classification/data.ts +92 -0
- package/src/tasks/token-classification/inference.ts +85 -0
- package/src/tasks/token-classification/spec/input.json +65 -0
- package/src/tasks/token-classification/spec/output.json +37 -0
- package/src/tasks/translation/about.md +65 -0
- package/src/tasks/translation/data.ts +70 -0
- package/src/tasks/translation/inference.ts +67 -0
- package/src/tasks/translation/spec/input.json +50 -0
- package/src/tasks/translation/spec/output.json +14 -0
- package/src/tasks/unconditional-image-generation/about.md +50 -0
- package/src/tasks/unconditional-image-generation/data.ts +72 -0
- package/src/tasks/video-classification/about.md +37 -0
- package/src/tasks/video-classification/data.ts +84 -0
- package/src/tasks/video-classification/inference.ts +59 -0
- package/src/tasks/video-classification/spec/input.json +42 -0
- package/src/tasks/video-classification/spec/output.json +10 -0
- package/src/tasks/video-text-to-text/about.md +98 -0
- package/src/tasks/video-text-to-text/data.ts +66 -0
- package/src/tasks/visual-question-answering/about.md +48 -0
- package/src/tasks/visual-question-answering/data.ts +97 -0
- package/src/tasks/visual-question-answering/inference.ts +62 -0
- package/src/tasks/visual-question-answering/spec/input.json +41 -0
- package/src/tasks/visual-question-answering/spec/output.json +21 -0
- package/src/tasks/zero-shot-classification/about.md +40 -0
- package/src/tasks/zero-shot-classification/data.ts +70 -0
- package/src/tasks/zero-shot-classification/inference.ts +67 -0
- package/src/tasks/zero-shot-classification/spec/input.json +50 -0
- package/src/tasks/zero-shot-classification/spec/output.json +11 -0
- package/src/tasks/zero-shot-image-classification/about.md +75 -0
- package/src/tasks/zero-shot-image-classification/data.ts +84 -0
- package/src/tasks/zero-shot-image-classification/inference.ts +61 -0
- package/src/tasks/zero-shot-image-classification/spec/input.json +45 -0
- package/src/tasks/zero-shot-image-classification/spec/output.json +10 -0
- package/src/tasks/zero-shot-object-detection/about.md +45 -0
- package/src/tasks/zero-shot-object-detection/data.ts +67 -0
- package/src/tasks/zero-shot-object-detection/inference.ts +66 -0
- package/src/tasks/zero-shot-object-detection/spec/input.json +40 -0
- package/src/tasks/zero-shot-object-detection/spec/output.json +47 -0
- package/src/tokenizer-data.ts +32 -0
- package/src/widget-example.ts +125 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { TaskDataCustom } from "../index.js";
|
|
2
|
+
|
|
3
|
+
const taskData: TaskDataCustom = {
|
|
4
|
+
datasets: [
|
|
5
|
+
{
|
|
6
|
+
description: "A widely used dataset useful to benchmark named entity recognition models.",
|
|
7
|
+
id: "eriktks/conll2003",
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
description:
|
|
11
|
+
"A multilingual dataset of Wikipedia articles annotated for named entity recognition in over 150 different languages.",
|
|
12
|
+
id: "unimelb-nlp/wikiann",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
demo: {
|
|
16
|
+
inputs: [
|
|
17
|
+
{
|
|
18
|
+
label: "Input",
|
|
19
|
+
content: "My name is Omar and I live in Zürich.",
|
|
20
|
+
type: "text",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
outputs: [
|
|
24
|
+
{
|
|
25
|
+
text: "My name is Omar and I live in Zürich.",
|
|
26
|
+
tokens: [
|
|
27
|
+
{
|
|
28
|
+
type: "PERSON",
|
|
29
|
+
start: 11,
|
|
30
|
+
end: 15,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
type: "GPE",
|
|
34
|
+
start: 30,
|
|
35
|
+
end: 36,
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
type: "text-with-tokens",
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
metrics: [
|
|
43
|
+
{
|
|
44
|
+
description: "",
|
|
45
|
+
id: "accuracy",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
description: "",
|
|
49
|
+
id: "recall",
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
description: "",
|
|
53
|
+
id: "precision",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
description: "",
|
|
57
|
+
id: "f1",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
models: [
|
|
61
|
+
{
|
|
62
|
+
description:
|
|
63
|
+
"A robust performance model to identify people, locations, organizations and names of miscellaneous entities.",
|
|
64
|
+
id: "dslim/bert-base-NER",
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
description: "A strong model to identify people, locations, organizations and names in multiple languages.",
|
|
68
|
+
id: "FacebookAI/xlm-roberta-large-finetuned-conll03-english",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
description: "A token classification model specialized on medical entity recognition.",
|
|
72
|
+
id: "blaze999/Medical-NER",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
description: "Flair models are typically the state of the art in named entity recognition tasks.",
|
|
76
|
+
id: "flair/ner-english",
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
spaces: [
|
|
80
|
+
{
|
|
81
|
+
description:
|
|
82
|
+
"An application that can recognizes entities, extracts noun chunks and recognizes various linguistic features of each token.",
|
|
83
|
+
id: "spacy/gradio_pipeline_visualizer",
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
summary:
|
|
87
|
+
"Token classification is a natural language understanding task in which a label is assigned to some tokens in a text. Some popular token classification subtasks are Named Entity Recognition (NER) and Part-of-Speech (PoS) tagging. NER models could be trained to identify specific entities in a text, such as dates, individuals and places; and PoS tagging would identify, for example, which words in a text are verbs, nouns, and punctuation marks.",
|
|
88
|
+
widgetModels: ["FacebookAI/xlm-roberta-large-finetuned-conll03-english"],
|
|
89
|
+
youtubeId: "wVHdVlPScxA",
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default taskData;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inference code generated from the JSON schema spec in ./spec
|
|
3
|
+
*
|
|
4
|
+
* Using src/scripts/inference-codegen
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Inputs for Token Classification inference
|
|
8
|
+
*/
|
|
9
|
+
export interface TokenClassificationInput {
|
|
10
|
+
/**
|
|
11
|
+
* The input text data
|
|
12
|
+
*/
|
|
13
|
+
inputs: string;
|
|
14
|
+
/**
|
|
15
|
+
* Additional inference parameters
|
|
16
|
+
*/
|
|
17
|
+
parameters?: TokenClassificationParameters;
|
|
18
|
+
[property: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Additional inference parameters
|
|
22
|
+
*
|
|
23
|
+
* Additional inference parameters for Token Classification
|
|
24
|
+
*/
|
|
25
|
+
export interface TokenClassificationParameters {
|
|
26
|
+
/**
|
|
27
|
+
* The strategy used to fuse tokens based on model predictions
|
|
28
|
+
*/
|
|
29
|
+
aggregation_strategy?: TokenClassificationAggregationStrategy;
|
|
30
|
+
/**
|
|
31
|
+
* A list of labels to ignore
|
|
32
|
+
*/
|
|
33
|
+
ignore_labels?: string[];
|
|
34
|
+
/**
|
|
35
|
+
* The number of overlapping tokens between chunks when splitting the input text.
|
|
36
|
+
*/
|
|
37
|
+
stride?: number;
|
|
38
|
+
[property: string]: unknown;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Do not aggregate tokens
|
|
42
|
+
*
|
|
43
|
+
* Group consecutive tokens with the same label in a single entity.
|
|
44
|
+
*
|
|
45
|
+
* Similar to "simple", also preserves word integrity (use the label predicted for the first
|
|
46
|
+
* token in a word).
|
|
47
|
+
*
|
|
48
|
+
* Similar to "simple", also preserves word integrity (uses the label with the highest
|
|
49
|
+
* score, averaged across the word's tokens).
|
|
50
|
+
*
|
|
51
|
+
* Similar to "simple", also preserves word integrity (uses the label with the highest score
|
|
52
|
+
* across the word's tokens).
|
|
53
|
+
*/
|
|
54
|
+
export type TokenClassificationAggregationStrategy = "none" | "simple" | "first" | "average" | "max";
|
|
55
|
+
export type TokenClassificationOutput = TokenClassificationOutputElement[];
|
|
56
|
+
/**
|
|
57
|
+
* Outputs of inference for the Token Classification task
|
|
58
|
+
*/
|
|
59
|
+
export interface TokenClassificationOutputElement {
|
|
60
|
+
/**
|
|
61
|
+
* The character position in the input where this group ends.
|
|
62
|
+
*/
|
|
63
|
+
end: number;
|
|
64
|
+
/**
|
|
65
|
+
* The predicted label for a single token
|
|
66
|
+
*/
|
|
67
|
+
entity?: string;
|
|
68
|
+
/**
|
|
69
|
+
* The predicted label for a group of one or more tokens
|
|
70
|
+
*/
|
|
71
|
+
entity_group?: string;
|
|
72
|
+
/**
|
|
73
|
+
* The associated score / probability
|
|
74
|
+
*/
|
|
75
|
+
score: number;
|
|
76
|
+
/**
|
|
77
|
+
* The character position in the input where this group begins.
|
|
78
|
+
*/
|
|
79
|
+
start: number;
|
|
80
|
+
/**
|
|
81
|
+
* The corresponding text
|
|
82
|
+
*/
|
|
83
|
+
word: string;
|
|
84
|
+
[property: string]: unknown;
|
|
85
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/token-classification/input.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Inputs for Token Classification inference",
|
|
5
|
+
"title": "TokenClassificationInput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"inputs": {
|
|
9
|
+
"description": "The input text data",
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"parameters": {
|
|
13
|
+
"description": "Additional inference parameters",
|
|
14
|
+
"$ref": "#/$defs/TokenClassificationParameters"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"$defs": {
|
|
18
|
+
"TokenClassificationParameters": {
|
|
19
|
+
"title": "TokenClassificationParameters",
|
|
20
|
+
"description": "Additional inference parameters for Token Classification",
|
|
21
|
+
"type": "object",
|
|
22
|
+
"properties": {
|
|
23
|
+
"ignore_labels": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"items": {
|
|
26
|
+
"type": "string"
|
|
27
|
+
},
|
|
28
|
+
"description": "A list of labels to ignore"
|
|
29
|
+
},
|
|
30
|
+
"stride": {
|
|
31
|
+
"type": "integer",
|
|
32
|
+
"description": "The number of overlapping tokens between chunks when splitting the input text."
|
|
33
|
+
},
|
|
34
|
+
"aggregation_strategy": {
|
|
35
|
+
"title": "TokenClassificationAggregationStrategy",
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "The strategy used to fuse tokens based on model predictions",
|
|
38
|
+
"oneOf": [
|
|
39
|
+
{
|
|
40
|
+
"const": "none",
|
|
41
|
+
"description": "Do not aggregate tokens"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"const": "simple",
|
|
45
|
+
"description": "Group consecutive tokens with the same label in a single entity."
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"const": "first",
|
|
49
|
+
"description": "Similar to \"simple\", also preserves word integrity (use the label predicted for the first token in a word)."
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"const": "average",
|
|
53
|
+
"description": "Similar to \"simple\", also preserves word integrity (uses the label with the highest score, averaged across the word's tokens)."
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"const": "max",
|
|
57
|
+
"description": "Similar to \"simple\", also preserves word integrity (uses the label with the highest score across the word's tokens)."
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": ["inputs"]
|
|
65
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/token-classification/output.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Outputs of inference for the Token Classification task",
|
|
5
|
+
"title": "TokenClassificationOutput",
|
|
6
|
+
"type": "array",
|
|
7
|
+
"items": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"properties": {
|
|
10
|
+
"entity_group": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"description": "The predicted label for a group of one or more tokens"
|
|
13
|
+
},
|
|
14
|
+
"entity": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "The predicted label for a single token"
|
|
17
|
+
},
|
|
18
|
+
"score": {
|
|
19
|
+
"type": "number",
|
|
20
|
+
"description": "The associated score / probability"
|
|
21
|
+
},
|
|
22
|
+
"word": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"description": "The corresponding text"
|
|
25
|
+
},
|
|
26
|
+
"start": {
|
|
27
|
+
"type": "integer",
|
|
28
|
+
"description": "The character position in the input where this group begins."
|
|
29
|
+
},
|
|
30
|
+
"end": {
|
|
31
|
+
"type": "integer",
|
|
32
|
+
"description": "The character position in the input where this group ends."
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": ["score", "word", "start", "end"]
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
## Use Cases
|
|
2
|
+
|
|
3
|
+
You can find over a thousand Translation models on the Hub, but sometimes you might not find a model for the language pair you are interested in. When this happen, you can use a pretrained multilingual Translation model like [mBART](https://huggingface.co/facebook/mbart-large-cc25) and further train it on your own data in a process called fine-tuning.
|
|
4
|
+
|
|
5
|
+
### Multilingual conversational agents
|
|
6
|
+
|
|
7
|
+
Translation models can be used to build conversational agents across different languages. This can be done in two ways.
|
|
8
|
+
|
|
9
|
+
- **Translate the dataset to a new language.** You can translate a dataset of intents (inputs) and responses to the target language. You can then train a new intent classification model with this new dataset. This allows you to proofread responses in the target language and have better control of the chatbot's outputs.
|
|
10
|
+
|
|
11
|
+
* **Translate the input and output of the agent.** You can use a Translation model in user inputs so that the chatbot can process it. You can then translate the output of the chatbot into the language of the user. This approach might be less reliable as the chatbot will generate responses that were not defined before.
|
|
12
|
+
|
|
13
|
+
## Inference
|
|
14
|
+
|
|
15
|
+
You can use the 🤗 Transformers library with the `translation_xx_to_yy` pattern where xx is the source language code and yy is the target language code. The default model for the pipeline is [t5-base](https://huggingface.co/t5-base) which under the hood adds a task prefix indicating the task itself, e.g. “translate: English to French”.
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
from transformers import pipeline
|
|
19
|
+
en_fr_translator = pipeline("translation_en_to_fr")
|
|
20
|
+
en_fr_translator("How old are you?")
|
|
21
|
+
## [{'translation_text': ' quel âge êtes-vous?'}]
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
If you’d like to use a specific model checkpoint that is from one specific language to another, you can also directly use the `translation` pipeline.
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from transformers import pipeline
|
|
28
|
+
|
|
29
|
+
model_checkpoint = "Helsinki-NLP/opus-mt-en-fr"
|
|
30
|
+
translator = pipeline("translation", model=model_checkpoint)
|
|
31
|
+
translator("How are you?")
|
|
32
|
+
# [{'translation_text': 'Comment allez-vous ?'}]
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You can use [huggingface.js](https://github.com/huggingface/huggingface.js) to infer translation models on Hugging Face Hub.
|
|
36
|
+
|
|
37
|
+
```javascript
|
|
38
|
+
import { HfInference } from "@huggingface/inference";
|
|
39
|
+
|
|
40
|
+
const inference = new HfInference(HF_TOKEN);
|
|
41
|
+
await inference.translation({
|
|
42
|
+
model: "t5-base",
|
|
43
|
+
inputs: "My name is Wolfgang and I live in Berlin",
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Useful Resources
|
|
48
|
+
|
|
49
|
+
Would you like to learn more about Translation? Great! Here you can find some curated resources that you may find helpful!
|
|
50
|
+
|
|
51
|
+
- [Course Chapter on Translation](https://huggingface.co/course/chapter7/4?fw=pt)
|
|
52
|
+
|
|
53
|
+
### Notebooks
|
|
54
|
+
|
|
55
|
+
- [PyTorch](https://github.com/huggingface/notebooks/blob/master/examples/translation.ipynb)
|
|
56
|
+
- [TensorFlow](https://github.com/huggingface/notebooks/blob/master/examples/translation-tf.ipynb)
|
|
57
|
+
|
|
58
|
+
### Scripts for training
|
|
59
|
+
|
|
60
|
+
- [PyTorch](https://github.com/huggingface/transformers/tree/main/examples/pytorch/translation)
|
|
61
|
+
- [TensorFlow](https://github.com/huggingface/transformers/tree/main/examples/tensorflow/translation)
|
|
62
|
+
|
|
63
|
+
### Documentation
|
|
64
|
+
|
|
65
|
+
- [Translation task guide](https://huggingface.co/docs/transformers/tasks/translation)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { TaskDataCustom } from "../index.js";
|
|
2
|
+
|
|
3
|
+
const taskData: TaskDataCustom = {
|
|
4
|
+
canonicalId: "text2text-generation",
|
|
5
|
+
datasets: [
|
|
6
|
+
{
|
|
7
|
+
description: "A dataset of copyright-free books translated into 16 different languages.",
|
|
8
|
+
id: "Helsinki-NLP/opus_books",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
description:
|
|
12
|
+
"An example of translation between programming languages. This dataset consists of functions in Java and C#.",
|
|
13
|
+
id: "google/code_x_glue_cc_code_to_code_trans",
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
demo: {
|
|
17
|
+
inputs: [
|
|
18
|
+
{
|
|
19
|
+
label: "Input",
|
|
20
|
+
content: "My name is Omar and I live in Zürich.",
|
|
21
|
+
type: "text",
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
outputs: [
|
|
25
|
+
{
|
|
26
|
+
label: "Output",
|
|
27
|
+
content: "Mein Name ist Omar und ich wohne in Zürich.",
|
|
28
|
+
type: "text",
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
},
|
|
32
|
+
metrics: [
|
|
33
|
+
{
|
|
34
|
+
description:
|
|
35
|
+
"BLEU score is calculated by counting the number of shared single or subsequent tokens between the generated sequence and the reference. Subsequent n tokens are called “n-grams”. Unigram refers to a single token while bi-gram refers to token pairs and n-grams refer to n subsequent tokens. The score ranges from 0 to 1, where 1 means the translation perfectly matched and 0 did not match at all",
|
|
36
|
+
id: "bleu",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
description: "",
|
|
40
|
+
id: "sacrebleu",
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
models: [
|
|
44
|
+
{
|
|
45
|
+
description:
|
|
46
|
+
"Very powerful model that can translate many languages between each other, especially low-resource languages.",
|
|
47
|
+
id: "facebook/nllb-200-1.3B",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
description:
|
|
51
|
+
"A general-purpose Transformer that can be used to translate from English to German, French, or Romanian.",
|
|
52
|
+
id: "google-t5/t5-base",
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
spaces: [
|
|
56
|
+
{
|
|
57
|
+
description: "An application that can translate between 100 languages.",
|
|
58
|
+
id: "Iker/Translate-100-languages",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
description: "An application that can translate between many languages.",
|
|
62
|
+
id: "Geonmo/nllb-translation-demo",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
summary: "Translation is the task of converting text from one language to another.",
|
|
66
|
+
widgetModels: ["facebook/mbart-large-50-many-to-many-mmt"],
|
|
67
|
+
youtubeId: "1JvfrvZgi6c",
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default taskData;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inference code generated from the JSON schema spec in ./spec
|
|
3
|
+
*
|
|
4
|
+
* Using src/scripts/inference-codegen
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Inputs for Translation inference
|
|
9
|
+
*/
|
|
10
|
+
export interface TranslationInput {
|
|
11
|
+
/**
|
|
12
|
+
* The text to translate.
|
|
13
|
+
*/
|
|
14
|
+
inputs: string;
|
|
15
|
+
/**
|
|
16
|
+
* Additional inference parameters
|
|
17
|
+
*/
|
|
18
|
+
parameters?: TranslationParameters;
|
|
19
|
+
[property: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Additional inference parameters
|
|
24
|
+
*
|
|
25
|
+
* Additional inference parameters for Translation
|
|
26
|
+
*/
|
|
27
|
+
export interface TranslationParameters {
|
|
28
|
+
/**
|
|
29
|
+
* Whether to clean up the potential extra spaces in the text output.
|
|
30
|
+
*/
|
|
31
|
+
clean_up_tokenization_spaces?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Additional parametrization of the text generation algorithm.
|
|
34
|
+
*/
|
|
35
|
+
generate_parameters?: { [key: string]: unknown };
|
|
36
|
+
/**
|
|
37
|
+
* The source language of the text. Required for models that can translate from multiple
|
|
38
|
+
* languages.
|
|
39
|
+
*/
|
|
40
|
+
src_lang?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Target language to translate to. Required for models that can translate to multiple
|
|
43
|
+
* languages.
|
|
44
|
+
*/
|
|
45
|
+
tgt_lang?: string;
|
|
46
|
+
/**
|
|
47
|
+
* The truncation strategy to use.
|
|
48
|
+
*/
|
|
49
|
+
truncation?: TranslationTruncationStrategy;
|
|
50
|
+
[property: string]: unknown;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The truncation strategy to use.
|
|
55
|
+
*/
|
|
56
|
+
export type TranslationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second";
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Outputs of inference for the Translation task
|
|
60
|
+
*/
|
|
61
|
+
export interface TranslationOutput {
|
|
62
|
+
/**
|
|
63
|
+
* The translated text.
|
|
64
|
+
*/
|
|
65
|
+
translation_text: string;
|
|
66
|
+
[property: string]: unknown;
|
|
67
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/translation/input.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Inputs for Translation inference",
|
|
5
|
+
"title": "TranslationInput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"inputs": {
|
|
9
|
+
"description": "The text to translate.",
|
|
10
|
+
"type": "string"
|
|
11
|
+
},
|
|
12
|
+
"parameters": {
|
|
13
|
+
"description": "Additional inference parameters",
|
|
14
|
+
"$ref": "#/$defs/TranslationParameters"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"$defs": {
|
|
18
|
+
"TranslationParameters": {
|
|
19
|
+
"title": "TranslationParameters",
|
|
20
|
+
"description": "Additional inference parameters for Translation",
|
|
21
|
+
"type": "object",
|
|
22
|
+
"properties": {
|
|
23
|
+
"src_lang": {
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "The source language of the text. Required for models that can translate from multiple languages."
|
|
26
|
+
},
|
|
27
|
+
"tgt_lang": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"description": "Target language to translate to. Required for models that can translate to multiple languages."
|
|
30
|
+
},
|
|
31
|
+
"clean_up_tokenization_spaces": {
|
|
32
|
+
"type": "boolean",
|
|
33
|
+
"description": "Whether to clean up the potential extra spaces in the text output."
|
|
34
|
+
},
|
|
35
|
+
"truncation": {
|
|
36
|
+
"title": "TranslationTruncationStrategy",
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "The truncation strategy to use.",
|
|
39
|
+
"enum": ["do_not_truncate", "longest_first", "only_first", "only_second"]
|
|
40
|
+
},
|
|
41
|
+
"generate_parameters": {
|
|
42
|
+
"title": "generateParameters",
|
|
43
|
+
"type": "object",
|
|
44
|
+
"description": "Additional parametrization of the text generation algorithm."
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"required": ["inputs"]
|
|
50
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/translation/output.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Outputs of inference for the Translation task",
|
|
5
|
+
"title": "TranslationOutput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"translation_text": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The translated text."
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"required": ["translation_text"]
|
|
14
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
## About the Task
|
|
2
|
+
|
|
3
|
+
Unconditional image generation is the task of generating new images without any specific input. The main goal of this is to create novel, original images that are not based on existing images.
|
|
4
|
+
This can be used for a variety of applications, such as creating new artistic images, improving image recognition algorithms, or generating photorealistic images for virtual reality environments.
|
|
5
|
+
|
|
6
|
+
Unconditional image generation models usually start with a _seed_ that generates a _random noise vector_. The model will then use this vector to create an output image similar to the images used for training the model.
|
|
7
|
+
|
|
8
|
+
An example of unconditional image generation would be generating the image of a face on a model trained with the [CelebA dataset](https://huggingface.co/datasets/huggan/CelebA-HQ) or [generating a butterfly](https://huggingface.co/spaces/huggan/butterfly-gan) on a model trained with the [Smithsonian Butterflies dataset](https://huggingface.co/datasets/ceyda/smithsonian_butterflies).
|
|
9
|
+
|
|
10
|
+
[Generative adversarial networks](https://en.wikipedia.org/wiki/Generative_adversarial_network) and [Diffusion](https://huggingface.co/docs/diffusers/index) are common architectures for this task.
|
|
11
|
+
|
|
12
|
+
## Use Cases
|
|
13
|
+
|
|
14
|
+
Unconditional image generation can be used for a variety of applications.
|
|
15
|
+
|
|
16
|
+
### Artistic Expression
|
|
17
|
+
|
|
18
|
+
Unconditional image generation can be used to create novel, original artwork that is not based on any existing images. This can be used to explore new creative possibilities and produce unique, imaginative images.
|
|
19
|
+
|
|
20
|
+
### Data Augmentation
|
|
21
|
+
|
|
22
|
+
Unconditional image generation models can be used to generate new images to improve the performance of image recognition algorithms. This makes algorithms more robust and able to handle a broader range of images.
|
|
23
|
+
|
|
24
|
+
### Virtual Reality
|
|
25
|
+
|
|
26
|
+
Unconditional image generation models can be used to create photorealistic images that can be used in virtual reality environments. This makes the VR experience more immersive and realistic.
|
|
27
|
+
|
|
28
|
+
### Medical Imaging
|
|
29
|
+
|
|
30
|
+
Unconditional image generation models can generate new medical images, such as CT or MRI scans, that can be used to train and evaluate medical imaging algorithms. This can improve the accuracy and reliability of these algorithms.
|
|
31
|
+
|
|
32
|
+
### Industrial Design
|
|
33
|
+
|
|
34
|
+
Unconditional image generation models can generate new designs for products, such as clothing or furniture, that are not based on any existing designs. This way, designers can explore new creative possibilities and produce unique, innovative designs.
|
|
35
|
+
|
|
36
|
+
## Model Hosting and Inference
|
|
37
|
+
|
|
38
|
+
This section should have useful information about Model Hosting and Inference
|
|
39
|
+
|
|
40
|
+
## Useful Resources
|
|
41
|
+
|
|
42
|
+
- [Hugging Face Diffusion Models Course](https://github.com/huggingface/diffusion-models-class)
|
|
43
|
+
- [Getting Started with Diffusers](https://huggingface.co/docs/diffusers/index)
|
|
44
|
+
- [Unconditional Image Generation Training](https://huggingface.co/docs/diffusers/training/unconditional_training)
|
|
45
|
+
|
|
46
|
+
### Training your own model in just a few seconds
|
|
47
|
+
|
|
48
|
+
In this area, you can insert useful information about training the model
|
|
49
|
+
|
|
50
|
+
This page was made possible thanks to the efforts of [Someet Sahoo](https://huggingface.co/Someet24) and [Juan Carlos Piñeros](https://huggingface.co/juancopi81).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { TaskDataCustom } from "../index.js";
|
|
2
|
+
|
|
3
|
+
const taskData: TaskDataCustom = {
|
|
4
|
+
datasets: [
|
|
5
|
+
{
|
|
6
|
+
description:
|
|
7
|
+
"The CIFAR-100 dataset consists of 60000 32x32 colour images in 100 classes, with 600 images per class.",
|
|
8
|
+
id: "cifar100",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
description: "Multiple images of celebrities, used for facial expression translation.",
|
|
12
|
+
id: "CelebA",
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
demo: {
|
|
16
|
+
inputs: [
|
|
17
|
+
{
|
|
18
|
+
label: "Seed",
|
|
19
|
+
content: "42",
|
|
20
|
+
type: "text",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: "Number of images to generate:",
|
|
24
|
+
content: "4",
|
|
25
|
+
type: "text",
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
outputs: [
|
|
29
|
+
{
|
|
30
|
+
filename: "unconditional-image-generation-output.jpeg",
|
|
31
|
+
type: "img",
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
metrics: [
|
|
36
|
+
{
|
|
37
|
+
description:
|
|
38
|
+
"The inception score (IS) evaluates the quality of generated images. It measures the diversity of the generated images (the model predictions are evenly distributed across all possible labels) and their 'distinction' or 'sharpness' (the model confidently predicts a single label for each image).",
|
|
39
|
+
id: "Inception score (IS)",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
description:
|
|
43
|
+
"The Fréchet Inception Distance (FID) evaluates the quality of images created by a generative model by calculating the distance between feature vectors for real and generated images.",
|
|
44
|
+
id: "Frećhet Inception Distance (FID)",
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
models: [
|
|
48
|
+
{
|
|
49
|
+
description:
|
|
50
|
+
"High-quality image generation model trained on the CIFAR-10 dataset. It synthesizes images of the ten classes presented in the dataset using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics.",
|
|
51
|
+
id: "google/ddpm-cifar10-32",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
description:
|
|
55
|
+
"High-quality image generation model trained on the 256x256 CelebA-HQ dataset. It synthesizes images of faces using diffusion probabilistic models, a class of latent variable models inspired by considerations from nonequilibrium thermodynamics.",
|
|
56
|
+
id: "google/ddpm-celebahq-256",
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
spaces: [
|
|
60
|
+
{
|
|
61
|
+
description: "An application that can generate realistic faces.",
|
|
62
|
+
id: "CompVis/celeba-latent-diffusion",
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
summary:
|
|
66
|
+
"Unconditional image generation is the task of generating images with no condition in any context (like a prompt text or another image). Once trained, the model will create images that resemble its training data distribution.",
|
|
67
|
+
widgetModels: [""],
|
|
68
|
+
// TODO: Add related video
|
|
69
|
+
youtubeId: "",
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default taskData;
|