@huggingface/tasks 0.9.1 → 0.10.1
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/README.md +12 -14
- package/dist/index.cjs +91 -18
- package/dist/index.js +90 -18
- package/dist/scripts/inference-codegen.d.ts +2 -0
- package/dist/scripts/inference-codegen.d.ts.map +1 -0
- package/dist/scripts/inference-tgi-import.d.ts +2 -0
- package/dist/scripts/inference-tgi-import.d.ts.map +1 -0
- package/dist/src/default-widget-inputs.d.ts +6 -0
- package/dist/src/default-widget-inputs.d.ts.map +1 -0
- package/dist/src/index.d.ts +17 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/library-to-tasks.d.ts +11 -0
- package/dist/src/library-to-tasks.d.ts.map +1 -0
- package/dist/src/local-apps.d.ts +104 -0
- package/dist/src/local-apps.d.ts.map +1 -0
- package/dist/src/model-data.d.ts +144 -0
- package/dist/src/model-data.d.ts.map +1 -0
- package/dist/src/model-libraries-downloads.d.ts +26 -0
- package/dist/src/model-libraries-downloads.d.ts.map +1 -0
- package/dist/src/model-libraries-snippets.d.ts +43 -0
- package/dist/src/model-libraries-snippets.d.ts.map +1 -0
- package/dist/src/model-libraries.d.ts +501 -0
- package/dist/src/model-libraries.d.ts.map +1 -0
- package/dist/src/pipelines.d.ts +404 -0
- package/dist/src/pipelines.d.ts.map +1 -0
- package/dist/src/snippets/curl.d.ts +9 -0
- package/dist/src/snippets/curl.d.ts.map +1 -0
- package/dist/src/snippets/index.d.ts +6 -0
- package/dist/src/snippets/index.d.ts.map +1 -0
- package/dist/src/snippets/inputs.d.ts +3 -0
- package/dist/src/snippets/inputs.d.ts.map +1 -0
- package/dist/src/snippets/js.d.ts +11 -0
- package/dist/src/snippets/js.d.ts.map +1 -0
- package/dist/src/snippets/python.d.ts +14 -0
- package/dist/src/snippets/python.d.ts.map +1 -0
- package/dist/src/snippets/types.d.ts +8 -0
- package/dist/src/snippets/types.d.ts.map +1 -0
- package/dist/src/tasks/audio-classification/data.d.ts +4 -0
- package/dist/src/tasks/audio-classification/data.d.ts.map +1 -0
- package/dist/src/tasks/audio-classification/inference.d.ts +52 -0
- package/dist/src/tasks/audio-classification/inference.d.ts.map +1 -0
- package/dist/src/tasks/audio-to-audio/data.d.ts +4 -0
- package/dist/src/tasks/audio-to-audio/data.d.ts.map +1 -0
- package/dist/src/tasks/automatic-speech-recognition/data.d.ts +4 -0
- package/dist/src/tasks/automatic-speech-recognition/data.d.ts.map +1 -0
- package/dist/src/tasks/automatic-speech-recognition/inference.d.ts +154 -0
- package/dist/src/tasks/automatic-speech-recognition/inference.d.ts.map +1 -0
- package/dist/src/tasks/chat-completion/inference.d.ts +254 -0
- package/dist/src/tasks/chat-completion/inference.d.ts.map +1 -0
- package/dist/src/tasks/depth-estimation/data.d.ts +4 -0
- package/dist/src/tasks/depth-estimation/data.d.ts.map +1 -0
- package/dist/src/tasks/depth-estimation/inference.d.ts +36 -0
- package/dist/src/tasks/depth-estimation/inference.d.ts.map +1 -0
- package/dist/src/tasks/document-question-answering/data.d.ts +4 -0
- package/dist/src/tasks/document-question-answering/data.d.ts.map +1 -0
- package/dist/src/tasks/document-question-answering/inference.d.ts +111 -0
- package/dist/src/tasks/document-question-answering/inference.d.ts.map +1 -0
- package/dist/src/tasks/feature-extraction/data.d.ts +4 -0
- package/dist/src/tasks/feature-extraction/data.d.ts.map +1 -0
- package/dist/src/tasks/feature-extraction/inference.d.ts +23 -0
- package/dist/src/tasks/feature-extraction/inference.d.ts.map +1 -0
- package/dist/src/tasks/fill-mask/data.d.ts +4 -0
- package/dist/src/tasks/fill-mask/data.d.ts.map +1 -0
- package/dist/src/tasks/fill-mask/inference.d.ts +63 -0
- package/dist/src/tasks/fill-mask/inference.d.ts.map +1 -0
- package/dist/src/tasks/image-classification/data.d.ts +4 -0
- package/dist/src/tasks/image-classification/data.d.ts.map +1 -0
- package/dist/src/tasks/image-classification/inference.d.ts +52 -0
- package/dist/src/tasks/image-classification/inference.d.ts.map +1 -0
- package/dist/src/tasks/image-feature-extraction/data.d.ts +4 -0
- package/dist/src/tasks/image-feature-extraction/data.d.ts.map +1 -0
- package/dist/src/tasks/image-segmentation/data.d.ts +4 -0
- package/dist/src/tasks/image-segmentation/data.d.ts.map +1 -0
- package/dist/src/tasks/image-segmentation/inference.d.ts +66 -0
- package/dist/src/tasks/image-segmentation/inference.d.ts.map +1 -0
- package/dist/src/tasks/image-to-image/data.d.ts +4 -0
- package/dist/src/tasks/image-to-image/data.d.ts.map +1 -0
- package/dist/src/tasks/image-to-image/inference.d.ts +64 -0
- package/dist/src/tasks/image-to-image/inference.d.ts.map +1 -0
- package/dist/src/tasks/image-to-text/data.d.ts +4 -0
- package/dist/src/tasks/image-to-text/data.d.ts.map +1 -0
- package/dist/src/tasks/image-to-text/inference.d.ts +139 -0
- package/dist/src/tasks/image-to-text/inference.d.ts.map +1 -0
- package/dist/src/tasks/index.d.ts +87 -0
- package/dist/src/tasks/index.d.ts.map +1 -0
- package/dist/src/tasks/mask-generation/data.d.ts +4 -0
- package/dist/src/tasks/mask-generation/data.d.ts.map +1 -0
- package/dist/src/tasks/object-detection/data.d.ts +4 -0
- package/dist/src/tasks/object-detection/data.d.ts.map +1 -0
- package/dist/src/tasks/object-detection/inference.d.ts +63 -0
- package/dist/src/tasks/object-detection/inference.d.ts.map +1 -0
- package/dist/src/tasks/placeholder/data.d.ts +4 -0
- package/dist/src/tasks/placeholder/data.d.ts.map +1 -0
- package/dist/src/tasks/question-answering/data.d.ts +4 -0
- package/dist/src/tasks/question-answering/data.d.ts.map +1 -0
- package/dist/src/tasks/question-answering/inference.d.ts +100 -0
- package/dist/src/tasks/question-answering/inference.d.ts.map +1 -0
- package/dist/src/tasks/reinforcement-learning/data.d.ts +4 -0
- package/dist/src/tasks/reinforcement-learning/data.d.ts.map +1 -0
- package/dist/src/tasks/sentence-similarity/data.d.ts +4 -0
- package/dist/src/tasks/sentence-similarity/data.d.ts.map +1 -0
- package/dist/src/tasks/sentence-similarity/inference.d.ts +32 -0
- package/dist/src/tasks/sentence-similarity/inference.d.ts.map +1 -0
- package/dist/src/tasks/summarization/data.d.ts +4 -0
- package/dist/src/tasks/summarization/data.d.ts.map +1 -0
- package/dist/src/tasks/summarization/inference.d.ts +55 -0
- package/dist/src/tasks/summarization/inference.d.ts.map +1 -0
- package/dist/src/tasks/table-question-answering/data.d.ts +4 -0
- package/dist/src/tasks/table-question-answering/data.d.ts.map +1 -0
- package/dist/src/tasks/table-question-answering/inference.d.ts +62 -0
- package/dist/src/tasks/table-question-answering/inference.d.ts.map +1 -0
- package/dist/src/tasks/tabular-classification/data.d.ts +4 -0
- package/dist/src/tasks/tabular-classification/data.d.ts.map +1 -0
- package/dist/src/tasks/tabular-regression/data.d.ts +4 -0
- package/dist/src/tasks/tabular-regression/data.d.ts.map +1 -0
- package/dist/src/tasks/text-classification/data.d.ts +4 -0
- package/dist/src/tasks/text-classification/data.d.ts.map +1 -0
- package/dist/src/tasks/text-classification/inference.d.ts +52 -0
- package/dist/src/tasks/text-classification/inference.d.ts.map +1 -0
- package/dist/src/tasks/text-generation/data.d.ts +4 -0
- package/dist/src/tasks/text-generation/data.d.ts.map +1 -0
- package/dist/src/tasks/text-generation/inference.d.ts +126 -0
- package/dist/src/tasks/text-generation/inference.d.ts.map +1 -0
- package/dist/src/tasks/text-to-audio/inference.d.ts +139 -0
- package/dist/src/tasks/text-to-audio/inference.d.ts.map +1 -0
- package/dist/src/tasks/text-to-image/data.d.ts +4 -0
- package/dist/src/tasks/text-to-image/data.d.ts.map +1 -0
- package/dist/src/tasks/text-to-image/inference.d.ts +68 -0
- package/dist/src/tasks/text-to-image/inference.d.ts.map +1 -0
- package/dist/src/tasks/text-to-speech/data.d.ts +4 -0
- package/dist/src/tasks/text-to-speech/data.d.ts.map +1 -0
- package/dist/src/tasks/text-to-speech/inference.d.ts +143 -0
- package/dist/src/tasks/text-to-speech/inference.d.ts.map +1 -0
- package/dist/src/tasks/text-to-video/data.d.ts +4 -0
- package/dist/src/tasks/text-to-video/data.d.ts.map +1 -0
- package/dist/src/tasks/text2text-generation/inference.d.ts +54 -0
- package/dist/src/tasks/text2text-generation/inference.d.ts.map +1 -0
- package/dist/src/tasks/token-classification/data.d.ts +4 -0
- package/dist/src/tasks/token-classification/data.d.ts.map +1 -0
- package/dist/src/tasks/token-classification/inference.d.ts +83 -0
- package/dist/src/tasks/token-classification/inference.d.ts.map +1 -0
- package/dist/src/tasks/translation/data.d.ts +4 -0
- package/dist/src/tasks/translation/data.d.ts.map +1 -0
- package/dist/src/tasks/translation/inference.d.ts +55 -0
- package/dist/src/tasks/translation/inference.d.ts.map +1 -0
- package/dist/src/tasks/unconditional-image-generation/data.d.ts +4 -0
- package/dist/src/tasks/unconditional-image-generation/data.d.ts.map +1 -0
- package/dist/src/tasks/video-classification/data.d.ts +4 -0
- package/dist/src/tasks/video-classification/data.d.ts.map +1 -0
- package/dist/src/tasks/video-classification/inference.d.ts +60 -0
- package/dist/src/tasks/video-classification/inference.d.ts.map +1 -0
- package/dist/src/tasks/visual-question-answering/data.d.ts +4 -0
- package/dist/src/tasks/visual-question-answering/data.d.ts.map +1 -0
- package/dist/src/tasks/visual-question-answering/inference.d.ts +64 -0
- package/dist/src/tasks/visual-question-answering/inference.d.ts.map +1 -0
- package/dist/src/tasks/zero-shot-classification/data.d.ts +4 -0
- package/dist/src/tasks/zero-shot-classification/data.d.ts.map +1 -0
- package/dist/src/tasks/zero-shot-classification/inference.d.ts +68 -0
- package/dist/src/tasks/zero-shot-classification/inference.d.ts.map +1 -0
- package/dist/src/tasks/zero-shot-image-classification/data.d.ts +4 -0
- package/dist/src/tasks/zero-shot-image-classification/data.d.ts.map +1 -0
- package/dist/src/tasks/zero-shot-image-classification/inference.d.ts +62 -0
- package/dist/src/tasks/zero-shot-image-classification/inference.d.ts.map +1 -0
- package/dist/src/tasks/zero-shot-object-detection/data.d.ts +4 -0
- package/dist/src/tasks/zero-shot-object-detection/data.d.ts.map +1 -0
- package/dist/src/tasks/zero-shot-object-detection/inference.d.ts +67 -0
- package/dist/src/tasks/zero-shot-object-detection/inference.d.ts.map +1 -0
- package/dist/src/tokenizer-data.d.ts +26 -0
- package/dist/src/tokenizer-data.d.ts.map +1 -0
- package/dist/src/widget-example.d.ts +86 -0
- package/dist/src/widget-example.d.ts.map +1 -0
- package/package.json +8 -6
- package/src/index.ts +3 -0
- package/src/local-apps.ts +119 -0
- package/src/model-data.ts +1 -5
- package/src/model-libraries-snippets.ts +21 -18
- package/src/model-libraries.ts +9 -0
- package/src/tasks/chat-completion/inference.ts +204 -85
- package/src/tasks/chat-completion/spec/input.json +198 -34
- package/src/tasks/chat-completion/spec/output.json +178 -40
- package/src/tasks/chat-completion/spec/stream_output.json +170 -0
- package/src/tasks/index.ts +7 -8
- package/src/tasks/text-generation/inference.ts +58 -170
- package/src/tasks/text-generation/spec/input.json +130 -29
- package/src/tasks/text-generation/spec/output.json +104 -90
- package/src/tasks/text-generation/spec/stream_output.json +97 -0
- package/tsconfig.json +3 -1
- package/dist/index.d.ts +0 -3542
- package/src/tasks/chat-completion/spec/output_stream.json +0 -48
- package/src/tasks/text-generation/spec/output_stream.json +0 -47
package/src/tasks/index.ts
CHANGED
|
@@ -43,9 +43,8 @@ export type {
|
|
|
43
43
|
ChatCompletionInput,
|
|
44
44
|
ChatCompletionInputMessage,
|
|
45
45
|
ChatCompletionOutput,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
ChatCompletionOutputChoiceMessage,
|
|
46
|
+
ChatCompletionOutputComplete,
|
|
47
|
+
ChatCompletionOutputMessage,
|
|
49
48
|
ChatCompletionStreamOutput,
|
|
50
49
|
ChatCompletionStreamOutputChoice,
|
|
51
50
|
ChatCompletionStreamOutputDelta,
|
|
@@ -85,15 +84,15 @@ export type {
|
|
|
85
84
|
TextClassificationParameters,
|
|
86
85
|
} from "./text-classification/inference";
|
|
87
86
|
export type {
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
TextGenerationOutputFinishReason,
|
|
88
|
+
TextGenerationOutputPrefillToken,
|
|
90
89
|
TextGenerationInput,
|
|
91
90
|
TextGenerationOutput,
|
|
92
91
|
TextGenerationOutputDetails,
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
TextGenerationInputGenerateParameters,
|
|
93
|
+
TextGenerationOutputBestOfSequence,
|
|
95
94
|
TextGenerationOutputToken,
|
|
96
|
-
|
|
95
|
+
TextGenerationStreamOutputStreamDetails,
|
|
97
96
|
TextGenerationStreamOutput,
|
|
98
97
|
} from "./text-generation/inference";
|
|
99
98
|
export type * from "./video-classification/inference";
|
|
@@ -5,246 +5,134 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
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.
|
|
9
13
|
*/
|
|
10
14
|
export interface TextGenerationInput {
|
|
11
|
-
/**
|
|
12
|
-
* The text to initialize generation with
|
|
13
|
-
*/
|
|
14
15
|
inputs: string;
|
|
15
|
-
|
|
16
|
-
* Additional inference parameters
|
|
17
|
-
*/
|
|
18
|
-
parameters?: TextGenerationParameters;
|
|
19
|
-
/**
|
|
20
|
-
* Whether to stream output tokens
|
|
21
|
-
*/
|
|
16
|
+
parameters?: TextGenerationInputGenerateParameters;
|
|
22
17
|
stream?: boolean;
|
|
23
18
|
[property: string]: unknown;
|
|
24
19
|
}
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
* Additional inference parameters
|
|
28
|
-
*
|
|
29
|
-
* Additional inference parameters for Text Generation
|
|
30
|
-
*/
|
|
31
|
-
export interface TextGenerationParameters {
|
|
32
|
-
/**
|
|
33
|
-
* The number of sampling queries to run. Only the best one (in terms of total logprob) will
|
|
34
|
-
* be returned.
|
|
35
|
-
*/
|
|
21
|
+
export interface TextGenerationInputGenerateParameters {
|
|
36
22
|
best_of?: number;
|
|
37
|
-
/**
|
|
38
|
-
* Whether or not to output decoder input details
|
|
39
|
-
*/
|
|
40
23
|
decoder_input_details?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* Whether or not to output details
|
|
43
|
-
*/
|
|
44
24
|
details?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* Whether to use logits sampling instead of greedy decoding when generating new tokens.
|
|
47
|
-
*/
|
|
48
25
|
do_sample?: boolean;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*/
|
|
26
|
+
frequency_penalty?: number;
|
|
27
|
+
grammar?: TextGenerationInputGrammarType;
|
|
52
28
|
max_new_tokens?: number;
|
|
53
|
-
/**
|
|
54
|
-
* The parameter for repetition penalty. A value of 1.0 means no penalty. See [this
|
|
55
|
-
* paper](https://hf.co/papers/1909.05858) for more details.
|
|
56
|
-
*/
|
|
57
29
|
repetition_penalty?: number;
|
|
58
|
-
/**
|
|
59
|
-
* Whether to prepend the prompt to the generated text.
|
|
60
|
-
*/
|
|
61
30
|
return_full_text?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* The random sampling seed.
|
|
64
|
-
*/
|
|
65
31
|
seed?: number;
|
|
66
|
-
|
|
67
|
-
* Stop generating tokens if a member of `stop_sequences` is generated.
|
|
68
|
-
*/
|
|
69
|
-
stop_sequences?: string[];
|
|
70
|
-
/**
|
|
71
|
-
* The value used to modulate the logits distribution.
|
|
72
|
-
*/
|
|
32
|
+
stop?: string[];
|
|
73
33
|
temperature?: number;
|
|
74
|
-
/**
|
|
75
|
-
* The number of highest probability vocabulary tokens to keep for top-k-filtering.
|
|
76
|
-
*/
|
|
77
34
|
top_k?: number;
|
|
78
|
-
|
|
79
|
-
* If set to < 1, only the smallest set of most probable tokens with probabilities that add
|
|
80
|
-
* up to `top_p` or higher are kept for generation.
|
|
81
|
-
*/
|
|
35
|
+
top_n_tokens?: number;
|
|
82
36
|
top_p?: number;
|
|
83
|
-
/**
|
|
84
|
-
* Truncate input tokens to the given size.
|
|
85
|
-
*/
|
|
86
37
|
truncate?: number;
|
|
87
|
-
/**
|
|
88
|
-
* Typical Decoding mass. See [Typical Decoding for Natural Language
|
|
89
|
-
* Generation](https://hf.co/papers/2202.00666) for more information
|
|
90
|
-
*/
|
|
91
38
|
typical_p?: number;
|
|
39
|
+
watermark?: boolean;
|
|
40
|
+
[property: string]: unknown;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface TextGenerationInputGrammarType {
|
|
44
|
+
type: Type;
|
|
92
45
|
/**
|
|
93
|
-
*
|
|
46
|
+
* A string that represents a [JSON Schema](https://json-schema.org/).
|
|
47
|
+
*
|
|
48
|
+
* JSON Schema is a declarative language that allows to annotate JSON documents
|
|
49
|
+
* with types and descriptions.
|
|
94
50
|
*/
|
|
95
|
-
|
|
51
|
+
value: unknown;
|
|
96
52
|
[property: string]: unknown;
|
|
97
53
|
}
|
|
98
54
|
|
|
55
|
+
export type Type = "json" | "regex";
|
|
56
|
+
|
|
99
57
|
/**
|
|
100
|
-
*
|
|
58
|
+
* Text Generation Output.
|
|
59
|
+
*
|
|
60
|
+
* Auto-generated from TGI specs.
|
|
61
|
+
* For more details, check out
|
|
62
|
+
* https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
|
|
101
63
|
*/
|
|
102
64
|
export interface TextGenerationOutput {
|
|
103
|
-
/**
|
|
104
|
-
* When enabled, details about the generation
|
|
105
|
-
*/
|
|
106
65
|
details?: TextGenerationOutputDetails;
|
|
107
|
-
/**
|
|
108
|
-
* The generated text
|
|
109
|
-
*/
|
|
110
66
|
generated_text: string;
|
|
111
67
|
[property: string]: unknown;
|
|
112
68
|
}
|
|
113
69
|
|
|
114
|
-
/**
|
|
115
|
-
* When enabled, details about the generation
|
|
116
|
-
*/
|
|
117
70
|
export interface TextGenerationOutputDetails {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*/
|
|
121
|
-
best_of_sequences?: TextGenerationOutputSequenceDetails[];
|
|
122
|
-
/**
|
|
123
|
-
* The reason why the generation was stopped.
|
|
124
|
-
*/
|
|
125
|
-
finish_reason: TextGenerationFinishReason;
|
|
126
|
-
/**
|
|
127
|
-
* The number of generated tokens
|
|
128
|
-
*/
|
|
71
|
+
best_of_sequences?: TextGenerationOutputBestOfSequence[];
|
|
72
|
+
finish_reason: TextGenerationOutputFinishReason;
|
|
129
73
|
generated_tokens: number;
|
|
130
|
-
prefill:
|
|
131
|
-
/**
|
|
132
|
-
* The random seed used for generation
|
|
133
|
-
*/
|
|
74
|
+
prefill: TextGenerationOutputPrefillToken[];
|
|
134
75
|
seed?: number;
|
|
135
|
-
/**
|
|
136
|
-
* The generated tokens and associated details
|
|
137
|
-
*/
|
|
138
76
|
tokens: TextGenerationOutputToken[];
|
|
139
|
-
/**
|
|
140
|
-
* Most likely tokens
|
|
141
|
-
*/
|
|
142
77
|
top_tokens?: Array<TextGenerationOutputToken[]>;
|
|
143
78
|
[property: string]: unknown;
|
|
144
79
|
}
|
|
145
80
|
|
|
146
|
-
export interface
|
|
147
|
-
finish_reason:
|
|
148
|
-
/**
|
|
149
|
-
* The generated text
|
|
150
|
-
*/
|
|
81
|
+
export interface TextGenerationOutputBestOfSequence {
|
|
82
|
+
finish_reason: TextGenerationOutputFinishReason;
|
|
151
83
|
generated_text: string;
|
|
152
|
-
/**
|
|
153
|
-
* The number of generated tokens
|
|
154
|
-
*/
|
|
155
84
|
generated_tokens: number;
|
|
156
|
-
prefill:
|
|
157
|
-
/**
|
|
158
|
-
* The random seed used for generation
|
|
159
|
-
*/
|
|
85
|
+
prefill: TextGenerationOutputPrefillToken[];
|
|
160
86
|
seed?: number;
|
|
161
|
-
/**
|
|
162
|
-
* The generated tokens and associated details
|
|
163
|
-
*/
|
|
164
87
|
tokens: TextGenerationOutputToken[];
|
|
165
|
-
/**
|
|
166
|
-
* Most likely tokens
|
|
167
|
-
*/
|
|
168
88
|
top_tokens?: Array<TextGenerationOutputToken[]>;
|
|
169
89
|
[property: string]: unknown;
|
|
170
90
|
}
|
|
171
91
|
|
|
172
|
-
|
|
173
|
-
* The reason why the generation was stopped.
|
|
174
|
-
*
|
|
175
|
-
* length: The generated sequence reached the maximum allowed length
|
|
176
|
-
*
|
|
177
|
-
* eos_token: The model generated an end-of-sentence (EOS) token
|
|
178
|
-
*
|
|
179
|
-
* stop_sequence: One of the sequence in stop_sequences was generated
|
|
180
|
-
*/
|
|
181
|
-
export type TextGenerationFinishReason = "length" | "eos_token" | "stop_sequence";
|
|
92
|
+
export type TextGenerationOutputFinishReason = "length" | "eos_token" | "stop_sequence";
|
|
182
93
|
|
|
183
|
-
export interface
|
|
94
|
+
export interface TextGenerationOutputPrefillToken {
|
|
184
95
|
id: number;
|
|
185
96
|
logprob: number;
|
|
186
|
-
/**
|
|
187
|
-
* The text associated with that token
|
|
188
|
-
*/
|
|
189
97
|
text: string;
|
|
190
98
|
[property: string]: unknown;
|
|
191
99
|
}
|
|
192
100
|
|
|
193
|
-
/**
|
|
194
|
-
* Generated token.
|
|
195
|
-
*/
|
|
196
101
|
export interface TextGenerationOutputToken {
|
|
197
102
|
id: number;
|
|
198
|
-
logprob
|
|
199
|
-
/**
|
|
200
|
-
* Whether or not that token is a special one
|
|
201
|
-
*/
|
|
103
|
+
logprob: number;
|
|
202
104
|
special: boolean;
|
|
203
|
-
/**
|
|
204
|
-
* The text associated with that token
|
|
205
|
-
*/
|
|
206
105
|
text: string;
|
|
207
106
|
[property: string]: unknown;
|
|
208
107
|
}
|
|
209
108
|
|
|
210
109
|
/**
|
|
211
|
-
* Text Generation Stream Output
|
|
110
|
+
* Text Generation Stream Output.
|
|
111
|
+
*
|
|
112
|
+
* Auto-generated from TGI specs.
|
|
113
|
+
* For more details, check out
|
|
114
|
+
* https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
|
|
212
115
|
*/
|
|
213
116
|
export interface TextGenerationStreamOutput {
|
|
214
|
-
|
|
215
|
-
* Generation details. Only available when the generation is finished.
|
|
216
|
-
*/
|
|
217
|
-
details?: TextGenerationStreamDetails;
|
|
218
|
-
/**
|
|
219
|
-
* The complete generated text. Only available when the generation is finished.
|
|
220
|
-
*/
|
|
117
|
+
details?: TextGenerationStreamOutputStreamDetails;
|
|
221
118
|
generated_text?: string;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
index?: number;
|
|
226
|
-
/**
|
|
227
|
-
* Generated token.
|
|
228
|
-
*/
|
|
229
|
-
token: TextGenerationOutputToken;
|
|
119
|
+
index: number;
|
|
120
|
+
token: TextGenerationStreamOutputToken;
|
|
121
|
+
top_tokens?: TextGenerationStreamOutputToken[];
|
|
230
122
|
[property: string]: unknown;
|
|
231
123
|
}
|
|
232
124
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
*/
|
|
236
|
-
export interface TextGenerationStreamDetails {
|
|
237
|
-
/**
|
|
238
|
-
* The reason why the generation was stopped.
|
|
239
|
-
*/
|
|
240
|
-
finish_reason: TextGenerationFinishReason;
|
|
241
|
-
/**
|
|
242
|
-
* The number of generated tokens
|
|
243
|
-
*/
|
|
125
|
+
export interface TextGenerationStreamOutputStreamDetails {
|
|
126
|
+
finish_reason: TextGenerationOutputFinishReason;
|
|
244
127
|
generated_tokens: number;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
128
|
+
seed?: number;
|
|
129
|
+
[property: string]: unknown;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface TextGenerationStreamOutputToken {
|
|
133
|
+
id: number;
|
|
134
|
+
logprob: number;
|
|
135
|
+
special: boolean;
|
|
136
|
+
text: string;
|
|
249
137
|
[property: string]: unknown;
|
|
250
138
|
}
|
|
@@ -1,94 +1,195 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$id": "/inference/schemas/text-generation/input.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-06/schema#",
|
|
4
|
-
"description": "
|
|
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
5
|
"title": "TextGenerationInput",
|
|
6
6
|
"type": "object",
|
|
7
|
+
"required": ["inputs"],
|
|
7
8
|
"properties": {
|
|
8
9
|
"inputs": {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
10
|
+
"type": "string",
|
|
11
|
+
"example": "My name is Olivier and I"
|
|
11
12
|
},
|
|
12
13
|
"parameters": {
|
|
13
|
-
"
|
|
14
|
-
"$ref": "#/$defs/TextGenerationParameters"
|
|
14
|
+
"$ref": "#/$defs/TextGenerationInputGenerateParameters"
|
|
15
15
|
},
|
|
16
16
|
"stream": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
17
|
+
"type": "boolean",
|
|
18
|
+
"default": "false"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"$defs": {
|
|
22
|
-
"
|
|
23
|
-
"title": "TextGenerationParameters",
|
|
24
|
-
"description": "Additional inference parameters for Text Generation",
|
|
22
|
+
"TextGenerationInputGenerateParameters": {
|
|
25
23
|
"type": "object",
|
|
26
24
|
"properties": {
|
|
27
25
|
"best_of": {
|
|
28
26
|
"type": "integer",
|
|
29
|
-
"
|
|
27
|
+
"default": "null",
|
|
28
|
+
"example": 1,
|
|
29
|
+
"nullable": true,
|
|
30
|
+
"minimum": 0,
|
|
31
|
+
"exclusiveMinimum": 0
|
|
30
32
|
},
|
|
31
33
|
"decoder_input_details": {
|
|
32
34
|
"type": "boolean",
|
|
33
|
-
"
|
|
35
|
+
"default": "false"
|
|
34
36
|
},
|
|
35
37
|
"details": {
|
|
36
38
|
"type": "boolean",
|
|
37
|
-
"
|
|
39
|
+
"default": "true"
|
|
38
40
|
},
|
|
39
41
|
"do_sample": {
|
|
40
42
|
"type": "boolean",
|
|
41
|
-
"
|
|
43
|
+
"default": "false",
|
|
44
|
+
"example": true
|
|
45
|
+
},
|
|
46
|
+
"frequency_penalty": {
|
|
47
|
+
"type": "number",
|
|
48
|
+
"format": "float",
|
|
49
|
+
"default": "null",
|
|
50
|
+
"example": 0.1,
|
|
51
|
+
"nullable": true,
|
|
52
|
+
"exclusiveMinimum": -2
|
|
53
|
+
},
|
|
54
|
+
"grammar": {
|
|
55
|
+
"allOf": [
|
|
56
|
+
{
|
|
57
|
+
"$ref": "#/$defs/TextGenerationInputGrammarType"
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
"default": "null",
|
|
61
|
+
"nullable": true
|
|
42
62
|
},
|
|
43
63
|
"max_new_tokens": {
|
|
44
64
|
"type": "integer",
|
|
45
|
-
"
|
|
65
|
+
"format": "int32",
|
|
66
|
+
"default": "100",
|
|
67
|
+
"example": "20",
|
|
68
|
+
"nullable": true,
|
|
69
|
+
"minimum": 0
|
|
46
70
|
},
|
|
47
71
|
"repetition_penalty": {
|
|
48
72
|
"type": "number",
|
|
49
|
-
"
|
|
73
|
+
"format": "float",
|
|
74
|
+
"default": "null",
|
|
75
|
+
"example": 1.03,
|
|
76
|
+
"nullable": true,
|
|
77
|
+
"exclusiveMinimum": 0
|
|
50
78
|
},
|
|
51
79
|
"return_full_text": {
|
|
52
80
|
"type": "boolean",
|
|
53
|
-
"
|
|
81
|
+
"default": "null",
|
|
82
|
+
"example": false,
|
|
83
|
+
"nullable": true
|
|
54
84
|
},
|
|
55
85
|
"seed": {
|
|
56
86
|
"type": "integer",
|
|
57
|
-
"
|
|
87
|
+
"format": "int64",
|
|
88
|
+
"default": "null",
|
|
89
|
+
"example": "null",
|
|
90
|
+
"nullable": true,
|
|
91
|
+
"minimum": 0,
|
|
92
|
+
"exclusiveMinimum": 0
|
|
58
93
|
},
|
|
59
|
-
"
|
|
94
|
+
"stop": {
|
|
60
95
|
"type": "array",
|
|
61
96
|
"items": {
|
|
62
97
|
"type": "string"
|
|
63
98
|
},
|
|
64
|
-
"
|
|
99
|
+
"example": ["photographer"],
|
|
100
|
+
"maxItems": 4
|
|
65
101
|
},
|
|
66
102
|
"temperature": {
|
|
67
103
|
"type": "number",
|
|
68
|
-
"
|
|
104
|
+
"format": "float",
|
|
105
|
+
"default": "null",
|
|
106
|
+
"example": 0.5,
|
|
107
|
+
"nullable": true,
|
|
108
|
+
"exclusiveMinimum": 0
|
|
69
109
|
},
|
|
70
110
|
"top_k": {
|
|
71
111
|
"type": "integer",
|
|
72
|
-
"
|
|
112
|
+
"format": "int32",
|
|
113
|
+
"default": "null",
|
|
114
|
+
"example": 10,
|
|
115
|
+
"nullable": true,
|
|
116
|
+
"exclusiveMinimum": 0
|
|
117
|
+
},
|
|
118
|
+
"top_n_tokens": {
|
|
119
|
+
"type": "integer",
|
|
120
|
+
"format": "int32",
|
|
121
|
+
"default": "null",
|
|
122
|
+
"example": 5,
|
|
123
|
+
"nullable": true,
|
|
124
|
+
"minimum": 0,
|
|
125
|
+
"exclusiveMinimum": 0
|
|
73
126
|
},
|
|
74
127
|
"top_p": {
|
|
75
128
|
"type": "number",
|
|
76
|
-
"
|
|
129
|
+
"format": "float",
|
|
130
|
+
"default": "null",
|
|
131
|
+
"example": 0.95,
|
|
132
|
+
"nullable": true,
|
|
133
|
+
"maximum": 1,
|
|
134
|
+
"exclusiveMinimum": 0
|
|
77
135
|
},
|
|
78
136
|
"truncate": {
|
|
79
137
|
"type": "integer",
|
|
80
|
-
"
|
|
138
|
+
"default": "null",
|
|
139
|
+
"example": "null",
|
|
140
|
+
"nullable": true,
|
|
141
|
+
"minimum": 0
|
|
81
142
|
},
|
|
82
143
|
"typical_p": {
|
|
83
144
|
"type": "number",
|
|
84
|
-
"
|
|
145
|
+
"format": "float",
|
|
146
|
+
"default": "null",
|
|
147
|
+
"example": 0.95,
|
|
148
|
+
"nullable": true,
|
|
149
|
+
"maximum": 1,
|
|
150
|
+
"exclusiveMinimum": 0
|
|
85
151
|
},
|
|
86
152
|
"watermark": {
|
|
87
153
|
"type": "boolean",
|
|
88
|
-
"
|
|
154
|
+
"default": "false",
|
|
155
|
+
"example": true
|
|
89
156
|
}
|
|
90
|
-
}
|
|
157
|
+
},
|
|
158
|
+
"title": "TextGenerationInputGenerateParameters"
|
|
159
|
+
},
|
|
160
|
+
"TextGenerationInputGrammarType": {
|
|
161
|
+
"oneOf": [
|
|
162
|
+
{
|
|
163
|
+
"type": "object",
|
|
164
|
+
"required": ["type", "value"],
|
|
165
|
+
"properties": {
|
|
166
|
+
"type": {
|
|
167
|
+
"type": "string",
|
|
168
|
+
"enum": ["json"]
|
|
169
|
+
},
|
|
170
|
+
"value": {
|
|
171
|
+
"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."
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
"type": "object",
|
|
177
|
+
"required": ["type", "value"],
|
|
178
|
+
"properties": {
|
|
179
|
+
"type": {
|
|
180
|
+
"type": "string",
|
|
181
|
+
"enum": ["regex"]
|
|
182
|
+
},
|
|
183
|
+
"value": {
|
|
184
|
+
"type": "string"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
],
|
|
189
|
+
"discriminator": {
|
|
190
|
+
"propertyName": "type"
|
|
191
|
+
},
|
|
192
|
+
"title": "TextGenerationInputGrammarType"
|
|
91
193
|
}
|
|
92
|
-
}
|
|
93
|
-
"required": ["inputs"]
|
|
194
|
+
}
|
|
94
195
|
}
|