Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
machineuser
commited on
Commit
·
afa4e5a
1
Parent(s):
5852013
Sync widgets demo
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- packages/tasks/package.json +7 -3
- packages/tasks/pnpm-lock.yaml +209 -0
- packages/tasks/src/scripts/inference-codegen.ts +192 -0
- packages/tasks/src/tasks/audio-classification/inference.ts +51 -0
- packages/tasks/src/tasks/audio-classification/spec/input.json +34 -0
- packages/tasks/src/tasks/audio-classification/spec/output.json +21 -0
- packages/tasks/src/tasks/automatic-speech-recognition/inference.ts +154 -0
- packages/tasks/src/tasks/automatic-speech-recognition/spec/input.json +34 -0
- packages/tasks/src/tasks/automatic-speech-recognition/spec/output.json +36 -0
- packages/tasks/src/tasks/common-definitions.json +109 -0
- packages/tasks/src/tasks/depth-estimation/inference.ts +35 -0
- packages/tasks/src/tasks/depth-estimation/spec/input.json +30 -0
- packages/tasks/src/tasks/depth-estimation/spec/output.json +10 -0
- packages/tasks/src/tasks/document-question-answering/inference.ts +102 -0
- packages/tasks/src/tasks/document-question-answering/spec/input.json +85 -0
- packages/tasks/src/tasks/document-question-answering/spec/output.json +36 -0
- packages/tasks/src/tasks/feature-extraction/inference.ts +22 -0
- packages/tasks/src/tasks/feature-extraction/spec/input.json +26 -0
- packages/tasks/src/tasks/feature-extraction/spec/output.json +7 -0
- packages/tasks/src/tasks/fill-mask/inference.ts +61 -0
- packages/tasks/src/tasks/fill-mask/spec/input.json +38 -0
- packages/tasks/src/tasks/fill-mask/spec/output.json +29 -0
- packages/tasks/src/tasks/image-classification/inference.ts +51 -0
- packages/tasks/src/tasks/image-classification/spec/input.json +34 -0
- packages/tasks/src/tasks/image-classification/spec/output.json +10 -0
- packages/tasks/src/tasks/image-segmentation/inference.ts +65 -0
- packages/tasks/src/tasks/image-segmentation/spec/input.json +54 -0
- packages/tasks/src/tasks/image-segmentation/spec/output.json +25 -0
- packages/tasks/src/tasks/image-to-image/inference.ts +67 -0
- packages/tasks/src/tasks/image-to-image/spec/input.json +52 -0
- packages/tasks/src/tasks/image-to-image/spec/output.json +12 -0
- packages/tasks/src/tasks/image-to-text/inference.ts +138 -0
- packages/tasks/src/tasks/image-to-text/spec/input.json +34 -0
- packages/tasks/src/tasks/image-to-text/spec/output.json +17 -0
- packages/tasks/src/tasks/index.ts +1 -0
- packages/tasks/src/tasks/object-detection/inference.ts +62 -0
- packages/tasks/src/tasks/object-detection/spec/input.json +30 -0
- packages/tasks/src/tasks/object-detection/spec/output.json +46 -0
- packages/tasks/src/tasks/placeholder/data.ts +3 -0
- packages/tasks/src/tasks/placeholder/spec/input.json +35 -0
- packages/tasks/src/tasks/placeholder/spec/output.json +17 -0
- packages/tasks/src/tasks/question-answering/inference.ts +99 -0
- packages/tasks/src/tasks/question-answering/spec/input.json +67 -0
- packages/tasks/src/tasks/question-answering/spec/output.json +29 -0
- packages/tasks/src/tasks/sentence-similarity/inference.ts +32 -0
- packages/tasks/src/tasks/sentence-similarity/spec/input.json +40 -0
- packages/tasks/src/tasks/sentence-similarity/spec/output.json +12 -0
- packages/tasks/src/tasks/summarization/data.ts +1 -0
- packages/tasks/src/tasks/summarization/inference.ts +58 -0
- packages/tasks/src/tasks/summarization/spec/input.json +7 -0
packages/tasks/package.json
CHANGED
@@ -24,9 +24,10 @@
|
|
24 |
"format": "prettier --write .",
|
25 |
"format:check": "prettier --check .",
|
26 |
"prepublishOnly": "pnpm run build",
|
27 |
-
"build": "tsup src/index.ts --format cjs,esm --clean --dts",
|
28 |
"prepare": "pnpm run build",
|
29 |
-
"check": "tsc"
|
|
|
30 |
},
|
31 |
"files": [
|
32 |
"dist",
|
@@ -40,5 +41,8 @@
|
|
40 |
],
|
41 |
"author": "Hugging Face",
|
42 |
"license": "MIT",
|
43 |
-
"devDependencies": {
|
|
|
|
|
|
|
44 |
}
|
|
|
24 |
"format": "prettier --write .",
|
25 |
"format:check": "prettier --check .",
|
26 |
"prepublishOnly": "pnpm run build",
|
27 |
+
"build": "tsup src/index.ts src/scripts/**.ts --format cjs,esm --clean --dts",
|
28 |
"prepare": "pnpm run build",
|
29 |
+
"check": "tsc",
|
30 |
+
"inference-codegen": "pnpm run build && node dist/scripts/inference-codegen.js"
|
31 |
},
|
32 |
"files": [
|
33 |
"dist",
|
|
|
41 |
],
|
42 |
"author": "Hugging Face",
|
43 |
"license": "MIT",
|
44 |
+
"devDependencies": {
|
45 |
+
"@types/node": "^20.11.5",
|
46 |
+
"quicktype-core": "https://github.com/huggingface/quicktype/raw/pack-18.0.15/packages/quicktype-core/quicktype-core-18.0.15.tgz"
|
47 |
+
}
|
48 |
}
|
packages/tasks/pnpm-lock.yaml
CHANGED
@@ -3,3 +3,212 @@ lockfileVersion: '6.0'
|
|
3 |
settings:
|
4 |
autoInstallPeers: true
|
5 |
excludeLinksFromLockfile: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
settings:
|
4 |
autoInstallPeers: true
|
5 |
excludeLinksFromLockfile: false
|
6 |
+
|
7 |
+
devDependencies:
|
8 |
+
'@types/node':
|
9 |
+
specifier: ^20.11.5
|
10 |
+
version: 20.11.5
|
11 |
+
quicktype-core:
|
12 |
+
specifier: https://github.com/huggingface/quicktype/raw/pack-18.0.15/packages/quicktype-core/quicktype-core-18.0.15.tgz
|
13 |
+
version: '@github.com/huggingface/quicktype/raw/pack-18.0.15/packages/quicktype-core/quicktype-core-18.0.15.tgz'
|
14 |
+
|
15 |
+
packages:
|
16 |
+
|
17 |
+
/@glideapps/[email protected]:
|
18 |
+
resolution: {integrity: sha512-q9U8v/n9qbkd2zDYjuX3qtlbl+OIyI9zF+zQhZjfYOE9VMDH7tfcUSJ9p0lXoY3lxmGFne09yi4iiNeQUwV7AA==}
|
19 |
+
dev: true
|
20 |
+
|
21 |
+
/@types/[email protected]:
|
22 |
+
resolution: {integrity: sha512-g557vgQjUUfN76MZAN/dt1z3dzcUsimuysco0KeluHgrPdJXkP/XdAURgyO2W9fZWHRtRBiVKzKn8vyOAwlG+w==}
|
23 |
+
dependencies:
|
24 |
+
undici-types: 5.26.5
|
25 |
+
dev: true
|
26 |
+
|
27 |
+
/@types/[email protected]:
|
28 |
+
resolution: {integrity: sha512-XOfUup9r3Y06nFAZh3WvO0rBU4OtlfPB/vgxpjg+NRdGU6CN6djdc6OEiH+PcqHCY6eFLo9Ista73uarf4gnBg==}
|
29 |
+
dev: true
|
30 |
+
|
31 | |
32 |
+
resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==}
|
33 |
+
engines: {node: '>=6.5'}
|
34 |
+
dependencies:
|
35 |
+
event-target-shim: 5.0.1
|
36 |
+
dev: true
|
37 |
+
|
38 | |
39 |
+
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
40 |
+
dev: true
|
41 |
+
|
42 | |
43 |
+
resolution: {integrity: sha512-8CVjaLJGuSKMVTxJ2DpBl5XnlNDiT4cQFeuCJJrvJmts9YrTZDizTX7PjC2s6W4x+MBGZeEY6dGMrF04/6Hgqg==}
|
44 |
+
dev: true
|
45 |
+
|
46 | |
47 |
+
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
|
48 |
+
dependencies:
|
49 |
+
base64-js: 1.5.1
|
50 |
+
ieee754: 1.2.1
|
51 |
+
dev: true
|
52 |
+
|
53 | |
54 |
+
resolution: {integrity: sha512-LA2YTIlR7biSpXkKYwwuzGjwL5rjWEZVOSnvdUc7gObvWe4WkjxOpfrdhoP7Hs09YWDVfg0Mal9BpAqLfVEzQg==}
|
55 |
+
dev: true
|
56 |
+
|
57 | |
58 |
+
resolution: {integrity: sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==}
|
59 |
+
dependencies:
|
60 |
+
node-fetch: 2.7.0
|
61 |
+
transitivePeerDependencies:
|
62 |
+
- encoding
|
63 |
+
dev: true
|
64 |
+
|
65 | |
66 |
+
resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==}
|
67 |
+
engines: {node: '>=6'}
|
68 |
+
dev: true
|
69 |
+
|
70 | |
71 |
+
resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}
|
72 |
+
engines: {node: '>=0.8.x'}
|
73 |
+
dev: true
|
74 |
+
|
75 | |
76 |
+
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
77 |
+
dev: true
|
78 |
+
|
79 | |
80 |
+
resolution: {integrity: sha512-ITvGim8FhRiYe4IQ5uHSkj7pVaPDrCTkNd3yq3cV7iZAcJdHTUMPMEHcqSOy9xZ9qFenQCvi+2wjH9a1nXqHww==}
|
81 |
+
dev: true
|
82 |
+
|
83 | |
84 |
+
resolution: {integrity: sha512-NPrWuHFxFUknr1KqJRDgUQPexQF0uIJWjeT+2KjEePhitQxQEx5EJBG1lVn5/hc8aLycTpXrDOgPQ6Zq+EDiTA==}
|
85 |
+
dev: true
|
86 |
+
|
87 | |
88 |
+
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
89 |
+
dev: true
|
90 |
+
|
91 | |
92 |
+
resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==}
|
93 |
+
engines: {node: 4.x || >=6.0.0}
|
94 |
+
peerDependencies:
|
95 |
+
encoding: ^0.1.0
|
96 |
+
peerDependenciesMeta:
|
97 |
+
encoding:
|
98 |
+
optional: true
|
99 |
+
dependencies:
|
100 |
+
whatwg-url: 5.0.0
|
101 |
+
dev: true
|
102 |
+
|
103 | |
104 |
+
resolution: {integrity: sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==}
|
105 |
+
dev: true
|
106 |
+
|
107 | |
108 |
+
resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==}
|
109 |
+
dev: true
|
110 |
+
|
111 | |
112 |
+
resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==}
|
113 |
+
engines: {node: '>=4'}
|
114 |
+
dev: true
|
115 |
+
|
116 | |
117 |
+
resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==}
|
118 |
+
engines: {node: '>= 0.6.0'}
|
119 |
+
dev: true
|
120 |
+
|
121 | |
122 |
+
resolution: {integrity: sha512-Lk/fICSyIhodxy1IDK2HazkeGjSmezAWX2egdtJnYhtzKEsBPJowlI6F6LPb5tqIQILrMbx22S5o3GuJavPusA==}
|
123 |
+
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
124 |
+
dependencies:
|
125 |
+
abort-controller: 3.0.0
|
126 |
+
buffer: 6.0.3
|
127 |
+
events: 3.3.0
|
128 |
+
process: 0.11.10
|
129 |
+
string_decoder: 1.3.0
|
130 |
+
dev: true
|
131 |
+
|
132 | |
133 |
+
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
|
134 |
+
dev: true
|
135 |
+
|
136 | |
137 |
+
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
|
138 |
+
dependencies:
|
139 |
+
safe-buffer: 5.2.1
|
140 |
+
dev: true
|
141 |
+
|
142 | |
143 |
+
resolution: {integrity: sha512-pkY1fj1cKHb2seWDy0B16HeWyczlJA9/WW3u3c4z/NiWDsO3DOU5D7nhTLE9CF0yXv/QZFY7sEJmj24dK+Rrqw==}
|
144 |
+
dev: true
|
145 |
+
|
146 | |
147 |
+
resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}
|
148 |
+
dev: true
|
149 |
+
|
150 | |
151 |
+
resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==}
|
152 |
+
dev: true
|
153 |
+
|
154 | |
155 |
+
resolution: {integrity: sha512-CLjCCLQ6UuMxWnbIylkisbRj31qxHPAurvena/0iwSVbQ2G1VY5/HjV0IRabOEbDHlzZlRdCrD4NhB0JtU40Pg==}
|
156 |
+
dependencies:
|
157 |
+
base64-js: 1.5.1
|
158 |
+
unicode-trie: 2.0.0
|
159 |
+
dev: true
|
160 |
+
|
161 | |
162 |
+
resolution: {integrity: sha512-x7bc76x0bm4prf1VLg79uhAzKw8DVboClSN5VxJuQ+LKDOVEW9CdH+VY7SP+vX7xCYQqzzgQpFqz15zeLvAtZQ==}
|
163 |
+
dependencies:
|
164 |
+
pako: 0.2.9
|
165 |
+
tiny-inflate: 1.0.3
|
166 |
+
dev: true
|
167 |
+
|
168 | |
169 |
+
resolution: {integrity: sha512-HXgFDgDommxn5/bIv0cnQZsPhHDA90NPHD6+c/v21U5+Sx5hoP8+dP9IZXBU1gIfvdRfhG8cel9QNPeionfcCQ==}
|
170 |
+
dev: true
|
171 |
+
|
172 | |
173 |
+
resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==}
|
174 |
+
dev: true
|
175 |
+
|
176 | |
177 |
+
resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==}
|
178 |
+
dependencies:
|
179 |
+
tr46: 0.0.3
|
180 |
+
webidl-conversions: 3.0.1
|
181 |
+
dev: true
|
182 |
+
|
183 | |
184 |
+
resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==}
|
185 |
+
dev: true
|
186 |
+
|
187 | |
188 |
+
resolution: {integrity: sha512-8aAvwVUSHpfEqTQ4w/KMlf3HcRdt50E5ODIQJBw1fQ5RL34xabzxtUlzTXVqc4rkZsPbvrXKWnABCD7kWSmocA==}
|
189 |
+
engines: {node: '>= 14'}
|
190 |
+
dev: true
|
191 |
+
|
192 |
+
'@github.com/huggingface/quicktype/raw/pack-18.0.15/packages/quicktype-core/quicktype-core-18.0.15.tgz':
|
193 |
+
resolution: {tarball: https://github.com/huggingface/quicktype/raw/pack-18.0.15/packages/quicktype-core/quicktype-core-18.0.15.tgz}
|
194 |
+
name: quicktype-core
|
195 |
+
version: 18.0.15
|
196 |
+
dependencies:
|
197 |
+
'@glideapps/ts-necessities': 2.1.3
|
198 |
+
'@types/urijs': 1.19.25
|
199 |
+
browser-or-node: 2.1.1
|
200 |
+
collection-utils: 1.0.1
|
201 |
+
cross-fetch: 4.0.0
|
202 |
+
is-url: 1.2.4
|
203 |
+
js-base64: 3.7.6
|
204 |
+
lodash: 4.17.21
|
205 |
+
pako: 1.0.11
|
206 |
+
pluralize: 8.0.0
|
207 |
+
readable-stream: 4.4.2
|
208 |
+
unicode-properties: 1.4.1
|
209 |
+
urijs: 1.19.11
|
210 |
+
wordwrap: 1.0.0
|
211 |
+
yaml: 2.3.4
|
212 |
+
transitivePeerDependencies:
|
213 |
+
- encoding
|
214 |
+
dev: true
|
packages/tasks/src/scripts/inference-codegen.ts
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import type { SerializedRenderResult } from "quicktype-core";
|
2 |
+
import { quicktype, InputData, JSONSchemaInput, FetchingJSONSchemaStore } from "quicktype-core";
|
3 |
+
import * as fs from "fs/promises";
|
4 |
+
import { existsSync as pathExists } from "fs";
|
5 |
+
import * as path from "path";
|
6 |
+
import * as ts from "typescript";
|
7 |
+
|
8 |
+
const TYPESCRIPT_HEADER_FILE = `
|
9 |
+
/**
|
10 |
+
* Inference code generated from the JSON schema spec in ./spec
|
11 |
+
*
|
12 |
+
* Using src/scripts/inference-codegen
|
13 |
+
*/
|
14 |
+
|
15 |
+
`;
|
16 |
+
|
17 |
+
const rootDirFinder = function (): string {
|
18 |
+
const parts = __dirname.split("/");
|
19 |
+
let level = parts.length - 1;
|
20 |
+
while (level > 0) {
|
21 |
+
const currentPath = parts.slice(0, level).join("/");
|
22 |
+
if (pathExists(`${currentPath}/package.json`)) {
|
23 |
+
return path.normalize(currentPath);
|
24 |
+
}
|
25 |
+
level--;
|
26 |
+
}
|
27 |
+
return "";
|
28 |
+
};
|
29 |
+
|
30 |
+
/**
|
31 |
+
*
|
32 |
+
* @param taskId The ID of the task for which we are generating code
|
33 |
+
* @param taskSpecDir The path to the directory where the input.json & output.json files are
|
34 |
+
* @param allSpecFiles An array of paths to all the tasks specs. Allows resolving cross-file references ($ref).
|
35 |
+
*/
|
36 |
+
async function buildInputData(taskId: string, taskSpecDir: string, allSpecFiles: string[]): Promise<InputData> {
|
37 |
+
const schema = new JSONSchemaInput(new FetchingJSONSchemaStore(), [], allSpecFiles);
|
38 |
+
await schema.addSource({
|
39 |
+
name: `${taskId}-input`,
|
40 |
+
schema: await fs.readFile(`${taskSpecDir}/input.json`, { encoding: "utf-8" }),
|
41 |
+
});
|
42 |
+
await schema.addSource({
|
43 |
+
name: `${taskId}-output`,
|
44 |
+
schema: await fs.readFile(`${taskSpecDir}/output.json`, { encoding: "utf-8" }),
|
45 |
+
});
|
46 |
+
const inputData = new InputData();
|
47 |
+
inputData.addInput(schema);
|
48 |
+
return inputData;
|
49 |
+
}
|
50 |
+
|
51 |
+
async function generateTypescript(inputData: InputData): Promise<SerializedRenderResult> {
|
52 |
+
return await quicktype({
|
53 |
+
inputData,
|
54 |
+
lang: "typescript",
|
55 |
+
alphabetizeProperties: true,
|
56 |
+
rendererOptions: {
|
57 |
+
"just-types": true,
|
58 |
+
"nice-property-names": true,
|
59 |
+
"prefer-unions": true,
|
60 |
+
"prefer-const-values": true,
|
61 |
+
"prefer-unknown": true,
|
62 |
+
"explicit-unions": true,
|
63 |
+
},
|
64 |
+
});
|
65 |
+
}
|
66 |
+
/**
|
67 |
+
* quicktype is unable to generate "top-level array types" that are defined in the output spec: https://github.com/glideapps/quicktype/issues/2481
|
68 |
+
* We have to use the TypeScript API to generate those types when required.
|
69 |
+
* This hacky function:
|
70 |
+
* - looks for the generated interface for output types
|
71 |
+
* - renames it with a `Element` suffix
|
72 |
+
* - generates type alias in the form `export type <OutputType> = <OutputType>Element[];
|
73 |
+
*
|
74 |
+
* And writes that to the `inference.ts` file
|
75 |
+
*
|
76 |
+
*/
|
77 |
+
async function postProcessOutput(path2generated: string, outputSpec: Record<string, unknown>): Promise<void> {
|
78 |
+
const source = ts.createSourceFile(
|
79 |
+
path.basename(path2generated),
|
80 |
+
await fs.readFile(path2generated, { encoding: "utf-8" }),
|
81 |
+
ts.ScriptTarget.ES2022
|
82 |
+
);
|
83 |
+
const exportedName = outputSpec.title;
|
84 |
+
if (outputSpec.type !== "array" || typeof exportedName !== "string") {
|
85 |
+
console.log(" Nothing to do");
|
86 |
+
return;
|
87 |
+
}
|
88 |
+
const topLevelNodes = source.getChildAt(0).getChildren();
|
89 |
+
const hasTypeAlias = topLevelNodes.some(
|
90 |
+
(node) =>
|
91 |
+
node.kind === ts.SyntaxKind.TypeAliasDeclaration &&
|
92 |
+
(node as ts.TypeAliasDeclaration).name.escapedText === exportedName
|
93 |
+
);
|
94 |
+
if (hasTypeAlias) {
|
95 |
+
return;
|
96 |
+
}
|
97 |
+
|
98 |
+
const interfaceDeclaration = topLevelNodes.find((node): node is ts.InterfaceDeclaration => {
|
99 |
+
if (node.kind === ts.SyntaxKind.InterfaceDeclaration) {
|
100 |
+
return (node as ts.InterfaceDeclaration).name.getText(source) === exportedName;
|
101 |
+
}
|
102 |
+
return false;
|
103 |
+
});
|
104 |
+
if (!interfaceDeclaration) {
|
105 |
+
console.log(" Nothing to do");
|
106 |
+
return;
|
107 |
+
}
|
108 |
+
|
109 |
+
console.log(" Inserting top-level array type alias...");
|
110 |
+
|
111 |
+
const updatedInterface = ts.factory.updateInterfaceDeclaration(
|
112 |
+
interfaceDeclaration,
|
113 |
+
interfaceDeclaration.modifiers,
|
114 |
+
ts.factory.createIdentifier(interfaceDeclaration.name.getText(source) + "Element"),
|
115 |
+
interfaceDeclaration.typeParameters,
|
116 |
+
interfaceDeclaration.heritageClauses,
|
117 |
+
interfaceDeclaration.members
|
118 |
+
);
|
119 |
+
const arrayDeclaration = ts.factory.createTypeAliasDeclaration(
|
120 |
+
[ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
121 |
+
exportedName,
|
122 |
+
undefined,
|
123 |
+
ts.factory.createArrayTypeNode(ts.factory.createTypeReferenceNode(updatedInterface.name))
|
124 |
+
);
|
125 |
+
|
126 |
+
const printer = ts.createPrinter();
|
127 |
+
|
128 |
+
const newNodes = ts.factory.createNodeArray([
|
129 |
+
...topLevelNodes.filter((node) => node !== interfaceDeclaration),
|
130 |
+
arrayDeclaration,
|
131 |
+
updatedInterface,
|
132 |
+
]);
|
133 |
+
|
134 |
+
await fs.writeFile(path2generated, printer.printList(ts.ListFormat.MultiLine, newNodes, source), {
|
135 |
+
flag: "w+",
|
136 |
+
encoding: "utf-8",
|
137 |
+
});
|
138 |
+
|
139 |
+
return;
|
140 |
+
}
|
141 |
+
|
142 |
+
async function main() {
|
143 |
+
const rootDir = rootDirFinder();
|
144 |
+
const tasksDir = path.join(rootDir, "src", "tasks");
|
145 |
+
const allTasks = await Promise.all(
|
146 |
+
(await fs.readdir(tasksDir, { withFileTypes: true }))
|
147 |
+
.filter((entry) => entry.isDirectory())
|
148 |
+
.filter((entry) => entry.name !== "placeholder")
|
149 |
+
.map(async (entry) => ({ task: entry.name, dirPath: path.join(entry.path, entry.name) }))
|
150 |
+
);
|
151 |
+
const allSpecFiles = [
|
152 |
+
path.join(tasksDir, "common-definitions.json"),
|
153 |
+
...allTasks
|
154 |
+
.flatMap(({ dirPath }) => [path.join(dirPath, "spec", "input.json"), path.join(dirPath, "spec", "output.json")])
|
155 |
+
.filter((filepath) => pathExists(filepath)),
|
156 |
+
];
|
157 |
+
|
158 |
+
for (const { task, dirPath } of allTasks) {
|
159 |
+
const taskSpecDir = path.join(dirPath, "spec");
|
160 |
+
if (!(pathExists(path.join(taskSpecDir, "input.json")) && pathExists(path.join(taskSpecDir, "output.json")))) {
|
161 |
+
console.debug(`No spec found for task ${task} - skipping`);
|
162 |
+
continue;
|
163 |
+
}
|
164 |
+
console.debug(`✨ Generating types for task`, task);
|
165 |
+
|
166 |
+
console.debug(" 📦 Building input data");
|
167 |
+
const inputData = await buildInputData(task, taskSpecDir, allSpecFiles);
|
168 |
+
|
169 |
+
console.debug(" 🏭 Generating typescript code");
|
170 |
+
{
|
171 |
+
const { lines } = await generateTypescript(inputData);
|
172 |
+
await fs.writeFile(`${dirPath}/inference.ts`, [TYPESCRIPT_HEADER_FILE, ...lines].join(`\n`), {
|
173 |
+
flag: "w+",
|
174 |
+
encoding: "utf-8",
|
175 |
+
});
|
176 |
+
}
|
177 |
+
|
178 |
+
const outputSpec = JSON.parse(await fs.readFile(`${taskSpecDir}/output.json`, { encoding: "utf-8" }));
|
179 |
+
|
180 |
+
console.log(" 🩹 Post-processing the generated code");
|
181 |
+
await postProcessOutput(`${dirPath}/inference.ts`, outputSpec);
|
182 |
+
}
|
183 |
+
console.debug("✅ All done!");
|
184 |
+
}
|
185 |
+
|
186 |
+
let exit = 0;
|
187 |
+
main()
|
188 |
+
.catch((err) => {
|
189 |
+
console.error("Failure", err);
|
190 |
+
exit = 1;
|
191 |
+
})
|
192 |
+
.finally(() => process.exit(exit));
|
packages/tasks/src/tasks/audio-classification/inference.ts
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
/**
|
7 |
+
* Inputs for Audio Classification inference
|
8 |
+
*/
|
9 |
+
export interface AudioClassificationInput {
|
10 |
+
/**
|
11 |
+
* The input audio data
|
12 |
+
*/
|
13 |
+
data: unknown;
|
14 |
+
/**
|
15 |
+
* Additional inference parameters
|
16 |
+
*/
|
17 |
+
parameters?: AudioClassificationParameters;
|
18 |
+
[property: string]: unknown;
|
19 |
+
}
|
20 |
+
/**
|
21 |
+
* Additional inference parameters
|
22 |
+
*
|
23 |
+
* Additional inference parameters for Audio Classification
|
24 |
+
*/
|
25 |
+
export interface AudioClassificationParameters {
|
26 |
+
functionToApply?: ClassificationOutputTransform;
|
27 |
+
/**
|
28 |
+
* When specified, limits the output to the top K most probable classes.
|
29 |
+
*/
|
30 |
+
topK?: number;
|
31 |
+
[property: string]: unknown;
|
32 |
+
}
|
33 |
+
/**
|
34 |
+
* The function to apply to the model outputs in order to retrieve the scores.
|
35 |
+
*/
|
36 |
+
export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none";
|
37 |
+
export type AudioClassificationOutput = AudioClassificationOutputElement[];
|
38 |
+
/**
|
39 |
+
* Outputs for Audio Classification inference
|
40 |
+
*/
|
41 |
+
export interface AudioClassificationOutputElement {
|
42 |
+
/**
|
43 |
+
* The predicted class label (model specific).
|
44 |
+
*/
|
45 |
+
label: string;
|
46 |
+
/**
|
47 |
+
* The corresponding probability.
|
48 |
+
*/
|
49 |
+
score: number;
|
50 |
+
[property: string]: unknown;
|
51 |
+
}
|
packages/tasks/src/tasks/audio-classification/spec/input.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/audio-classification/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Audio Classification inference",
|
5 |
+
"title": "AudioClassificationInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "The input audio data"
|
10 |
+
},
|
11 |
+
"parameters": {
|
12 |
+
"description": "Additional inference parameters",
|
13 |
+
"$ref": "#/$defs/AudioClassificationParameters"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"$defs": {
|
17 |
+
"AudioClassificationParameters": {
|
18 |
+
"title": "AudioClassificationParameters",
|
19 |
+
"description": "Additional inference parameters for Audio Classification",
|
20 |
+
"type": "object",
|
21 |
+
"properties": {
|
22 |
+
"functionToApply": {
|
23 |
+
"title": "AudioClassificationOutputTransform",
|
24 |
+
"$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform"
|
25 |
+
},
|
26 |
+
"topK": {
|
27 |
+
"type": "integer",
|
28 |
+
"description": "When specified, limits the output to the top K most probable classes."
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
},
|
33 |
+
"required": ["data"]
|
34 |
+
}
|
packages/tasks/src/tasks/audio-classification/spec/output.json
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/audio-classification/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"title": "AudioClassificationOutput",
|
5 |
+
"description": "Outputs for Audio Classification inference",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"type": "object",
|
9 |
+
"properties": {
|
10 |
+
"label": {
|
11 |
+
"type": "string",
|
12 |
+
"description": "The predicted class label (model specific)."
|
13 |
+
},
|
14 |
+
"score": {
|
15 |
+
"type": "number",
|
16 |
+
"description": "The corresponding probability."
|
17 |
+
}
|
18 |
+
},
|
19 |
+
"required": ["label", "score"]
|
20 |
+
}
|
21 |
+
}
|
packages/tasks/src/tasks/automatic-speech-recognition/inference.ts
ADDED
@@ -0,0 +1,154 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
/**
|
7 |
+
* Inputs for Automatic Speech Recognition inference
|
8 |
+
*/
|
9 |
+
export interface AutomaticSpeechRecognitionInput {
|
10 |
+
/**
|
11 |
+
* The input audio data
|
12 |
+
*/
|
13 |
+
data: unknown;
|
14 |
+
/**
|
15 |
+
* Additional inference parameters
|
16 |
+
*/
|
17 |
+
parameters?: AutomaticSpeechRecognitionParameters;
|
18 |
+
[property: string]: unknown;
|
19 |
+
}
|
20 |
+
/**
|
21 |
+
* Additional inference parameters
|
22 |
+
*
|
23 |
+
* Additional inference parameters for Automatic Speech Recognition
|
24 |
+
*/
|
25 |
+
export interface AutomaticSpeechRecognitionParameters {
|
26 |
+
/**
|
27 |
+
* Parametrization of the text generation process
|
28 |
+
*/
|
29 |
+
generate?: GenerationParameters;
|
30 |
+
/**
|
31 |
+
* Whether to output corresponding timestamps with the generated text
|
32 |
+
*/
|
33 |
+
returnTimestamps?: boolean;
|
34 |
+
[property: string]: unknown;
|
35 |
+
}
|
36 |
+
/**
|
37 |
+
* Parametrization of the text generation process
|
38 |
+
*
|
39 |
+
* Ad-hoc parametrization of the text generation process
|
40 |
+
*/
|
41 |
+
export interface GenerationParameters {
|
42 |
+
/**
|
43 |
+
* Whether to use sampling instead of greedy decoding when generating new tokens.
|
44 |
+
*/
|
45 |
+
doSample?: boolean;
|
46 |
+
/**
|
47 |
+
* Controls the stopping condition for beam-based methods.
|
48 |
+
*/
|
49 |
+
earlyStopping?: EarlyStoppingUnion;
|
50 |
+
/**
|
51 |
+
* If set to float strictly between 0 and 1, only tokens with a conditional probability
|
52 |
+
* greater than epsilon_cutoff will be sampled. In the paper, suggested values range from
|
53 |
+
* 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language
|
54 |
+
* Model Desmoothing](https://hf.co/papers/2210.15191) for more details.
|
55 |
+
*/
|
56 |
+
epsilonCutoff?: number;
|
57 |
+
/**
|
58 |
+
* Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to
|
59 |
+
* float strictly between 0 and 1, a token is only considered if it is greater than either
|
60 |
+
* eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter
|
61 |
+
* term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In
|
62 |
+
* the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model.
|
63 |
+
* See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191)
|
64 |
+
* for more details.
|
65 |
+
*/
|
66 |
+
etaCutoff?: number;
|
67 |
+
/**
|
68 |
+
* The maximum length (in tokens) of the generated text, including the input.
|
69 |
+
*/
|
70 |
+
maxLength?: number;
|
71 |
+
/**
|
72 |
+
* The maximum number of tokens to generate. Takes precedence over maxLength.
|
73 |
+
*/
|
74 |
+
maxNewTokens?: number;
|
75 |
+
/**
|
76 |
+
* The minimum length (in tokens) of the generated text, including the input.
|
77 |
+
*/
|
78 |
+
minLength?: number;
|
79 |
+
/**
|
80 |
+
* The minimum number of tokens to generate. Takes precedence over maxLength.
|
81 |
+
*/
|
82 |
+
minNewTokens?: number;
|
83 |
+
/**
|
84 |
+
* Number of groups to divide num_beams into in order to ensure diversity among different
|
85 |
+
* groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details.
|
86 |
+
*/
|
87 |
+
numBeamGroups?: number;
|
88 |
+
/**
|
89 |
+
* Number of beams to use for beam search.
|
90 |
+
*/
|
91 |
+
numBeams?: number;
|
92 |
+
/**
|
93 |
+
* The value balances the model confidence and the degeneration penalty in contrastive
|
94 |
+
* search decoding.
|
95 |
+
*/
|
96 |
+
penaltyAlpha?: number;
|
97 |
+
/**
|
98 |
+
* The value used to modulate the next token probabilities.
|
99 |
+
*/
|
100 |
+
temperature?: number;
|
101 |
+
/**
|
102 |
+
* The number of highest probability vocabulary tokens to keep for top-k-filtering.
|
103 |
+
*/
|
104 |
+
topK?: number;
|
105 |
+
/**
|
106 |
+
* If set to float < 1, only the smallest set of most probable tokens with probabilities
|
107 |
+
* that add up to top_p or higher are kept for generation.
|
108 |
+
*/
|
109 |
+
topP?: number;
|
110 |
+
/**
|
111 |
+
* Local typicality measures how similar the conditional probability of predicting a target
|
112 |
+
* token next is to the expected conditional probability of predicting a random token next,
|
113 |
+
* given the partial text already generated. If set to float < 1, the smallest set of the
|
114 |
+
* most locally typical tokens with probabilities that add up to typical_p or higher are
|
115 |
+
* kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details.
|
116 |
+
*/
|
117 |
+
typicalP?: number;
|
118 |
+
/**
|
119 |
+
* Whether the model should use the past last key/values attentions to speed up decoding
|
120 |
+
*/
|
121 |
+
useCache?: boolean;
|
122 |
+
[property: string]: unknown;
|
123 |
+
}
|
124 |
+
/**
|
125 |
+
* Controls the stopping condition for beam-based methods.
|
126 |
+
*/
|
127 |
+
export type EarlyStoppingUnion = boolean | "never";
|
128 |
+
export interface AutomaticSpeechRecognitionOutputChunk {
|
129 |
+
/**
|
130 |
+
* A chunk of text identified by the model
|
131 |
+
*/
|
132 |
+
text: string;
|
133 |
+
/**
|
134 |
+
* The start and end timestamps corresponding with the text
|
135 |
+
*/
|
136 |
+
timestamps: number[];
|
137 |
+
[property: string]: unknown;
|
138 |
+
}
|
139 |
+
export type AutomaticSpeechRecognitionOutput = AutomaticSpeechRecognitionOutputElement[];
|
140 |
+
/**
|
141 |
+
* Outputs of inference for the Automatic Speech Recognition task
|
142 |
+
*/
|
143 |
+
export interface AutomaticSpeechRecognitionOutputElement {
|
144 |
+
/**
|
145 |
+
* When returnTimestamps is enabled, chunks contains a list of audio chunks identified by
|
146 |
+
* the model.
|
147 |
+
*/
|
148 |
+
chunks?: AutomaticSpeechRecognitionOutputChunk[];
|
149 |
+
/**
|
150 |
+
* The recognized text.
|
151 |
+
*/
|
152 |
+
text: string;
|
153 |
+
[property: string]: unknown;
|
154 |
+
}
|
packages/tasks/src/tasks/automatic-speech-recognition/spec/input.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/automatic-speech-recognition/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Automatic Speech Recognition inference",
|
5 |
+
"title": "AutomaticSpeechRecognitionInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "The input audio data"
|
10 |
+
},
|
11 |
+
"parameters": {
|
12 |
+
"description": "Additional inference parameters",
|
13 |
+
"$ref": "#/$defs/AutomaticSpeechRecognitionParameters"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"$defs": {
|
17 |
+
"AutomaticSpeechRecognitionParameters": {
|
18 |
+
"title": "AutomaticSpeechRecognitionParameters",
|
19 |
+
"description": "Additional inference parameters for Automatic Speech Recognition",
|
20 |
+
"type": "object",
|
21 |
+
"properties": {
|
22 |
+
"returnTimestamps": {
|
23 |
+
"type": "boolean",
|
24 |
+
"description": "Whether to output corresponding timestamps with the generated text"
|
25 |
+
},
|
26 |
+
"generate": {
|
27 |
+
"description": "Parametrization of the text generation process",
|
28 |
+
"$ref": "/inference/schemas/common-definitions.json#/definitions/GenerationParameters"
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
},
|
33 |
+
"required": ["data"]
|
34 |
+
}
|
packages/tasks/src/tasks/automatic-speech-recognition/spec/output.json
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/automatic-speech-recognition/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Outputs of inference for the Automatic Speech Recognition task",
|
5 |
+
"title": "AutomaticSpeechRecognitionOutput",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"type": "object",
|
9 |
+
"properties": {
|
10 |
+
"text": {
|
11 |
+
"type": "string",
|
12 |
+
"description": "The recognized text."
|
13 |
+
},
|
14 |
+
"chunks": {
|
15 |
+
"type": "array",
|
16 |
+
"description": "When returnTimestamps is enabled, chunks contains a list of audio chunks identified by the model.",
|
17 |
+
"items": {
|
18 |
+
"type": "object",
|
19 |
+
"title": "AutomaticSpeechRecognitionOutputChunk",
|
20 |
+
"properties": {
|
21 |
+
"text": { "type": "string", "description": "A chunk of text identified by the model" },
|
22 |
+
"timestamps": {
|
23 |
+
"type": "array",
|
24 |
+
"description": "The start and end timestamps corresponding with the text",
|
25 |
+
"items": { "type": "number" },
|
26 |
+
"minLength": 2,
|
27 |
+
"maxLength": 2
|
28 |
+
}
|
29 |
+
},
|
30 |
+
"required": ["text", "timestamps"]
|
31 |
+
}
|
32 |
+
}
|
33 |
+
},
|
34 |
+
"required": ["text"]
|
35 |
+
}
|
36 |
+
}
|
packages/tasks/src/tasks/common-definitions.json
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/common-definitions.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "(Incomplete!) Common type definitions shared by several tasks",
|
5 |
+
"definitions": {
|
6 |
+
"ClassificationOutputTransform": {
|
7 |
+
"title": "ClassificationOutputTransform",
|
8 |
+
"type": "string",
|
9 |
+
"description": "The function to apply to the model outputs in order to retrieve the scores.",
|
10 |
+
"oneOf": [
|
11 |
+
{
|
12 |
+
"const": "sigmoid"
|
13 |
+
},
|
14 |
+
{
|
15 |
+
"const": "softmax"
|
16 |
+
},
|
17 |
+
{
|
18 |
+
"const": "none"
|
19 |
+
}
|
20 |
+
]
|
21 |
+
},
|
22 |
+
"ClassificationOutput": {
|
23 |
+
"title": "ClassificationOutput",
|
24 |
+
"type": "object",
|
25 |
+
"properties": {
|
26 |
+
"label": {
|
27 |
+
"type": "string",
|
28 |
+
"description": "The predicted class label."
|
29 |
+
},
|
30 |
+
"score": {
|
31 |
+
"type": "number",
|
32 |
+
"description": "The corresponding probability."
|
33 |
+
}
|
34 |
+
},
|
35 |
+
"required": ["label", "score"]
|
36 |
+
},
|
37 |
+
"GenerationParameters": {
|
38 |
+
"title": "GenerationParameters",
|
39 |
+
"description": "Ad-hoc parametrization of the text generation process",
|
40 |
+
"type": "object",
|
41 |
+
"properties": {
|
42 |
+
"temperature": {
|
43 |
+
"type": "number",
|
44 |
+
"description": "The value used to modulate the next token probabilities."
|
45 |
+
},
|
46 |
+
"topK": {
|
47 |
+
"type": "integer",
|
48 |
+
"description": "The number of highest probability vocabulary tokens to keep for top-k-filtering."
|
49 |
+
},
|
50 |
+
"topP": {
|
51 |
+
"type": "number",
|
52 |
+
"description": "If set to float < 1, only the smallest set of most probable tokens with probabilities that add up to top_p or higher are kept for generation."
|
53 |
+
},
|
54 |
+
"typicalP": {
|
55 |
+
"type": "number",
|
56 |
+
"description": " Local typicality measures how similar the conditional probability of predicting a target token next is to the expected conditional probability of predicting a random token next, given the partial text already generated. If set to float < 1, the smallest set of the most locally typical tokens with probabilities that add up to typical_p or higher are kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details."
|
57 |
+
},
|
58 |
+
"epsilonCutoff": {
|
59 |
+
"type": "number",
|
60 |
+
"description": "If set to float strictly between 0 and 1, only tokens with a conditional probability greater than epsilon_cutoff will be sampled. In the paper, suggested values range from 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) for more details."
|
61 |
+
},
|
62 |
+
"etaCutoff": {
|
63 |
+
"type": "number",
|
64 |
+
"description": "Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to float strictly between 0 and 1, a token is only considered if it is greater than either eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model. See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191) for more details."
|
65 |
+
},
|
66 |
+
"maxLength": {
|
67 |
+
"type": "integer",
|
68 |
+
"description": "The maximum length (in tokens) of the generated text, including the input."
|
69 |
+
},
|
70 |
+
"maxNewTokens": {
|
71 |
+
"type": "integer",
|
72 |
+
"description": "The maximum number of tokens to generate. Takes precedence over maxLength."
|
73 |
+
},
|
74 |
+
"minLength": {
|
75 |
+
"type": "integer",
|
76 |
+
"description": "The minimum length (in tokens) of the generated text, including the input."
|
77 |
+
},
|
78 |
+
"minNewTokens": {
|
79 |
+
"type": "integer",
|
80 |
+
"description": "The minimum number of tokens to generate. Takes precedence over maxLength."
|
81 |
+
},
|
82 |
+
"doSample": {
|
83 |
+
"type": "boolean",
|
84 |
+
"description": "Whether to use sampling instead of greedy decoding when generating new tokens."
|
85 |
+
},
|
86 |
+
"earlyStopping": {
|
87 |
+
"description": "Controls the stopping condition for beam-based methods.",
|
88 |
+
"oneOf": [{ "type": "boolean" }, { "const": "never", "type": "string" }]
|
89 |
+
},
|
90 |
+
"numBeams": {
|
91 |
+
"type": "integer",
|
92 |
+
"description": "Number of beams to use for beam search."
|
93 |
+
},
|
94 |
+
"numBeamGroups": {
|
95 |
+
"type": "integer",
|
96 |
+
"description": "Number of groups to divide num_beams into in order to ensure diversity among different groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details."
|
97 |
+
},
|
98 |
+
"penaltyAlpha": {
|
99 |
+
"type": "number",
|
100 |
+
"description": "The value balances the model confidence and the degeneration penalty in contrastive search decoding."
|
101 |
+
},
|
102 |
+
"useCache": {
|
103 |
+
"type": "boolean",
|
104 |
+
"description": "Whether the model should use the past last key/values attentions to speed up decoding"
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
}
|
109 |
+
}
|
packages/tasks/src/tasks/depth-estimation/inference.ts
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
|
7 |
+
export type DepthEstimationOutput = unknown[];
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Inputs for Depth Estimation inference
|
11 |
+
*/
|
12 |
+
export interface DepthEstimationInput {
|
13 |
+
/**
|
14 |
+
* The input image data
|
15 |
+
*/
|
16 |
+
data: unknown;
|
17 |
+
/**
|
18 |
+
* Additional inference parameters
|
19 |
+
*/
|
20 |
+
parameters?: DepthEstimationParameters;
|
21 |
+
[property: string]: unknown;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Additional inference parameters
|
26 |
+
*
|
27 |
+
* Additional inference parameters for Depth Estimation
|
28 |
+
*/
|
29 |
+
export interface DepthEstimationParameters {
|
30 |
+
/**
|
31 |
+
* When specified, limits the output to the top K most probable classes.
|
32 |
+
*/
|
33 |
+
topK?: number;
|
34 |
+
[property: string]: unknown;
|
35 |
+
}
|
packages/tasks/src/tasks/depth-estimation/spec/input.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/depth-estimation/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Depth Estimation inference",
|
5 |
+
"title": "DepthEstimationInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "The input image data"
|
10 |
+
},
|
11 |
+
"parameters": {
|
12 |
+
"description": "Additional inference parameters",
|
13 |
+
"$ref": "#/$defs/DepthEstimationParameters"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"$defs": {
|
17 |
+
"DepthEstimationParameters": {
|
18 |
+
"title": "DepthEstimationParameters",
|
19 |
+
"description": "Additional inference parameters for Depth Estimation",
|
20 |
+
"type": "object",
|
21 |
+
"properties": {
|
22 |
+
"topK": {
|
23 |
+
"type": "integer",
|
24 |
+
"description": "When specified, limits the output to the top K most probable classes."
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
},
|
29 |
+
"required": ["data"]
|
30 |
+
}
|
packages/tasks/src/tasks/depth-estimation/spec/output.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/depth-estimation/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Outputs of inference for the Depth Estimation task",
|
5 |
+
"title": "DepthEstimationOutput",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"description": "The output depth labels"
|
9 |
+
}
|
10 |
+
}
|
packages/tasks/src/tasks/document-question-answering/inference.ts
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
/**
|
7 |
+
* Inputs for Document Question Answering inference
|
8 |
+
*/
|
9 |
+
export interface DocumentQuestionAnsweringInput {
|
10 |
+
/**
|
11 |
+
* One (document, question) pair to answer
|
12 |
+
*/
|
13 |
+
data: DocumentQuestionAnsweringInputData;
|
14 |
+
/**
|
15 |
+
* Additional inference parameters
|
16 |
+
*/
|
17 |
+
parameters?: DocumentQuestionAnsweringParameters;
|
18 |
+
[property: string]: unknown;
|
19 |
+
}
|
20 |
+
/**
|
21 |
+
* One (document, question) pair to answer
|
22 |
+
*/
|
23 |
+
export interface DocumentQuestionAnsweringInputData {
|
24 |
+
/**
|
25 |
+
* The image on which the question is asked
|
26 |
+
*/
|
27 |
+
image: unknown;
|
28 |
+
/**
|
29 |
+
* A question to ask of the document
|
30 |
+
*/
|
31 |
+
question: string;
|
32 |
+
[property: string]: unknown;
|
33 |
+
}
|
34 |
+
/**
|
35 |
+
* Additional inference parameters
|
36 |
+
*
|
37 |
+
* Additional inference parameters for Document Question Answering
|
38 |
+
*/
|
39 |
+
export interface DocumentQuestionAnsweringParameters {
|
40 |
+
/**
|
41 |
+
* If the words in the document are too long to fit with the question for the model, it will
|
42 |
+
* be split in several chunks with some overlap. This argument controls the size of that
|
43 |
+
* overlap.
|
44 |
+
*/
|
45 |
+
docStride?: number;
|
46 |
+
/**
|
47 |
+
* Whether to accept impossible as an answer
|
48 |
+
*/
|
49 |
+
handleImpossibleAnswer?: boolean;
|
50 |
+
/**
|
51 |
+
* Language to use while running OCR. Defaults to english.
|
52 |
+
*/
|
53 |
+
lang?: string;
|
54 |
+
/**
|
55 |
+
* The maximum length of predicted answers (e.g., only answers with a shorter length are
|
56 |
+
* considered).
|
57 |
+
*/
|
58 |
+
maxAnswerLen?: number;
|
59 |
+
/**
|
60 |
+
* The maximum length of the question after tokenization. It will be truncated if needed.
|
61 |
+
*/
|
62 |
+
maxQuestionLen?: number;
|
63 |
+
/**
|
64 |
+
* The maximum length of the total sentence (context + question) in tokens of each chunk
|
65 |
+
* passed to the model. The context will be split in several chunks (using doc_stride as
|
66 |
+
* overlap) if needed.
|
67 |
+
*/
|
68 |
+
maxSeqLen?: number;
|
69 |
+
/**
|
70 |
+
* The number of answers to return (will be chosen by order of likelihood). Can return less
|
71 |
+
* than top_k answers if there are not enough options available within the context.
|
72 |
+
*/
|
73 |
+
topK?: number;
|
74 |
+
/**
|
75 |
+
* A list of words and bounding boxes (normalized 0->1000). If provided, the inference will
|
76 |
+
* skip the OCR step and use the provided bounding boxes instead.
|
77 |
+
*/
|
78 |
+
wordBoxes?: WordBox[];
|
79 |
+
[property: string]: unknown;
|
80 |
+
}
|
81 |
+
export type WordBox = number[] | string;
|
82 |
+
export type DocumentQuestionAnsweringOutput = DocumentQuestionAnsweringOutputElement[];
|
83 |
+
/**
|
84 |
+
* Outputs of inference for the Document Question Answering task
|
85 |
+
*/
|
86 |
+
export interface DocumentQuestionAnsweringOutputElement {
|
87 |
+
/**
|
88 |
+
* The answer to the question.
|
89 |
+
*/
|
90 |
+
answer: string;
|
91 |
+
end: number;
|
92 |
+
/**
|
93 |
+
* The probability associated to the answer.
|
94 |
+
*/
|
95 |
+
score: number;
|
96 |
+
start: number;
|
97 |
+
/**
|
98 |
+
* The index of each word/box pair that is in the answer
|
99 |
+
*/
|
100 |
+
words: number[];
|
101 |
+
[property: string]: unknown;
|
102 |
+
}
|
packages/tasks/src/tasks/document-question-answering/spec/input.json
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/document-question-answering/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Document Question Answering inference",
|
5 |
+
"title": "DocumentQuestionAnsweringInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "One (document, question) pair to answer",
|
10 |
+
"type": "object",
|
11 |
+
"title": "DocumentQuestionAnsweringInputData",
|
12 |
+
"properties": {
|
13 |
+
"image": {
|
14 |
+
"description": "The image on which the question is asked"
|
15 |
+
},
|
16 |
+
"question": {
|
17 |
+
"type": "string",
|
18 |
+
"description": "A question to ask of the document"
|
19 |
+
}
|
20 |
+
},
|
21 |
+
"required": ["image", "question"]
|
22 |
+
},
|
23 |
+
"parameters": {
|
24 |
+
"description": "Additional inference parameters",
|
25 |
+
"$ref": "#/$defs/DocumentQuestionAnsweringParameters"
|
26 |
+
}
|
27 |
+
},
|
28 |
+
"$defs": {
|
29 |
+
"DocumentQuestionAnsweringParameters": {
|
30 |
+
"title": "DocumentQuestionAnsweringParameters",
|
31 |
+
"description": "Additional inference parameters for Document Question Answering",
|
32 |
+
"type": "object",
|
33 |
+
"properties": {
|
34 |
+
"docStride": {
|
35 |
+
"type": "integer",
|
36 |
+
"description": "If the words in the document are too long to fit with the question for the model, it will be split in several chunks with some overlap. This argument controls the size of that overlap."
|
37 |
+
},
|
38 |
+
"handleImpossibleAnswer": {
|
39 |
+
"type": "boolean",
|
40 |
+
"description": "Whether to accept impossible as an answer"
|
41 |
+
},
|
42 |
+
"lang": {
|
43 |
+
"type": "string",
|
44 |
+
"description": "Language to use while running OCR. Defaults to english."
|
45 |
+
},
|
46 |
+
"maxAnswerLen": {
|
47 |
+
"type": "integer",
|
48 |
+
"description": "The maximum length of predicted answers (e.g., only answers with a shorter length are considered)."
|
49 |
+
},
|
50 |
+
"maxSeqLen": {
|
51 |
+
"type": "integer",
|
52 |
+
"description": "The maximum length of the total sentence (context + question) in tokens of each chunk passed to the model. The context will be split in several chunks (using doc_stride as overlap) if needed."
|
53 |
+
},
|
54 |
+
"maxQuestionLen": {
|
55 |
+
"type": "integer",
|
56 |
+
"description": "The maximum length of the question after tokenization. It will be truncated if needed."
|
57 |
+
},
|
58 |
+
"topK": {
|
59 |
+
"type": "integer",
|
60 |
+
"description": "The number of answers to return (will be chosen by order of likelihood). Can return less than top_k answers if there are not enough options available within the context."
|
61 |
+
},
|
62 |
+
"wordBoxes": {
|
63 |
+
"type": "array",
|
64 |
+
"description": "A list of words and bounding boxes (normalized 0->1000). If provided, the inference will skip the OCR step and use the provided bounding boxes instead.",
|
65 |
+
"items": {
|
66 |
+
"anyOf": [
|
67 |
+
{
|
68 |
+
"type": "string"
|
69 |
+
},
|
70 |
+
{
|
71 |
+
"type": "array",
|
72 |
+
"items": {
|
73 |
+
"type": "number"
|
74 |
+
},
|
75 |
+
"maxLength": 4,
|
76 |
+
"minLength": 4
|
77 |
+
}
|
78 |
+
]
|
79 |
+
}
|
80 |
+
}
|
81 |
+
}
|
82 |
+
}
|
83 |
+
},
|
84 |
+
"required": ["data"]
|
85 |
+
}
|
packages/tasks/src/tasks/document-question-answering/spec/output.json
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/document-question-answering/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Outputs of inference for the Document Question Answering task",
|
5 |
+
"title": "DocumentQuestionAnsweringOutput",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"type": "object",
|
9 |
+
"properties": {
|
10 |
+
"answer": {
|
11 |
+
"type": "string",
|
12 |
+
"description": "The answer to the question."
|
13 |
+
},
|
14 |
+
"score": {
|
15 |
+
"type": "number",
|
16 |
+
"description": "The probability associated to the answer."
|
17 |
+
},
|
18 |
+
"start": {
|
19 |
+
"type": "integer",
|
20 |
+
"descrtiption": "The start word index of the answer (in the OCR’d version of the input or provided word boxes)."
|
21 |
+
},
|
22 |
+
"end": {
|
23 |
+
"type": "integer",
|
24 |
+
"descrtiption": "The end word index of the answer (in the OCR’d version of the input or provided word boxes)."
|
25 |
+
},
|
26 |
+
"words": {
|
27 |
+
"type": "array",
|
28 |
+
"items": {
|
29 |
+
"type": "integer"
|
30 |
+
},
|
31 |
+
"description": "The index of each word/box pair that is in the answer"
|
32 |
+
}
|
33 |
+
},
|
34 |
+
"required": ["answer", "score", "start", "end", "words"]
|
35 |
+
}
|
36 |
+
}
|
packages/tasks/src/tasks/feature-extraction/inference.ts
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
|
7 |
+
export type FeatureExtractionOutput = unknown[];
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Inputs for Text Embedding inference
|
11 |
+
*/
|
12 |
+
export interface FeatureExtractionInput {
|
13 |
+
/**
|
14 |
+
* The text to get the embeddings of
|
15 |
+
*/
|
16 |
+
data: string;
|
17 |
+
/**
|
18 |
+
* Additional inference parameters
|
19 |
+
*/
|
20 |
+
parameters?: { [key: string]: unknown };
|
21 |
+
[property: string]: unknown;
|
22 |
+
}
|
packages/tasks/src/tasks/feature-extraction/spec/input.json
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/feature-extraction/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Text Embedding inference",
|
5 |
+
"title": "FeatureExtractionInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "The text to get the embeddings of",
|
10 |
+
"type": "string"
|
11 |
+
},
|
12 |
+
"parameters": {
|
13 |
+
"description": "Additional inference parameters",
|
14 |
+
"$ref": "#/$defs/FeatureExtractionParameters"
|
15 |
+
}
|
16 |
+
},
|
17 |
+
"$defs": {
|
18 |
+
"FeatureExtractionParameters": {
|
19 |
+
"title": "FeatureExtractionParameters",
|
20 |
+
"description": "Additional inference parameters for Feature Extraction",
|
21 |
+
"type": "object",
|
22 |
+
"properties": {}
|
23 |
+
}
|
24 |
+
},
|
25 |
+
"required": ["data"]
|
26 |
+
}
|
packages/tasks/src/tasks/feature-extraction/spec/output.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/feature-extraction/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "The embedding for the input text, as a nested list (tensor) of floats",
|
5 |
+
"type": "array",
|
6 |
+
"title": "FeatureExtractionOutput"
|
7 |
+
}
|
packages/tasks/src/tasks/fill-mask/inference.ts
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
/**
|
7 |
+
* Inputs for Fill Mask inference
|
8 |
+
*/
|
9 |
+
export interface FillMaskInput {
|
10 |
+
/**
|
11 |
+
* The text with masked tokens
|
12 |
+
*/
|
13 |
+
data: string;
|
14 |
+
/**
|
15 |
+
* Additional inference parameters
|
16 |
+
*/
|
17 |
+
parameters?: FillMaskParameters;
|
18 |
+
[property: string]: unknown;
|
19 |
+
}
|
20 |
+
/**
|
21 |
+
* Additional inference parameters
|
22 |
+
*
|
23 |
+
* Additional inference parameters for Fill Mask
|
24 |
+
*/
|
25 |
+
export interface FillMaskParameters {
|
26 |
+
/**
|
27 |
+
* When passed, the model will limit the scores to the passed targets instead of looking up
|
28 |
+
* in the whole vocabulary. If the provided targets are not in the model vocab, they will be
|
29 |
+
* tokenized and the first resulting token will be used (with a warning, and that might be
|
30 |
+
* slower).
|
31 |
+
*/
|
32 |
+
targets?: string[];
|
33 |
+
/**
|
34 |
+
* When passed, overrides the number of predictions to return.
|
35 |
+
*/
|
36 |
+
topK?: number;
|
37 |
+
[property: string]: unknown;
|
38 |
+
}
|
39 |
+
export type FillMaskOutput = FillMaskOutputElement[];
|
40 |
+
/**
|
41 |
+
* Outputs of inference for the Fill Mask task
|
42 |
+
*/
|
43 |
+
export interface FillMaskOutputElement {
|
44 |
+
/**
|
45 |
+
* The corresponding probability
|
46 |
+
*/
|
47 |
+
score: number;
|
48 |
+
/**
|
49 |
+
* The corresponding input with the mask token prediction.
|
50 |
+
*/
|
51 |
+
sequence: string;
|
52 |
+
/**
|
53 |
+
* The predicted token id (to replace the masked one).
|
54 |
+
*/
|
55 |
+
token: number;
|
56 |
+
/**
|
57 |
+
* The predicted token (to replace the masked one).
|
58 |
+
*/
|
59 |
+
tokenStr: string;
|
60 |
+
[property: string]: unknown;
|
61 |
+
}
|
packages/tasks/src/tasks/fill-mask/spec/input.json
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/fill-mask/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Fill Mask inference",
|
5 |
+
"title": "FillMaskInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "The text with masked tokens",
|
10 |
+
"type": "string"
|
11 |
+
},
|
12 |
+
"parameters": {
|
13 |
+
"description": "Additional inference parameters",
|
14 |
+
"$ref": "#/$defs/FillMaskParameters"
|
15 |
+
}
|
16 |
+
},
|
17 |
+
"$defs": {
|
18 |
+
"FillMaskParameters": {
|
19 |
+
"title": "FillMaskParameters",
|
20 |
+
"description": "Additional inference parameters for Fill Mask",
|
21 |
+
"type": "object",
|
22 |
+
"properties": {
|
23 |
+
"topK": {
|
24 |
+
"type": "integer",
|
25 |
+
"description": "When passed, overrides the number of predictions to return."
|
26 |
+
},
|
27 |
+
"targets": {
|
28 |
+
"description": "When passed, the model will limit the scores to the passed targets instead of looking up in the whole vocabulary. If the provided targets are not in the model vocab, they will be tokenized and the first resulting token will be used (with a warning, and that might be slower).",
|
29 |
+
"type": "array",
|
30 |
+
"items": {
|
31 |
+
"type": "string"
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
},
|
37 |
+
"required": ["data"]
|
38 |
+
}
|
packages/tasks/src/tasks/fill-mask/spec/output.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/fill-mask/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Outputs of inference for the Fill Mask task",
|
5 |
+
"title": "FillMaskOutput",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"type": "object",
|
9 |
+
"properties": {
|
10 |
+
"sequence": {
|
11 |
+
"type": "string",
|
12 |
+
"description": "The corresponding input with the mask token prediction."
|
13 |
+
},
|
14 |
+
"score": {
|
15 |
+
"type": "number",
|
16 |
+
"description": "The corresponding probability"
|
17 |
+
},
|
18 |
+
"token": {
|
19 |
+
"type": "integer",
|
20 |
+
"description": "The predicted token id (to replace the masked one)."
|
21 |
+
},
|
22 |
+
"tokenStr": {
|
23 |
+
"type": "string",
|
24 |
+
"description": "The predicted token (to replace the masked one)."
|
25 |
+
}
|
26 |
+
},
|
27 |
+
"required": ["sequence", "score", "token", "tokenStr"]
|
28 |
+
}
|
29 |
+
}
|
packages/tasks/src/tasks/image-classification/inference.ts
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
/**
|
7 |
+
* Inputs for Image Classification inference
|
8 |
+
*/
|
9 |
+
export interface ImageClassificationInput {
|
10 |
+
/**
|
11 |
+
* The input image data
|
12 |
+
*/
|
13 |
+
data: unknown;
|
14 |
+
/**
|
15 |
+
* Additional inference parameters
|
16 |
+
*/
|
17 |
+
parameters?: ImageClassificationParameters;
|
18 |
+
[property: string]: unknown;
|
19 |
+
}
|
20 |
+
/**
|
21 |
+
* Additional inference parameters
|
22 |
+
*
|
23 |
+
* Additional inference parameters for Image Classification
|
24 |
+
*/
|
25 |
+
export interface ImageClassificationParameters {
|
26 |
+
functionToApply?: ClassificationOutputTransform;
|
27 |
+
/**
|
28 |
+
* When specified, limits the output to the top K most probable classes.
|
29 |
+
*/
|
30 |
+
topK?: number;
|
31 |
+
[property: string]: unknown;
|
32 |
+
}
|
33 |
+
/**
|
34 |
+
* The function to apply to the model outputs in order to retrieve the scores.
|
35 |
+
*/
|
36 |
+
export type ClassificationOutputTransform = "sigmoid" | "softmax" | "none";
|
37 |
+
export type ImageClassificationOutput = ImageClassificationOutputElement[];
|
38 |
+
/**
|
39 |
+
* Outputs of inference for the Image Classification task
|
40 |
+
*/
|
41 |
+
export interface ImageClassificationOutputElement {
|
42 |
+
/**
|
43 |
+
* The predicted class label.
|
44 |
+
*/
|
45 |
+
label: string;
|
46 |
+
/**
|
47 |
+
* The corresponding probability.
|
48 |
+
*/
|
49 |
+
score: number;
|
50 |
+
[property: string]: unknown;
|
51 |
+
}
|
packages/tasks/src/tasks/image-classification/spec/input.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/image-classification/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Image Classification inference",
|
5 |
+
"title": "ImageClassificationInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "The input image data"
|
10 |
+
},
|
11 |
+
"parameters": {
|
12 |
+
"description": "Additional inference parameters",
|
13 |
+
"$ref": "#/$defs/ImageClassificationParameters"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"$defs": {
|
17 |
+
"ImageClassificationParameters": {
|
18 |
+
"title": "ImageClassificationParameters",
|
19 |
+
"description": "Additional inference parameters for Image Classification",
|
20 |
+
"type": "object",
|
21 |
+
"properties": {
|
22 |
+
"functionToApply": {
|
23 |
+
"title": "ImageClassificationOutputTransform",
|
24 |
+
"$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform"
|
25 |
+
},
|
26 |
+
"topK": {
|
27 |
+
"type": "integer",
|
28 |
+
"description": "When specified, limits the output to the top K most probable classes."
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
},
|
33 |
+
"required": ["data"]
|
34 |
+
}
|
packages/tasks/src/tasks/image-classification/spec/output.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/image-classification/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Outputs of inference for the Image Classification task",
|
5 |
+
"title": "ImageClassificationOutput",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutput"
|
9 |
+
}
|
10 |
+
}
|
packages/tasks/src/tasks/image-segmentation/inference.ts
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
/**
|
7 |
+
* Inputs for Image Segmentation inference
|
8 |
+
*/
|
9 |
+
export interface ImageSegmentationInput {
|
10 |
+
/**
|
11 |
+
* The input image data
|
12 |
+
*/
|
13 |
+
data: unknown;
|
14 |
+
/**
|
15 |
+
* Additional inference parameters
|
16 |
+
*/
|
17 |
+
parameters?: ImageSegmentationParameters;
|
18 |
+
[property: string]: unknown;
|
19 |
+
}
|
20 |
+
/**
|
21 |
+
* Additional inference parameters
|
22 |
+
*
|
23 |
+
* Additional inference parameters for Image Segmentation
|
24 |
+
*/
|
25 |
+
export interface ImageSegmentationParameters {
|
26 |
+
/**
|
27 |
+
* Threshold to use when turning the predicted masks into binary values.
|
28 |
+
*/
|
29 |
+
maskThreshold?: number;
|
30 |
+
/**
|
31 |
+
* Mask overlap threshold to eliminate small, disconnected segments.
|
32 |
+
*/
|
33 |
+
overlapMaskAreaThreshold?: number;
|
34 |
+
/**
|
35 |
+
* Segmentation task to be performed, depending on model capabilities.
|
36 |
+
*/
|
37 |
+
subtask?: ImageSegmentationSubtask;
|
38 |
+
/**
|
39 |
+
* Probability threshold to filter out predicted masks.
|
40 |
+
*/
|
41 |
+
threshold?: number;
|
42 |
+
[property: string]: unknown;
|
43 |
+
}
|
44 |
+
export type ImageSegmentationSubtask = "instance" | "panoptic" | "semantic";
|
45 |
+
export type ImageSegmentationOutput = ImageSegmentationOutputElement[];
|
46 |
+
/**
|
47 |
+
* Outputs of inference for the Image Segmentation task
|
48 |
+
*
|
49 |
+
* A predicted mask / segment
|
50 |
+
*/
|
51 |
+
export interface ImageSegmentationOutputElement {
|
52 |
+
/**
|
53 |
+
* The label of the predicted segment
|
54 |
+
*/
|
55 |
+
label: string;
|
56 |
+
/**
|
57 |
+
* The corresponding mask as a black-and-white image
|
58 |
+
*/
|
59 |
+
mask: unknown;
|
60 |
+
/**
|
61 |
+
* The score or confidence degreee the model has
|
62 |
+
*/
|
63 |
+
score?: number;
|
64 |
+
[property: string]: unknown;
|
65 |
+
}
|
packages/tasks/src/tasks/image-segmentation/spec/input.json
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/image-segmentation/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Image Segmentation inference",
|
5 |
+
"title": "ImageSegmentationInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "The input image data"
|
10 |
+
},
|
11 |
+
"parameters": {
|
12 |
+
"description": "Additional inference parameters",
|
13 |
+
"$ref": "#/$defs/ImageSegmentationParameters"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"$defs": {
|
17 |
+
"ImageSegmentationParameters": {
|
18 |
+
"title": "ImageSegmentationParameters",
|
19 |
+
"description": "Additional inference parameters for Image Segmentation",
|
20 |
+
"type": "object",
|
21 |
+
"properties": {
|
22 |
+
"maskThreshold": {
|
23 |
+
"type": "number",
|
24 |
+
"description": "Threshold to use when turning the predicted masks into binary values."
|
25 |
+
},
|
26 |
+
"overlapMaskAreaThreshold": {
|
27 |
+
"type": "number",
|
28 |
+
"description": "Mask overlap threshold to eliminate small, disconnected segments."
|
29 |
+
},
|
30 |
+
"subtask": {
|
31 |
+
"title": "ImageSegmentationSubtask",
|
32 |
+
"type": "string",
|
33 |
+
"description": "Segmentation task to be performed, depending on model capabilities.",
|
34 |
+
"oneOf": [
|
35 |
+
{
|
36 |
+
"const": "instance"
|
37 |
+
},
|
38 |
+
{
|
39 |
+
"const": "panoptic"
|
40 |
+
},
|
41 |
+
{
|
42 |
+
"const": "semantic"
|
43 |
+
}
|
44 |
+
]
|
45 |
+
},
|
46 |
+
"threshold": {
|
47 |
+
"type": "number",
|
48 |
+
"description": "Probability threshold to filter out predicted masks."
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
},
|
53 |
+
"required": ["data"]
|
54 |
+
}
|
packages/tasks/src/tasks/image-segmentation/spec/output.json
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/image-segmentation/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Outputs of inference for the Image Segmentation task",
|
5 |
+
"title": "ImageSegmentationOutput",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"description": "A predicted mask / segment",
|
9 |
+
"type": "object",
|
10 |
+
"properties": {
|
11 |
+
"label": {
|
12 |
+
"type": "string",
|
13 |
+
"description": "The label of the predicted segment"
|
14 |
+
},
|
15 |
+
"mask": {
|
16 |
+
"description": "The corresponding mask as a black-and-white image"
|
17 |
+
},
|
18 |
+
"score": {
|
19 |
+
"type": "number",
|
20 |
+
"description": "The score or confidence degreee the model has"
|
21 |
+
}
|
22 |
+
},
|
23 |
+
"required": ["label", "mask"]
|
24 |
+
}
|
25 |
+
}
|
packages/tasks/src/tasks/image-to-image/inference.ts
ADDED
@@ -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 Image To Image inference
|
9 |
+
*/
|
10 |
+
export interface ImageToImageInput {
|
11 |
+
/**
|
12 |
+
* The input image data
|
13 |
+
*/
|
14 |
+
data: unknown;
|
15 |
+
/**
|
16 |
+
* Additional inference parameters
|
17 |
+
*/
|
18 |
+
parameters?: ImageToImageParameters;
|
19 |
+
[property: string]: unknown;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* Additional inference parameters
|
24 |
+
*
|
25 |
+
* Additional inference parameters for Image To Image
|
26 |
+
*/
|
27 |
+
export interface ImageToImageParameters {
|
28 |
+
/**
|
29 |
+
* For diffusion models. A higher guidance scale value encourages the model to generate
|
30 |
+
* images closely linked to the text prompt at the expense of lower image quality.
|
31 |
+
*/
|
32 |
+
guidanceScale?: number;
|
33 |
+
/**
|
34 |
+
* One or several prompt to guide what NOT to include in image generation.
|
35 |
+
*/
|
36 |
+
negativePrompt?: string[];
|
37 |
+
/**
|
38 |
+
* For diffusion models. The number of denoising steps. More denoising steps usually lead to
|
39 |
+
* a higher quality image at the expense of slower inference.
|
40 |
+
*/
|
41 |
+
numInferenceSteps?: number;
|
42 |
+
/**
|
43 |
+
* The size in pixel of the output image
|
44 |
+
*/
|
45 |
+
targetSize?: TargetSize;
|
46 |
+
[property: string]: unknown;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* The size in pixel of the output image
|
51 |
+
*/
|
52 |
+
export interface TargetSize {
|
53 |
+
height: number;
|
54 |
+
width: number;
|
55 |
+
[property: string]: unknown;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Outputs of inference for the Image To Image task
|
60 |
+
*/
|
61 |
+
export interface ImageToImageOutput {
|
62 |
+
/**
|
63 |
+
* The output image
|
64 |
+
*/
|
65 |
+
image?: unknown;
|
66 |
+
[property: string]: unknown;
|
67 |
+
}
|
packages/tasks/src/tasks/image-to-image/spec/input.json
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/image-to-image/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Image To Image inference",
|
5 |
+
"title": "ImageToImageInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "The input image data"
|
10 |
+
},
|
11 |
+
"parameters": {
|
12 |
+
"description": "Additional inference parameters",
|
13 |
+
"$ref": "#/$defs/ImageToImageParameters"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"$defs": {
|
17 |
+
"ImageToImageParameters": {
|
18 |
+
"title": "ImageToImageParameters",
|
19 |
+
"description": "Additional inference parameters for Image To Image",
|
20 |
+
"type": "object",
|
21 |
+
"properties": {
|
22 |
+
"guidanceScale": {
|
23 |
+
"type": "number",
|
24 |
+
"description": "For diffusion models. A higher guidance scale value encourages the model to generate images closely linked to the text prompt at the expense of lower image quality."
|
25 |
+
},
|
26 |
+
"negativePrompt": {
|
27 |
+
"type": "array",
|
28 |
+
"items": { "type": "string" },
|
29 |
+
"description": "One or several prompt to guide what NOT to include in image generation."
|
30 |
+
},
|
31 |
+
"numInferenceSteps": {
|
32 |
+
"type": "integer",
|
33 |
+
"description": "For diffusion models. The number of denoising steps. More denoising steps usually lead to a higher quality image at the expense of slower inference."
|
34 |
+
},
|
35 |
+
"targetSize": {
|
36 |
+
"type": "object",
|
37 |
+
"description": "The size in pixel of the output image",
|
38 |
+
"properties": {
|
39 |
+
"width": {
|
40 |
+
"type": "integer"
|
41 |
+
},
|
42 |
+
"height": {
|
43 |
+
"type": "integer"
|
44 |
+
}
|
45 |
+
},
|
46 |
+
"required": ["width", "height"]
|
47 |
+
}
|
48 |
+
}
|
49 |
+
}
|
50 |
+
},
|
51 |
+
"required": ["data"]
|
52 |
+
}
|
packages/tasks/src/tasks/image-to-image/spec/output.json
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/image-to-image/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Outputs of inference for the Image To Image task",
|
5 |
+
"title": "ImageToImageOutput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"image": {
|
9 |
+
"description": "The output image"
|
10 |
+
}
|
11 |
+
}
|
12 |
+
}
|
packages/tasks/src/tasks/image-to-text/inference.ts
ADDED
@@ -0,0 +1,138 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
/**
|
7 |
+
* Inputs for Image To Text inference
|
8 |
+
*/
|
9 |
+
export interface ImageToTextInput {
|
10 |
+
/**
|
11 |
+
* The input image data
|
12 |
+
*/
|
13 |
+
data: unknown;
|
14 |
+
/**
|
15 |
+
* Additional inference parameters
|
16 |
+
*/
|
17 |
+
parameters?: ImageToTextParameters;
|
18 |
+
[property: string]: unknown;
|
19 |
+
}
|
20 |
+
/**
|
21 |
+
* Additional inference parameters
|
22 |
+
*
|
23 |
+
* Additional inference parameters for Image To Text
|
24 |
+
*/
|
25 |
+
export interface ImageToTextParameters {
|
26 |
+
/**
|
27 |
+
* Parametrization of the text generation process
|
28 |
+
*/
|
29 |
+
generate?: GenerationParameters;
|
30 |
+
/**
|
31 |
+
* The amount of maximum tokens to generate.
|
32 |
+
*/
|
33 |
+
maxNewTokens?: number;
|
34 |
+
[property: string]: unknown;
|
35 |
+
}
|
36 |
+
/**
|
37 |
+
* Parametrization of the text generation process
|
38 |
+
*
|
39 |
+
* Ad-hoc parametrization of the text generation process
|
40 |
+
*/
|
41 |
+
export interface GenerationParameters {
|
42 |
+
/**
|
43 |
+
* Whether to use sampling instead of greedy decoding when generating new tokens.
|
44 |
+
*/
|
45 |
+
doSample?: boolean;
|
46 |
+
/**
|
47 |
+
* Controls the stopping condition for beam-based methods.
|
48 |
+
*/
|
49 |
+
earlyStopping?: EarlyStoppingUnion;
|
50 |
+
/**
|
51 |
+
* If set to float strictly between 0 and 1, only tokens with a conditional probability
|
52 |
+
* greater than epsilon_cutoff will be sampled. In the paper, suggested values range from
|
53 |
+
* 3e-4 to 9e-4, depending on the size of the model. See [Truncation Sampling as Language
|
54 |
+
* Model Desmoothing](https://hf.co/papers/2210.15191) for more details.
|
55 |
+
*/
|
56 |
+
epsilonCutoff?: number;
|
57 |
+
/**
|
58 |
+
* Eta sampling is a hybrid of locally typical sampling and epsilon sampling. If set to
|
59 |
+
* float strictly between 0 and 1, a token is only considered if it is greater than either
|
60 |
+
* eta_cutoff or sqrt(eta_cutoff) * exp(-entropy(softmax(next_token_logits))). The latter
|
61 |
+
* term is intuitively the expected next token probability, scaled by sqrt(eta_cutoff). In
|
62 |
+
* the paper, suggested values range from 3e-4 to 2e-3, depending on the size of the model.
|
63 |
+
* See [Truncation Sampling as Language Model Desmoothing](https://hf.co/papers/2210.15191)
|
64 |
+
* for more details.
|
65 |
+
*/
|
66 |
+
etaCutoff?: number;
|
67 |
+
/**
|
68 |
+
* The maximum length (in tokens) of the generated text, including the input.
|
69 |
+
*/
|
70 |
+
maxLength?: number;
|
71 |
+
/**
|
72 |
+
* The maximum number of tokens to generate. Takes precedence over maxLength.
|
73 |
+
*/
|
74 |
+
maxNewTokens?: number;
|
75 |
+
/**
|
76 |
+
* The minimum length (in tokens) of the generated text, including the input.
|
77 |
+
*/
|
78 |
+
minLength?: number;
|
79 |
+
/**
|
80 |
+
* The minimum number of tokens to generate. Takes precedence over maxLength.
|
81 |
+
*/
|
82 |
+
minNewTokens?: number;
|
83 |
+
/**
|
84 |
+
* Number of groups to divide num_beams into in order to ensure diversity among different
|
85 |
+
* groups of beams. See [this paper](https://hf.co/papers/1610.02424) for more details.
|
86 |
+
*/
|
87 |
+
numBeamGroups?: number;
|
88 |
+
/**
|
89 |
+
* Number of beams to use for beam search.
|
90 |
+
*/
|
91 |
+
numBeams?: number;
|
92 |
+
/**
|
93 |
+
* The value balances the model confidence and the degeneration penalty in contrastive
|
94 |
+
* search decoding.
|
95 |
+
*/
|
96 |
+
penaltyAlpha?: number;
|
97 |
+
/**
|
98 |
+
* The value used to modulate the next token probabilities.
|
99 |
+
*/
|
100 |
+
temperature?: number;
|
101 |
+
/**
|
102 |
+
* The number of highest probability vocabulary tokens to keep for top-k-filtering.
|
103 |
+
*/
|
104 |
+
topK?: number;
|
105 |
+
/**
|
106 |
+
* If set to float < 1, only the smallest set of most probable tokens with probabilities
|
107 |
+
* that add up to top_p or higher are kept for generation.
|
108 |
+
*/
|
109 |
+
topP?: number;
|
110 |
+
/**
|
111 |
+
* Local typicality measures how similar the conditional probability of predicting a target
|
112 |
+
* token next is to the expected conditional probability of predicting a random token next,
|
113 |
+
* given the partial text already generated. If set to float < 1, the smallest set of the
|
114 |
+
* most locally typical tokens with probabilities that add up to typical_p or higher are
|
115 |
+
* kept for generation. See [this paper](https://hf.co/papers/2202.00666) for more details.
|
116 |
+
*/
|
117 |
+
typicalP?: number;
|
118 |
+
/**
|
119 |
+
* Whether the model should use the past last key/values attentions to speed up decoding
|
120 |
+
*/
|
121 |
+
useCache?: boolean;
|
122 |
+
[property: string]: unknown;
|
123 |
+
}
|
124 |
+
/**
|
125 |
+
* Controls the stopping condition for beam-based methods.
|
126 |
+
*/
|
127 |
+
export type EarlyStoppingUnion = boolean | "never";
|
128 |
+
export type ImageToTextOutput = ImageToTextOutputElement[];
|
129 |
+
/**
|
130 |
+
* Outputs of inference for the Image To Text task
|
131 |
+
*/
|
132 |
+
export interface ImageToTextOutputElement {
|
133 |
+
/**
|
134 |
+
* The generated text.
|
135 |
+
*/
|
136 |
+
generatedText: string;
|
137 |
+
[property: string]: unknown;
|
138 |
+
}
|
packages/tasks/src/tasks/image-to-text/spec/input.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/image-to-text/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Image To Text inference",
|
5 |
+
"title": "ImageToTextInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "The input image data"
|
10 |
+
},
|
11 |
+
"parameters": {
|
12 |
+
"description": "Additional inference parameters",
|
13 |
+
"$ref": "#/$defs/ImageToTextParameters"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"$defs": {
|
17 |
+
"ImageToTextParameters": {
|
18 |
+
"title": "ImageToTextParameters",
|
19 |
+
"description": "Additional inference parameters for Image To Text",
|
20 |
+
"type": "object",
|
21 |
+
"properties": {
|
22 |
+
"maxNewTokens": {
|
23 |
+
"type": "integer",
|
24 |
+
"description": "The amount of maximum tokens to generate."
|
25 |
+
},
|
26 |
+
"generate": {
|
27 |
+
"description": "Parametrization of the text generation process",
|
28 |
+
"$ref": "/inference/schemas/common-definitions.json#/definitions/GenerationParameters"
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
},
|
33 |
+
"required": ["data"]
|
34 |
+
}
|
packages/tasks/src/tasks/image-to-text/spec/output.json
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/image-to-text/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Outputs of inference for the Image To Text task",
|
5 |
+
"title": "ImageToTextOutput",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"type": "object",
|
9 |
+
"properties": {
|
10 |
+
"generatedText": {
|
11 |
+
"type": "string",
|
12 |
+
"description": "The generated text."
|
13 |
+
}
|
14 |
+
},
|
15 |
+
"required": ["generatedText"]
|
16 |
+
}
|
17 |
+
}
|
packages/tasks/src/tasks/index.ts
CHANGED
@@ -216,6 +216,7 @@ export interface TaskData {
|
|
216 |
datasets: ExampleRepo[];
|
217 |
demo: TaskDemo;
|
218 |
id: PipelineType;
|
|
|
219 |
isPlaceholder?: boolean;
|
220 |
label: string;
|
221 |
libraries: ModelLibraryKey[];
|
|
|
216 |
datasets: ExampleRepo[];
|
217 |
demo: TaskDemo;
|
218 |
id: PipelineType;
|
219 |
+
canonicalId?: PipelineType;
|
220 |
isPlaceholder?: boolean;
|
221 |
label: string;
|
222 |
libraries: ModelLibraryKey[];
|
packages/tasks/src/tasks/object-detection/inference.ts
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
/**
|
7 |
+
* Inputs for Object Detection inference
|
8 |
+
*/
|
9 |
+
export interface ObjectDetectionInput {
|
10 |
+
/**
|
11 |
+
* The input image data
|
12 |
+
*/
|
13 |
+
data: unknown;
|
14 |
+
/**
|
15 |
+
* Additional inference parameters
|
16 |
+
*/
|
17 |
+
parameters?: ObjectDetectionParameters;
|
18 |
+
[property: string]: unknown;
|
19 |
+
}
|
20 |
+
/**
|
21 |
+
* Additional inference parameters
|
22 |
+
*
|
23 |
+
* Additional inference parameters for Object Detection
|
24 |
+
*/
|
25 |
+
export interface ObjectDetectionParameters {
|
26 |
+
/**
|
27 |
+
* The probability necessary to make a prediction.
|
28 |
+
*/
|
29 |
+
threshold?: number;
|
30 |
+
[property: string]: unknown;
|
31 |
+
}
|
32 |
+
/**
|
33 |
+
* The predicted bounding box. Coordinates are relative to the top left corner of the input
|
34 |
+
* image.
|
35 |
+
*/
|
36 |
+
export interface BoundingBox {
|
37 |
+
xmax: number;
|
38 |
+
xmin: number;
|
39 |
+
ymax: number;
|
40 |
+
ymin: number;
|
41 |
+
[property: string]: unknown;
|
42 |
+
}
|
43 |
+
export type ObjectDetectionOutput = ObjectDetectionOutputElement[];
|
44 |
+
/**
|
45 |
+
* Outputs of inference for the Object Detection task
|
46 |
+
*/
|
47 |
+
export interface ObjectDetectionOutputElement {
|
48 |
+
/**
|
49 |
+
* The predicted bounding box. Coordinates are relative to the top left corner of the input
|
50 |
+
* image.
|
51 |
+
*/
|
52 |
+
box: BoundingBox;
|
53 |
+
/**
|
54 |
+
* The predicted label for the bounding box
|
55 |
+
*/
|
56 |
+
label: string;
|
57 |
+
/**
|
58 |
+
* The associated score / probability
|
59 |
+
*/
|
60 |
+
score: number;
|
61 |
+
[property: string]: unknown;
|
62 |
+
}
|
packages/tasks/src/tasks/object-detection/spec/input.json
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/object-detection/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Object Detection inference",
|
5 |
+
"title": "ObjectDetectionInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "The input image data"
|
10 |
+
},
|
11 |
+
"parameters": {
|
12 |
+
"description": "Additional inference parameters",
|
13 |
+
"$ref": "#/$defs/ObjectDetectionParameters"
|
14 |
+
}
|
15 |
+
},
|
16 |
+
"$defs": {
|
17 |
+
"ObjectDetectionParameters": {
|
18 |
+
"title": "ObjectDetectionParameters",
|
19 |
+
"description": "Additional inference parameters for Object Detection",
|
20 |
+
"type": "object",
|
21 |
+
"properties": {
|
22 |
+
"threshold": {
|
23 |
+
"type": "number",
|
24 |
+
"description": "The probability necessary to make a prediction."
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
},
|
29 |
+
"required": ["data"]
|
30 |
+
}
|
packages/tasks/src/tasks/object-detection/spec/output.json
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/object-detection/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Outputs of inference for the Object Detection task",
|
5 |
+
"title": "ObjectDetectionOutput",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"type": "object",
|
9 |
+
"properties": {
|
10 |
+
"label": {
|
11 |
+
"type": "string",
|
12 |
+
"description": "The predicted label for the bounding box"
|
13 |
+
},
|
14 |
+
"score": {
|
15 |
+
"type": "number",
|
16 |
+
"description": "The associated score / probability"
|
17 |
+
},
|
18 |
+
"box": {
|
19 |
+
"$ref": "#/$defs/BoundingBox",
|
20 |
+
"description": "The predicted bounding box. Coordinates are relative to the top left corner of the input image."
|
21 |
+
}
|
22 |
+
},
|
23 |
+
"required": ["box", "label", "score"]
|
24 |
+
},
|
25 |
+
"$defs": {
|
26 |
+
"BoundingBox": {
|
27 |
+
"type": "object",
|
28 |
+
"title": "BoundingBox",
|
29 |
+
"properties": {
|
30 |
+
"xmin": {
|
31 |
+
"type": "integer"
|
32 |
+
},
|
33 |
+
"xmax": {
|
34 |
+
"type": "integer"
|
35 |
+
},
|
36 |
+
"ymin": {
|
37 |
+
"type": "integer"
|
38 |
+
},
|
39 |
+
"ymax": {
|
40 |
+
"type": "integer"
|
41 |
+
}
|
42 |
+
},
|
43 |
+
"required": ["xmin", "xmax", "ymin", "ymax"]
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
packages/tasks/src/tasks/placeholder/data.ts
CHANGED
@@ -13,6 +13,9 @@ const taskData: TaskDataCustom = {
|
|
13 |
summary: "",
|
14 |
widgetModels: [],
|
15 |
youtubeId: undefined,
|
|
|
|
|
|
|
16 |
};
|
17 |
|
18 |
export default taskData;
|
|
|
13 |
summary: "",
|
14 |
widgetModels: [],
|
15 |
youtubeId: undefined,
|
16 |
+
/// If this is a subtask, link to the most general task ID
|
17 |
+
/// (eg, text2text-generation is the canonical ID of translation)
|
18 |
+
canonicalId: undefined,
|
19 |
};
|
20 |
|
21 |
export default taskData;
|
packages/tasks/src/tasks/placeholder/spec/input.json
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/<TASK_ID>/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for <TASK_ID> inference",
|
5 |
+
"title": "PlaceholderInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"description": "TODO: describe the input here. This must be model & framework agnostic.",
|
10 |
+
"type": "string"
|
11 |
+
},
|
12 |
+
"parameters": {
|
13 |
+
"description": "Additional inference parameters",
|
14 |
+
"$ref": "#/$defs/<TASK_ID>Parameters"
|
15 |
+
}
|
16 |
+
},
|
17 |
+
"$defs": {
|
18 |
+
"<TASK_ID>Parameters": {
|
19 |
+
"title": "<TASK_ID>Parameters",
|
20 |
+
"description": "TODO: describe additional parameters here.",
|
21 |
+
"type": "object",
|
22 |
+
"properties": {
|
23 |
+
"dummyParameterName": {
|
24 |
+
"type": "boolean",
|
25 |
+
"description": "TODO: describe the parameter here"
|
26 |
+
},
|
27 |
+
"dummyParameterName2": {
|
28 |
+
"type": "integer",
|
29 |
+
"description": "TODO: describe the parameter here"
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
+
},
|
34 |
+
"required": ["data"]
|
35 |
+
}
|
packages/tasks/src/tasks/placeholder/spec/output.json
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/<TASK_ID>/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Outputs for <TASK_ID> inference",
|
5 |
+
"title": "PlaceholderOutput",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"type": "object",
|
9 |
+
"properties": {
|
10 |
+
"meaningfulOutputName": {
|
11 |
+
"type": "string",
|
12 |
+
"description": "TODO: Describe what is outputed by the inference here"
|
13 |
+
}
|
14 |
+
},
|
15 |
+
"required": ["meaningfulOutputName"]
|
16 |
+
}
|
17 |
+
}
|
packages/tasks/src/tasks/question-answering/inference.ts
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
/**
|
7 |
+
* Inputs for Question Answering inference
|
8 |
+
*/
|
9 |
+
export interface QuestionAnsweringInput {
|
10 |
+
/**
|
11 |
+
* One (context, question) pair to answer
|
12 |
+
*/
|
13 |
+
data: QuestionAnsweringInputData;
|
14 |
+
/**
|
15 |
+
* Additional inference parameters
|
16 |
+
*/
|
17 |
+
parameters?: QuestionAnsweringParameters;
|
18 |
+
[property: string]: unknown;
|
19 |
+
}
|
20 |
+
/**
|
21 |
+
* One (context, question) pair to answer
|
22 |
+
*/
|
23 |
+
export interface QuestionAnsweringInputData {
|
24 |
+
/**
|
25 |
+
* The context to be used for answering the question
|
26 |
+
*/
|
27 |
+
context: string;
|
28 |
+
/**
|
29 |
+
* The question to be answered
|
30 |
+
*/
|
31 |
+
question: string;
|
32 |
+
[property: string]: unknown;
|
33 |
+
}
|
34 |
+
/**
|
35 |
+
* Additional inference parameters
|
36 |
+
*
|
37 |
+
* Additional inference parameters for Question Answering
|
38 |
+
*/
|
39 |
+
export interface QuestionAnsweringParameters {
|
40 |
+
/**
|
41 |
+
* Attempts to align the answer to real words. Improves quality on space separated
|
42 |
+
* languages. Might hurt on non-space-separated languages (like Japanese or Chinese)
|
43 |
+
*/
|
44 |
+
alignToWords?: boolean;
|
45 |
+
/**
|
46 |
+
* If the context is too long to fit with the question for the model, it will be split in
|
47 |
+
* several chunks with some overlap. This argument controls the size of that overlap.
|
48 |
+
*/
|
49 |
+
docStride?: number;
|
50 |
+
/**
|
51 |
+
* Whether to accept impossible as an answer.
|
52 |
+
*/
|
53 |
+
handleImpossibleAnswer?: boolean;
|
54 |
+
/**
|
55 |
+
* The maximum length of predicted answers (e.g., only answers with a shorter length are
|
56 |
+
* considered).
|
57 |
+
*/
|
58 |
+
maxAnswerLen?: number;
|
59 |
+
/**
|
60 |
+
* The maximum length of the question after tokenization. It will be truncated if needed.
|
61 |
+
*/
|
62 |
+
maxQuestionLen?: number;
|
63 |
+
/**
|
64 |
+
* The maximum length of the total sentence (context + question) in tokens of each chunk
|
65 |
+
* passed to the model. The context will be split in several chunks (using docStride as
|
66 |
+
* overlap) if needed.
|
67 |
+
*/
|
68 |
+
maxSeqLen?: number;
|
69 |
+
/**
|
70 |
+
* The number of answers to return (will be chosen by order of likelihood). Note that we
|
71 |
+
* return less than topk answers if there are not enough options available within the
|
72 |
+
* context.
|
73 |
+
*/
|
74 |
+
topK?: number;
|
75 |
+
[property: string]: unknown;
|
76 |
+
}
|
77 |
+
export type QuestionAnsweringOutput = QuestionAnsweringOutputElement[];
|
78 |
+
/**
|
79 |
+
* Outputs of inference for the Question Answering task
|
80 |
+
*/
|
81 |
+
export interface QuestionAnsweringOutputElement {
|
82 |
+
/**
|
83 |
+
* The answer to the question.
|
84 |
+
*/
|
85 |
+
answer: string;
|
86 |
+
/**
|
87 |
+
* The character position in the input where the answer ends.
|
88 |
+
*/
|
89 |
+
end: number;
|
90 |
+
/**
|
91 |
+
* The probability associated to the answer.
|
92 |
+
*/
|
93 |
+
score: number;
|
94 |
+
/**
|
95 |
+
* The character position in the input where the answer begins.
|
96 |
+
*/
|
97 |
+
start: number;
|
98 |
+
[property: string]: unknown;
|
99 |
+
}
|
packages/tasks/src/tasks/question-answering/spec/input.json
ADDED
@@ -0,0 +1,67 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/question-answering/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Question Answering inference",
|
5 |
+
"title": "QuestionAnsweringInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"title": "QuestionAnsweringInputData",
|
10 |
+
"description": "One (context, question) pair to answer",
|
11 |
+
"type": "object",
|
12 |
+
"properties": {
|
13 |
+
"context": {
|
14 |
+
"type": "string",
|
15 |
+
"description": "The context to be used for answering the question"
|
16 |
+
},
|
17 |
+
"question": {
|
18 |
+
"type": "string",
|
19 |
+
"description": "The question to be answered"
|
20 |
+
}
|
21 |
+
},
|
22 |
+
"required": ["question", "context"]
|
23 |
+
},
|
24 |
+
"parameters": {
|
25 |
+
"description": "Additional inference parameters",
|
26 |
+
"$ref": "#/$defs/QuestionAnsweringParameters"
|
27 |
+
}
|
28 |
+
},
|
29 |
+
"$defs": {
|
30 |
+
"QuestionAnsweringParameters": {
|
31 |
+
"title": "QuestionAnsweringParameters",
|
32 |
+
"description": "Additional inference parameters for Question Answering",
|
33 |
+
"type": "object",
|
34 |
+
"properties": {
|
35 |
+
"topK": {
|
36 |
+
"type": "integer",
|
37 |
+
"description": "The number of answers to return (will be chosen by order of likelihood). Note that we return less than topk answers if there are not enough options available within the context."
|
38 |
+
},
|
39 |
+
"docStride": {
|
40 |
+
"type": "integer",
|
41 |
+
"description": "If the context is too long to fit with the question for the model, it will be split in several chunks with some overlap. This argument controls the size of that overlap."
|
42 |
+
},
|
43 |
+
"maxAnswerLen": {
|
44 |
+
"type": "integer",
|
45 |
+
"description": "The maximum length of predicted answers (e.g., only answers with a shorter length are considered)."
|
46 |
+
},
|
47 |
+
"maxSeqLen": {
|
48 |
+
"type": "integer",
|
49 |
+
"description": "The maximum length of the total sentence (context + question) in tokens of each chunk passed to the model. The context will be split in several chunks (using docStride as overlap) if needed."
|
50 |
+
},
|
51 |
+
"maxQuestionLen": {
|
52 |
+
"type": "integer",
|
53 |
+
"description": "The maximum length of the question after tokenization. It will be truncated if needed."
|
54 |
+
},
|
55 |
+
"handleImpossibleAnswer": {
|
56 |
+
"type": "boolean",
|
57 |
+
"description": "Whether to accept impossible as an answer."
|
58 |
+
},
|
59 |
+
"alignToWords": {
|
60 |
+
"type": "boolean",
|
61 |
+
"description": "Attempts to align the answer to real words. Improves quality on space separated languages. Might hurt on non-space-separated languages (like Japanese or Chinese)"
|
62 |
+
}
|
63 |
+
}
|
64 |
+
}
|
65 |
+
},
|
66 |
+
"required": ["data"]
|
67 |
+
}
|
packages/tasks/src/tasks/question-answering/spec/output.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/question-answering/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"title": "QuestionAnsweringOutput",
|
5 |
+
"description": "Outputs of inference for the Question Answering task",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"type": "object",
|
9 |
+
"properties": {
|
10 |
+
"answer": {
|
11 |
+
"type": "string",
|
12 |
+
"description": "The answer to the question."
|
13 |
+
},
|
14 |
+
"score": {
|
15 |
+
"type": "number",
|
16 |
+
"description": "The probability associated to the answer."
|
17 |
+
},
|
18 |
+
"start": {
|
19 |
+
"type": "integer",
|
20 |
+
"description": "The character position in the input where the answer begins."
|
21 |
+
},
|
22 |
+
"end": {
|
23 |
+
"type": "integer",
|
24 |
+
"description": "The character position in the input where the answer ends."
|
25 |
+
}
|
26 |
+
},
|
27 |
+
"required": ["answer", "score", "start", "end"]
|
28 |
+
}
|
29 |
+
}
|
packages/tasks/src/tasks/sentence-similarity/inference.ts
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* Inference code generated from the JSON schema spec in ./spec
|
3 |
+
*
|
4 |
+
* Using src/scripts/inference-codegen
|
5 |
+
*/
|
6 |
+
|
7 |
+
export type SentenceSimilarityOutput = number[];
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Inputs for Sentence similarity inference
|
11 |
+
*/
|
12 |
+
export interface SentenceSimilarityInput {
|
13 |
+
data: SentenceSimilarityInputData;
|
14 |
+
/**
|
15 |
+
* Additional inference parameters
|
16 |
+
*/
|
17 |
+
parameters?: { [key: string]: unknown };
|
18 |
+
[property: string]: unknown;
|
19 |
+
}
|
20 |
+
|
21 |
+
export interface SentenceSimilarityInputData {
|
22 |
+
/**
|
23 |
+
* A list of strings which will be compared against the source_sentence.
|
24 |
+
*/
|
25 |
+
sentences: string[];
|
26 |
+
/**
|
27 |
+
* The string that you wish to compare the other strings with. This can be a phrase,
|
28 |
+
* sentence, or longer passage, depending on the model being used.
|
29 |
+
*/
|
30 |
+
sourceSentence: string;
|
31 |
+
[property: string]: unknown;
|
32 |
+
}
|
packages/tasks/src/tasks/sentence-similarity/spec/input.json
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/sentence-similarity/input.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"description": "Inputs for Sentence similarity inference",
|
5 |
+
"title": "SentenceSimilarityInput",
|
6 |
+
"type": "object",
|
7 |
+
"properties": {
|
8 |
+
"data": {
|
9 |
+
"title": "SentenceSimilarityInputData",
|
10 |
+
"type": "object",
|
11 |
+
"properties": {
|
12 |
+
"sourceSentence": {
|
13 |
+
"description": "The string that you wish to compare the other strings with. This can be a phrase, sentence, or longer passage, depending on the model being used.",
|
14 |
+
"type": "string"
|
15 |
+
},
|
16 |
+
"sentences": {
|
17 |
+
"type": "array",
|
18 |
+
"description": "A list of strings which will be compared against the source_sentence.",
|
19 |
+
"items": {
|
20 |
+
"type": "string"
|
21 |
+
}
|
22 |
+
}
|
23 |
+
},
|
24 |
+
"required": ["sourceSentence", "sentences"]
|
25 |
+
},
|
26 |
+
"parameters": {
|
27 |
+
"description": "Additional inference parameters",
|
28 |
+
"$ref": "#/$defs/SentenceSimilarityParameters"
|
29 |
+
}
|
30 |
+
},
|
31 |
+
"$defs": {
|
32 |
+
"SentenceSimilarityParameters": {
|
33 |
+
"title": "SentenceSimilarityParameters",
|
34 |
+
"description": "Additional inference parameters for Sentence Similarity",
|
35 |
+
"type": "object",
|
36 |
+
"properties": {}
|
37 |
+
}
|
38 |
+
},
|
39 |
+
"required": ["data"]
|
40 |
+
}
|
packages/tasks/src/tasks/sentence-similarity/spec/output.json
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$id": "/inference/schemas/sentence-similarity/output.json",
|
3 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
4 |
+
"title": "SentenceSimilarityOutput",
|
5 |
+
"description": "Outputs of inference for the Sentence Similarity task",
|
6 |
+
"type": "array",
|
7 |
+
"items": {
|
8 |
+
"description": "The associated similarity score for each of the given sentences",
|
9 |
+
"type": "number",
|
10 |
+
"title": "SentenceSimilarityScore"
|
11 |
+
}
|
12 |
+
}
|
packages/tasks/src/tasks/summarization/data.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import type { TaskDataCustom } from "..";
|
2 |
|
3 |
const taskData: TaskDataCustom = {
|
|
|
4 |
datasets: [
|
5 |
{
|
6 |
description:
|
|
|
1 |
import type { TaskDataCustom } from "..";
|
2 |
|
3 |
const taskData: TaskDataCustom = {
|
4 |
+
canonicalId: "text2text-generation",
|
5 |
datasets: [
|
6 |
{
|
7 |
description:
|
packages/tasks/src/tasks/summarization/inference.ts
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 Summarization inference
|
9 |
+
*
|
10 |
+
* Inputs for Text2text Generation inference
|
11 |
+
*/
|
12 |
+
export interface SummarizationInput {
|
13 |
+
/**
|
14 |
+
* The input text data
|
15 |
+
*/
|
16 |
+
data: string;
|
17 |
+
/**
|
18 |
+
* Additional inference parameters
|
19 |
+
*/
|
20 |
+
parameters?: Text2TextGenerationParameters;
|
21 |
+
[property: string]: unknown;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Additional inference parameters
|
26 |
+
*
|
27 |
+
* Additional inference parameters for Text2text Generation
|
28 |
+
*/
|
29 |
+
export interface Text2TextGenerationParameters {
|
30 |
+
/**
|
31 |
+
* Whether to clean up the potential extra spaces in the text output.
|
32 |
+
*/
|
33 |
+
cleanUpTokenizationSpaces?: boolean;
|
34 |
+
/**
|
35 |
+
* Additional parametrization of the text generation algorithm
|
36 |
+
*/
|
37 |
+
generateParameters?: { [key: string]: unknown };
|
38 |
+
/**
|
39 |
+
* The truncation strategy to use
|
40 |
+
*/
|
41 |
+
truncation?: Text2TextGenerationTruncationStrategy;
|
42 |
+
[property: string]: unknown;
|
43 |
+
}
|
44 |
+
|
45 |
+
export type Text2TextGenerationTruncationStrategy = "do_not_truncate" | "longest_first" | "only_first" | "only_second";
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Outputs for Summarization inference
|
49 |
+
*
|
50 |
+
* Outputs of inference for the Text2text Generation task
|
51 |
+
*/
|
52 |
+
export interface SummarizationOutput {
|
53 |
+
/**
|
54 |
+
* The generated text.
|
55 |
+
*/
|
56 |
+
generatedText: string;
|
57 |
+
[property: string]: unknown;
|
58 |
+
}
|
packages/tasks/src/tasks/summarization/spec/input.json
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"$ref": "/inference/schemas/text2text-generation/input.json",
|
3 |
+
"$id": "/inference/schemas/summarization/input.json",
|
4 |
+
"$schema": "http://json-schema.org/draft-06/schema#",
|
5 |
+
"title": "SummarizationInput",
|
6 |
+
"description": "Inputs for Summarization inference"
|
7 |
+
}
|