@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,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inference code generated from the JSON schema spec in ./spec
|
|
3
|
+
*
|
|
4
|
+
* Using src/scripts/inference-codegen
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Text Generation Input.
|
|
9
|
+
*
|
|
10
|
+
* Auto-generated from TGI specs.
|
|
11
|
+
* For more details, check out
|
|
12
|
+
* https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
|
|
13
|
+
*/
|
|
14
|
+
export interface TextGenerationInput {
|
|
15
|
+
inputs: string;
|
|
16
|
+
parameters?: TextGenerationInputGenerateParameters;
|
|
17
|
+
stream?: boolean;
|
|
18
|
+
[property: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface TextGenerationInputGenerateParameters {
|
|
22
|
+
/**
|
|
23
|
+
* Lora adapter id
|
|
24
|
+
*/
|
|
25
|
+
adapter_id?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Generate best_of sequences and return the one if the highest token logprobs.
|
|
28
|
+
*/
|
|
29
|
+
best_of?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to return decoder input token logprobs and ids.
|
|
32
|
+
*/
|
|
33
|
+
decoder_input_details?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to return generation details.
|
|
36
|
+
*/
|
|
37
|
+
details?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Activate logits sampling.
|
|
40
|
+
*/
|
|
41
|
+
do_sample?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The parameter for frequency penalty. 1.0 means no penalty
|
|
44
|
+
* Penalize new tokens based on their existing frequency in the text so far,
|
|
45
|
+
* decreasing the model's likelihood to repeat the same line verbatim.
|
|
46
|
+
*/
|
|
47
|
+
frequency_penalty?: number;
|
|
48
|
+
grammar?: TextGenerationInputGrammarType;
|
|
49
|
+
/**
|
|
50
|
+
* Maximum number of tokens to generate.
|
|
51
|
+
*/
|
|
52
|
+
max_new_tokens?: number;
|
|
53
|
+
/**
|
|
54
|
+
* The parameter for repetition penalty. 1.0 means no penalty.
|
|
55
|
+
* See [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details.
|
|
56
|
+
*/
|
|
57
|
+
repetition_penalty?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Whether to prepend the prompt to the generated text
|
|
60
|
+
*/
|
|
61
|
+
return_full_text?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Random sampling seed.
|
|
64
|
+
*/
|
|
65
|
+
seed?: number;
|
|
66
|
+
/**
|
|
67
|
+
* Stop generating tokens if a member of `stop` is generated.
|
|
68
|
+
*/
|
|
69
|
+
stop?: string[];
|
|
70
|
+
/**
|
|
71
|
+
* The value used to module the logits distribution.
|
|
72
|
+
*/
|
|
73
|
+
temperature?: number;
|
|
74
|
+
/**
|
|
75
|
+
* The number of highest probability vocabulary tokens to keep for top-k-filtering.
|
|
76
|
+
*/
|
|
77
|
+
top_k?: number;
|
|
78
|
+
/**
|
|
79
|
+
* The number of highest probability vocabulary tokens to keep for top-n-filtering.
|
|
80
|
+
*/
|
|
81
|
+
top_n_tokens?: number;
|
|
82
|
+
/**
|
|
83
|
+
* Top-p value for nucleus sampling.
|
|
84
|
+
*/
|
|
85
|
+
top_p?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Truncate inputs tokens to the given size.
|
|
88
|
+
*/
|
|
89
|
+
truncate?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Typical Decoding mass
|
|
92
|
+
* See [Typical Decoding for Natural Language Generation](https://arxiv.org/abs/2202.00666)
|
|
93
|
+
* for more information.
|
|
94
|
+
*/
|
|
95
|
+
typical_p?: number;
|
|
96
|
+
/**
|
|
97
|
+
* Watermarking with [A Watermark for Large Language
|
|
98
|
+
* Models](https://arxiv.org/abs/2301.10226).
|
|
99
|
+
*/
|
|
100
|
+
watermark?: boolean;
|
|
101
|
+
[property: string]: unknown;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface TextGenerationInputGrammarType {
|
|
105
|
+
type: Type;
|
|
106
|
+
/**
|
|
107
|
+
* A string that represents a [JSON Schema](https://json-schema.org/).
|
|
108
|
+
*
|
|
109
|
+
* JSON Schema is a declarative language that allows to annotate JSON documents
|
|
110
|
+
* with types and descriptions.
|
|
111
|
+
*/
|
|
112
|
+
value: unknown;
|
|
113
|
+
[property: string]: unknown;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type Type = "json" | "regex";
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Text Generation Output.
|
|
120
|
+
*
|
|
121
|
+
* Auto-generated from TGI specs.
|
|
122
|
+
* For more details, check out
|
|
123
|
+
* https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
|
|
124
|
+
*/
|
|
125
|
+
export interface TextGenerationOutput {
|
|
126
|
+
details?: TextGenerationOutputDetails;
|
|
127
|
+
generated_text: string;
|
|
128
|
+
[property: string]: unknown;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface TextGenerationOutputDetails {
|
|
132
|
+
best_of_sequences?: TextGenerationOutputBestOfSequence[];
|
|
133
|
+
finish_reason: TextGenerationOutputFinishReason;
|
|
134
|
+
generated_tokens: number;
|
|
135
|
+
prefill: TextGenerationOutputPrefillToken[];
|
|
136
|
+
seed?: number;
|
|
137
|
+
tokens: TextGenerationOutputToken[];
|
|
138
|
+
top_tokens?: Array<TextGenerationOutputToken[]>;
|
|
139
|
+
[property: string]: unknown;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface TextGenerationOutputBestOfSequence {
|
|
143
|
+
finish_reason: TextGenerationOutputFinishReason;
|
|
144
|
+
generated_text: string;
|
|
145
|
+
generated_tokens: number;
|
|
146
|
+
prefill: TextGenerationOutputPrefillToken[];
|
|
147
|
+
seed?: number;
|
|
148
|
+
tokens: TextGenerationOutputToken[];
|
|
149
|
+
top_tokens?: Array<TextGenerationOutputToken[]>;
|
|
150
|
+
[property: string]: unknown;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export type TextGenerationOutputFinishReason = "length" | "eos_token" | "stop_sequence";
|
|
154
|
+
|
|
155
|
+
export interface TextGenerationOutputPrefillToken {
|
|
156
|
+
id: number;
|
|
157
|
+
logprob: number;
|
|
158
|
+
text: string;
|
|
159
|
+
[property: string]: unknown;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface TextGenerationOutputToken {
|
|
163
|
+
id: number;
|
|
164
|
+
logprob: number;
|
|
165
|
+
special: boolean;
|
|
166
|
+
text: string;
|
|
167
|
+
[property: string]: unknown;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Text Generation Stream Output.
|
|
172
|
+
*
|
|
173
|
+
* Auto-generated from TGI specs.
|
|
174
|
+
* For more details, check out
|
|
175
|
+
* https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
|
|
176
|
+
*/
|
|
177
|
+
export interface TextGenerationStreamOutput {
|
|
178
|
+
details?: TextGenerationStreamOutputStreamDetails;
|
|
179
|
+
generated_text?: string;
|
|
180
|
+
index: number;
|
|
181
|
+
token: TextGenerationStreamOutputToken;
|
|
182
|
+
top_tokens?: TextGenerationStreamOutputToken[];
|
|
183
|
+
[property: string]: unknown;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface TextGenerationStreamOutputStreamDetails {
|
|
187
|
+
finish_reason: TextGenerationOutputFinishReason;
|
|
188
|
+
generated_tokens: number;
|
|
189
|
+
input_length: number;
|
|
190
|
+
seed?: number;
|
|
191
|
+
[property: string]: unknown;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface TextGenerationStreamOutputToken {
|
|
195
|
+
id: number;
|
|
196
|
+
logprob: number;
|
|
197
|
+
special: boolean;
|
|
198
|
+
text: string;
|
|
199
|
+
[property: string]: unknown;
|
|
200
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/text-generation/input.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Text Generation Input.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.",
|
|
5
|
+
"title": "TextGenerationInput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["inputs"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"inputs": {
|
|
10
|
+
"type": "string",
|
|
11
|
+
"example": "My name is Olivier and I"
|
|
12
|
+
},
|
|
13
|
+
"parameters": {
|
|
14
|
+
"$ref": "#/$defs/TextGenerationInputGenerateParameters"
|
|
15
|
+
},
|
|
16
|
+
"stream": {
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"default": "false"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"$defs": {
|
|
22
|
+
"TextGenerationInputGenerateParameters": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"properties": {
|
|
25
|
+
"adapter_id": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "Lora adapter id",
|
|
28
|
+
"default": "null",
|
|
29
|
+
"example": "null",
|
|
30
|
+
"nullable": true
|
|
31
|
+
},
|
|
32
|
+
"best_of": {
|
|
33
|
+
"type": "integer",
|
|
34
|
+
"description": "Generate best_of sequences and return the one if the highest token logprobs.",
|
|
35
|
+
"default": "null",
|
|
36
|
+
"example": 1,
|
|
37
|
+
"nullable": true,
|
|
38
|
+
"minimum": 0,
|
|
39
|
+
"exclusiveMinimum": 0
|
|
40
|
+
},
|
|
41
|
+
"decoder_input_details": {
|
|
42
|
+
"type": "boolean",
|
|
43
|
+
"description": "Whether to return decoder input token logprobs and ids.",
|
|
44
|
+
"default": "false"
|
|
45
|
+
},
|
|
46
|
+
"details": {
|
|
47
|
+
"type": "boolean",
|
|
48
|
+
"description": "Whether to return generation details.",
|
|
49
|
+
"default": "true"
|
|
50
|
+
},
|
|
51
|
+
"do_sample": {
|
|
52
|
+
"type": "boolean",
|
|
53
|
+
"description": "Activate logits sampling.",
|
|
54
|
+
"default": "false",
|
|
55
|
+
"example": true
|
|
56
|
+
},
|
|
57
|
+
"frequency_penalty": {
|
|
58
|
+
"type": "number",
|
|
59
|
+
"format": "float",
|
|
60
|
+
"description": "The parameter for frequency penalty. 1.0 means no penalty\nPenalize new tokens based on their existing frequency in the text so far,\ndecreasing the model's likelihood to repeat the same line verbatim.",
|
|
61
|
+
"default": "null",
|
|
62
|
+
"example": 0.1,
|
|
63
|
+
"nullable": true,
|
|
64
|
+
"exclusiveMinimum": -2
|
|
65
|
+
},
|
|
66
|
+
"grammar": {
|
|
67
|
+
"allOf": [
|
|
68
|
+
{
|
|
69
|
+
"$ref": "#/$defs/TextGenerationInputGrammarType"
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
"default": "null",
|
|
73
|
+
"nullable": true
|
|
74
|
+
},
|
|
75
|
+
"max_new_tokens": {
|
|
76
|
+
"type": "integer",
|
|
77
|
+
"format": "int32",
|
|
78
|
+
"description": "Maximum number of tokens to generate.",
|
|
79
|
+
"default": "100",
|
|
80
|
+
"example": "20",
|
|
81
|
+
"nullable": true,
|
|
82
|
+
"minimum": 0
|
|
83
|
+
},
|
|
84
|
+
"repetition_penalty": {
|
|
85
|
+
"type": "number",
|
|
86
|
+
"format": "float",
|
|
87
|
+
"description": "The parameter for repetition penalty. 1.0 means no penalty.\nSee [this paper](https://arxiv.org/pdf/1909.05858.pdf) for more details.",
|
|
88
|
+
"default": "null",
|
|
89
|
+
"example": 1.03,
|
|
90
|
+
"nullable": true,
|
|
91
|
+
"exclusiveMinimum": 0
|
|
92
|
+
},
|
|
93
|
+
"return_full_text": {
|
|
94
|
+
"type": "boolean",
|
|
95
|
+
"description": "Whether to prepend the prompt to the generated text",
|
|
96
|
+
"default": "null",
|
|
97
|
+
"example": false,
|
|
98
|
+
"nullable": true
|
|
99
|
+
},
|
|
100
|
+
"seed": {
|
|
101
|
+
"type": "integer",
|
|
102
|
+
"format": "int64",
|
|
103
|
+
"description": "Random sampling seed.",
|
|
104
|
+
"default": "null",
|
|
105
|
+
"example": "null",
|
|
106
|
+
"nullable": true,
|
|
107
|
+
"minimum": 0,
|
|
108
|
+
"exclusiveMinimum": 0
|
|
109
|
+
},
|
|
110
|
+
"stop": {
|
|
111
|
+
"type": "array",
|
|
112
|
+
"items": {
|
|
113
|
+
"type": "string"
|
|
114
|
+
},
|
|
115
|
+
"description": "Stop generating tokens if a member of `stop` is generated.",
|
|
116
|
+
"example": ["photographer"],
|
|
117
|
+
"maxItems": 4
|
|
118
|
+
},
|
|
119
|
+
"temperature": {
|
|
120
|
+
"type": "number",
|
|
121
|
+
"format": "float",
|
|
122
|
+
"description": "The value used to module the logits distribution.",
|
|
123
|
+
"default": "null",
|
|
124
|
+
"example": 0.5,
|
|
125
|
+
"nullable": true,
|
|
126
|
+
"exclusiveMinimum": 0
|
|
127
|
+
},
|
|
128
|
+
"top_k": {
|
|
129
|
+
"type": "integer",
|
|
130
|
+
"format": "int32",
|
|
131
|
+
"description": "The number of highest probability vocabulary tokens to keep for top-k-filtering.",
|
|
132
|
+
"default": "null",
|
|
133
|
+
"example": 10,
|
|
134
|
+
"nullable": true,
|
|
135
|
+
"exclusiveMinimum": 0
|
|
136
|
+
},
|
|
137
|
+
"top_n_tokens": {
|
|
138
|
+
"type": "integer",
|
|
139
|
+
"format": "int32",
|
|
140
|
+
"description": "The number of highest probability vocabulary tokens to keep for top-n-filtering.",
|
|
141
|
+
"default": "null",
|
|
142
|
+
"example": 5,
|
|
143
|
+
"nullable": true,
|
|
144
|
+
"minimum": 0,
|
|
145
|
+
"exclusiveMinimum": 0
|
|
146
|
+
},
|
|
147
|
+
"top_p": {
|
|
148
|
+
"type": "number",
|
|
149
|
+
"format": "float",
|
|
150
|
+
"description": "Top-p value for nucleus sampling.",
|
|
151
|
+
"default": "null",
|
|
152
|
+
"example": 0.95,
|
|
153
|
+
"nullable": true,
|
|
154
|
+
"maximum": 1,
|
|
155
|
+
"exclusiveMinimum": 0
|
|
156
|
+
},
|
|
157
|
+
"truncate": {
|
|
158
|
+
"type": "integer",
|
|
159
|
+
"description": "Truncate inputs tokens to the given size.",
|
|
160
|
+
"default": "null",
|
|
161
|
+
"example": "null",
|
|
162
|
+
"nullable": true,
|
|
163
|
+
"minimum": 0
|
|
164
|
+
},
|
|
165
|
+
"typical_p": {
|
|
166
|
+
"type": "number",
|
|
167
|
+
"format": "float",
|
|
168
|
+
"description": "Typical Decoding mass\nSee [Typical Decoding for Natural Language Generation](https://arxiv.org/abs/2202.00666) for more information.",
|
|
169
|
+
"default": "null",
|
|
170
|
+
"example": 0.95,
|
|
171
|
+
"nullable": true,
|
|
172
|
+
"maximum": 1,
|
|
173
|
+
"exclusiveMinimum": 0
|
|
174
|
+
},
|
|
175
|
+
"watermark": {
|
|
176
|
+
"type": "boolean",
|
|
177
|
+
"description": "Watermarking with [A Watermark for Large Language Models](https://arxiv.org/abs/2301.10226).",
|
|
178
|
+
"default": "false",
|
|
179
|
+
"example": true
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
"title": "TextGenerationInputGenerateParameters"
|
|
183
|
+
},
|
|
184
|
+
"TextGenerationInputGrammarType": {
|
|
185
|
+
"oneOf": [
|
|
186
|
+
{
|
|
187
|
+
"type": "object",
|
|
188
|
+
"required": ["type", "value"],
|
|
189
|
+
"properties": {
|
|
190
|
+
"type": {
|
|
191
|
+
"type": "string",
|
|
192
|
+
"enum": ["json"]
|
|
193
|
+
},
|
|
194
|
+
"value": {
|
|
195
|
+
"description": "A string that represents a [JSON Schema](https://json-schema.org/).\n\nJSON Schema is a declarative language that allows to annotate JSON documents\nwith types and descriptions."
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
"type": "object",
|
|
201
|
+
"required": ["type", "value"],
|
|
202
|
+
"properties": {
|
|
203
|
+
"type": {
|
|
204
|
+
"type": "string",
|
|
205
|
+
"enum": ["regex"]
|
|
206
|
+
},
|
|
207
|
+
"value": {
|
|
208
|
+
"type": "string"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
],
|
|
213
|
+
"discriminator": {
|
|
214
|
+
"propertyName": "type"
|
|
215
|
+
},
|
|
216
|
+
"title": "TextGenerationInputGrammarType"
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/text-generation/output.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Text Generation Output.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.",
|
|
5
|
+
"title": "TextGenerationOutput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["generated_text"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"details": {
|
|
10
|
+
"allOf": [
|
|
11
|
+
{
|
|
12
|
+
"$ref": "#/$defs/TextGenerationOutputDetails"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"nullable": true
|
|
16
|
+
},
|
|
17
|
+
"generated_text": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"example": "test"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"$defs": {
|
|
23
|
+
"TextGenerationOutputDetails": {
|
|
24
|
+
"type": "object",
|
|
25
|
+
"required": ["finish_reason", "generated_tokens", "prefill", "tokens"],
|
|
26
|
+
"properties": {
|
|
27
|
+
"best_of_sequences": {
|
|
28
|
+
"type": "array",
|
|
29
|
+
"items": {
|
|
30
|
+
"$ref": "#/$defs/TextGenerationOutputBestOfSequence"
|
|
31
|
+
},
|
|
32
|
+
"nullable": true
|
|
33
|
+
},
|
|
34
|
+
"finish_reason": {
|
|
35
|
+
"$ref": "#/$defs/TextGenerationOutputFinishReason"
|
|
36
|
+
},
|
|
37
|
+
"generated_tokens": {
|
|
38
|
+
"type": "integer",
|
|
39
|
+
"format": "int32",
|
|
40
|
+
"example": 1,
|
|
41
|
+
"minimum": 0
|
|
42
|
+
},
|
|
43
|
+
"prefill": {
|
|
44
|
+
"type": "array",
|
|
45
|
+
"items": {
|
|
46
|
+
"$ref": "#/$defs/TextGenerationOutputPrefillToken"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"seed": {
|
|
50
|
+
"type": "integer",
|
|
51
|
+
"format": "int64",
|
|
52
|
+
"example": 42,
|
|
53
|
+
"nullable": true,
|
|
54
|
+
"minimum": 0
|
|
55
|
+
},
|
|
56
|
+
"tokens": {
|
|
57
|
+
"type": "array",
|
|
58
|
+
"items": {
|
|
59
|
+
"$ref": "#/$defs/TextGenerationOutputToken"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"top_tokens": {
|
|
63
|
+
"type": "array",
|
|
64
|
+
"items": {
|
|
65
|
+
"type": "array",
|
|
66
|
+
"items": {
|
|
67
|
+
"$ref": "#/$defs/TextGenerationOutputToken"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"title": "TextGenerationOutputDetails"
|
|
73
|
+
},
|
|
74
|
+
"TextGenerationOutputBestOfSequence": {
|
|
75
|
+
"type": "object",
|
|
76
|
+
"required": ["generated_text", "finish_reason", "generated_tokens", "prefill", "tokens"],
|
|
77
|
+
"properties": {
|
|
78
|
+
"finish_reason": {
|
|
79
|
+
"$ref": "#/$defs/TextGenerationOutputFinishReason"
|
|
80
|
+
},
|
|
81
|
+
"generated_text": {
|
|
82
|
+
"type": "string",
|
|
83
|
+
"example": "test"
|
|
84
|
+
},
|
|
85
|
+
"generated_tokens": {
|
|
86
|
+
"type": "integer",
|
|
87
|
+
"format": "int32",
|
|
88
|
+
"example": 1,
|
|
89
|
+
"minimum": 0
|
|
90
|
+
},
|
|
91
|
+
"prefill": {
|
|
92
|
+
"type": "array",
|
|
93
|
+
"items": {
|
|
94
|
+
"$ref": "#/$defs/TextGenerationOutputPrefillToken"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"seed": {
|
|
98
|
+
"type": "integer",
|
|
99
|
+
"format": "int64",
|
|
100
|
+
"example": 42,
|
|
101
|
+
"nullable": true,
|
|
102
|
+
"minimum": 0
|
|
103
|
+
},
|
|
104
|
+
"tokens": {
|
|
105
|
+
"type": "array",
|
|
106
|
+
"items": {
|
|
107
|
+
"$ref": "#/$defs/TextGenerationOutputToken"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
"top_tokens": {
|
|
111
|
+
"type": "array",
|
|
112
|
+
"items": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"items": {
|
|
115
|
+
"$ref": "#/$defs/TextGenerationOutputToken"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
"title": "TextGenerationOutputBestOfSequence"
|
|
121
|
+
},
|
|
122
|
+
"TextGenerationOutputFinishReason": {
|
|
123
|
+
"type": "string",
|
|
124
|
+
"enum": ["length", "eos_token", "stop_sequence"],
|
|
125
|
+
"example": "Length",
|
|
126
|
+
"title": "TextGenerationOutputFinishReason"
|
|
127
|
+
},
|
|
128
|
+
"TextGenerationOutputPrefillToken": {
|
|
129
|
+
"type": "object",
|
|
130
|
+
"required": ["id", "text", "logprob"],
|
|
131
|
+
"properties": {
|
|
132
|
+
"id": {
|
|
133
|
+
"type": "integer",
|
|
134
|
+
"format": "int32",
|
|
135
|
+
"example": 0,
|
|
136
|
+
"minimum": 0
|
|
137
|
+
},
|
|
138
|
+
"logprob": {
|
|
139
|
+
"type": "number",
|
|
140
|
+
"format": "float",
|
|
141
|
+
"example": -0.34,
|
|
142
|
+
"nullable": true
|
|
143
|
+
},
|
|
144
|
+
"text": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"example": "test"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"title": "TextGenerationOutputPrefillToken"
|
|
150
|
+
},
|
|
151
|
+
"TextGenerationOutputToken": {
|
|
152
|
+
"type": "object",
|
|
153
|
+
"required": ["id", "text", "logprob", "special"],
|
|
154
|
+
"properties": {
|
|
155
|
+
"id": {
|
|
156
|
+
"type": "integer",
|
|
157
|
+
"format": "int32",
|
|
158
|
+
"example": 0,
|
|
159
|
+
"minimum": 0
|
|
160
|
+
},
|
|
161
|
+
"logprob": {
|
|
162
|
+
"type": "number",
|
|
163
|
+
"format": "float",
|
|
164
|
+
"example": -0.34,
|
|
165
|
+
"nullable": true
|
|
166
|
+
},
|
|
167
|
+
"special": {
|
|
168
|
+
"type": "boolean",
|
|
169
|
+
"example": "false"
|
|
170
|
+
},
|
|
171
|
+
"text": {
|
|
172
|
+
"type": "string",
|
|
173
|
+
"example": "test"
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"title": "TextGenerationOutputToken"
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "/inference/schemas/text-generation/stream_output.json",
|
|
3
|
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
+
"description": "Text Generation Stream Output.\n\nAuto-generated from TGI specs.\nFor more details, check out https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.",
|
|
5
|
+
"title": "TextGenerationStreamOutput",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["index", "token"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"details": {
|
|
10
|
+
"allOf": [
|
|
11
|
+
{
|
|
12
|
+
"$ref": "#/$defs/TextGenerationStreamOutputStreamDetails"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"default": "null",
|
|
16
|
+
"nullable": true
|
|
17
|
+
},
|
|
18
|
+
"generated_text": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"default": "null",
|
|
21
|
+
"example": "test",
|
|
22
|
+
"nullable": true
|
|
23
|
+
},
|
|
24
|
+
"index": {
|
|
25
|
+
"type": "integer",
|
|
26
|
+
"format": "int32",
|
|
27
|
+
"minimum": 0
|
|
28
|
+
},
|
|
29
|
+
"token": {
|
|
30
|
+
"$ref": "#/$defs/TextGenerationStreamOutputToken"
|
|
31
|
+
},
|
|
32
|
+
"top_tokens": {
|
|
33
|
+
"type": "array",
|
|
34
|
+
"items": {
|
|
35
|
+
"$ref": "#/$defs/TextGenerationStreamOutputToken"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"$defs": {
|
|
40
|
+
"TextGenerationStreamOutputStreamDetails": {
|
|
41
|
+
"type": "object",
|
|
42
|
+
"required": ["finish_reason", "generated_tokens", "input_length"],
|
|
43
|
+
"properties": {
|
|
44
|
+
"finish_reason": {
|
|
45
|
+
"$ref": "#/$defs/TextGenerationStreamOutputFinishReason"
|
|
46
|
+
},
|
|
47
|
+
"generated_tokens": {
|
|
48
|
+
"type": "integer",
|
|
49
|
+
"format": "int32",
|
|
50
|
+
"example": 1,
|
|
51
|
+
"minimum": 0
|
|
52
|
+
},
|
|
53
|
+
"input_length": {
|
|
54
|
+
"type": "integer",
|
|
55
|
+
"format": "int32",
|
|
56
|
+
"example": 1,
|
|
57
|
+
"minimum": 0
|
|
58
|
+
},
|
|
59
|
+
"seed": {
|
|
60
|
+
"type": "integer",
|
|
61
|
+
"format": "int64",
|
|
62
|
+
"example": 42,
|
|
63
|
+
"nullable": true,
|
|
64
|
+
"minimum": 0
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
"title": "TextGenerationStreamOutputStreamDetails"
|
|
68
|
+
},
|
|
69
|
+
"TextGenerationStreamOutputFinishReason": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"enum": ["length", "eos_token", "stop_sequence"],
|
|
72
|
+
"example": "Length",
|
|
73
|
+
"title": "TextGenerationStreamOutputFinishReason"
|
|
74
|
+
},
|
|
75
|
+
"TextGenerationStreamOutputToken": {
|
|
76
|
+
"type": "object",
|
|
77
|
+
"required": ["id", "text", "logprob", "special"],
|
|
78
|
+
"properties": {
|
|
79
|
+
"id": {
|
|
80
|
+
"type": "integer",
|
|
81
|
+
"format": "int32",
|
|
82
|
+
"example": 0,
|
|
83
|
+
"minimum": 0
|
|
84
|
+
},
|
|
85
|
+
"logprob": {
|
|
86
|
+
"type": "number",
|
|
87
|
+
"format": "float",
|
|
88
|
+
"example": -0.34,
|
|
89
|
+
"nullable": true
|
|
90
|
+
},
|
|
91
|
+
"special": {
|
|
92
|
+
"type": "boolean",
|
|
93
|
+
"example": "false"
|
|
94
|
+
},
|
|
95
|
+
"text": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"example": "test"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"title": "TextGenerationStreamOutputToken"
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|