@huggingface/tasks 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{index.mjs → index.cjs} +2695 -2497
- package/dist/index.d.ts +427 -65
- package/dist/index.js +2660 -2532
- package/package.json +13 -8
- package/src/index.ts +2 -5
- package/src/library-to-tasks.ts +1 -1
- package/src/model-data.ts +1 -1
- package/src/model-libraries-downloads.ts +20 -0
- package/src/{library-ui-elements.ts → model-libraries-snippets.ts} +50 -296
- package/src/model-libraries.ts +375 -44
- package/src/pipelines.ts +1 -1
- package/src/tasks/audio-classification/about.md +1 -1
- package/src/tasks/audio-classification/inference.ts +51 -0
- package/src/tasks/audio-classification/spec/input.json +34 -0
- package/src/tasks/audio-classification/spec/output.json +10 -0
- package/src/tasks/audio-to-audio/about.md +1 -1
- package/src/tasks/automatic-speech-recognition/about.md +4 -2
- package/src/tasks/automatic-speech-recognition/inference.ts +159 -0
- package/src/tasks/automatic-speech-recognition/spec/input.json +34 -0
- package/src/tasks/automatic-speech-recognition/spec/output.json +38 -0
- package/src/tasks/common-definitions.json +117 -0
- package/src/tasks/depth-estimation/data.ts +8 -4
- package/src/tasks/depth-estimation/inference.ts +35 -0
- package/src/tasks/depth-estimation/spec/input.json +25 -0
- package/src/tasks/depth-estimation/spec/output.json +16 -0
- package/src/tasks/document-question-answering/inference.ts +110 -0
- package/src/tasks/document-question-answering/spec/input.json +85 -0
- package/src/tasks/document-question-answering/spec/output.json +36 -0
- package/src/tasks/feature-extraction/inference.ts +22 -0
- package/src/tasks/feature-extraction/spec/input.json +26 -0
- package/src/tasks/feature-extraction/spec/output.json +7 -0
- package/src/tasks/fill-mask/inference.ts +62 -0
- package/src/tasks/fill-mask/spec/input.json +38 -0
- package/src/tasks/fill-mask/spec/output.json +29 -0
- package/src/tasks/image-classification/inference.ts +51 -0
- package/src/tasks/image-classification/spec/input.json +34 -0
- package/src/tasks/image-classification/spec/output.json +10 -0
- package/src/tasks/image-segmentation/inference.ts +65 -0
- package/src/tasks/image-segmentation/spec/input.json +54 -0
- package/src/tasks/image-segmentation/spec/output.json +25 -0
- package/src/tasks/image-to-image/inference.ts +67 -0
- package/src/tasks/image-to-image/spec/input.json +54 -0
- package/src/tasks/image-to-image/spec/output.json +12 -0
- package/src/tasks/image-to-text/inference.ts +143 -0
- package/src/tasks/image-to-text/spec/input.json +34 -0
- package/src/tasks/image-to-text/spec/output.json +14 -0
- package/src/tasks/index.ts +5 -2
- package/src/tasks/mask-generation/about.md +65 -0
- package/src/tasks/mask-generation/data.ts +42 -5
- package/src/tasks/object-detection/inference.ts +62 -0
- package/src/tasks/object-detection/spec/input.json +30 -0
- package/src/tasks/object-detection/spec/output.json +46 -0
- package/src/tasks/placeholder/data.ts +3 -0
- package/src/tasks/placeholder/spec/input.json +35 -0
- package/src/tasks/placeholder/spec/output.json +17 -0
- package/src/tasks/question-answering/inference.ts +99 -0
- package/src/tasks/question-answering/spec/input.json +67 -0
- package/src/tasks/question-answering/spec/output.json +29 -0
- package/src/tasks/sentence-similarity/about.md +2 -2
- package/src/tasks/sentence-similarity/inference.ts +32 -0
- package/src/tasks/sentence-similarity/spec/input.json +40 -0
- package/src/tasks/sentence-similarity/spec/output.json +12 -0
- package/src/tasks/summarization/data.ts +1 -0
- package/src/tasks/summarization/inference.ts +59 -0
- package/src/tasks/summarization/spec/input.json +7 -0
- package/src/tasks/summarization/spec/output.json +7 -0
- package/src/tasks/table-question-answering/inference.ts +61 -0
- package/src/tasks/table-question-answering/spec/input.json +44 -0
- package/src/tasks/table-question-answering/spec/output.json +40 -0
- package/src/tasks/tabular-classification/about.md +1 -1
- package/src/tasks/tabular-regression/about.md +1 -1
- package/src/tasks/text-classification/about.md +1 -0
- package/src/tasks/text-classification/inference.ts +51 -0
- package/src/tasks/text-classification/spec/input.json +35 -0
- package/src/tasks/text-classification/spec/output.json +10 -0
- package/src/tasks/text-generation/about.md +24 -13
- package/src/tasks/text-generation/data.ts +22 -38
- package/src/tasks/text-generation/inference.ts +194 -0
- package/src/tasks/text-generation/spec/input.json +90 -0
- package/src/tasks/text-generation/spec/output.json +120 -0
- package/src/tasks/text-to-audio/inference.ts +143 -0
- package/src/tasks/text-to-audio/spec/input.json +31 -0
- package/src/tasks/text-to-audio/spec/output.json +17 -0
- package/src/tasks/text-to-image/about.md +11 -2
- package/src/tasks/text-to-image/data.ts +6 -2
- package/src/tasks/text-to-image/inference.ts +71 -0
- package/src/tasks/text-to-image/spec/input.json +59 -0
- package/src/tasks/text-to-image/spec/output.json +13 -0
- package/src/tasks/text-to-speech/about.md +4 -2
- package/src/tasks/text-to-speech/data.ts +1 -0
- package/src/tasks/text-to-speech/inference.ts +147 -0
- package/src/tasks/text-to-speech/spec/input.json +7 -0
- package/src/tasks/text-to-speech/spec/output.json +7 -0
- package/src/tasks/text2text-generation/inference.ts +55 -0
- package/src/tasks/text2text-generation/spec/input.json +55 -0
- package/src/tasks/text2text-generation/spec/output.json +14 -0
- package/src/tasks/token-classification/inference.ts +82 -0
- package/src/tasks/token-classification/spec/input.json +65 -0
- package/src/tasks/token-classification/spec/output.json +33 -0
- package/src/tasks/translation/data.ts +1 -0
- package/src/tasks/translation/inference.ts +59 -0
- package/src/tasks/translation/spec/input.json +7 -0
- package/src/tasks/translation/spec/output.json +7 -0
- package/src/tasks/video-classification/inference.ts +59 -0
- package/src/tasks/video-classification/spec/input.json +42 -0
- package/src/tasks/video-classification/spec/output.json +10 -0
- package/src/tasks/visual-question-answering/inference.ts +63 -0
- package/src/tasks/visual-question-answering/spec/input.json +41 -0
- package/src/tasks/visual-question-answering/spec/output.json +21 -0
- package/src/tasks/zero-shot-classification/inference.ts +67 -0
- package/src/tasks/zero-shot-classification/spec/input.json +50 -0
- package/src/tasks/zero-shot-classification/spec/output.json +10 -0
- package/src/tasks/zero-shot-image-classification/data.ts +8 -5
- package/src/tasks/zero-shot-image-classification/inference.ts +61 -0
- package/src/tasks/zero-shot-image-classification/spec/input.json +45 -0
- package/src/tasks/zero-shot-image-classification/spec/output.json +10 -0
- package/src/tasks/zero-shot-object-detection/about.md +6 -0
- package/src/tasks/zero-shot-object-detection/data.ts +6 -1
- package/src/tasks/zero-shot-object-detection/inference.ts +66 -0
- package/src/tasks/zero-shot-object-detection/spec/input.json +40 -0
- package/src/tasks/zero-shot-object-detection/spec/output.json +47 -0
- package/tsconfig.json +3 -3
package/package.json
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huggingface/tasks",
|
|
3
3
|
"packageManager": "pnpm@8.10.5",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "List of ML tasks for huggingface.co/tasks",
|
|
6
6
|
"repository": "https://github.com/huggingface/huggingface.js.git",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
|
-
"main": "./dist/index.
|
|
11
|
-
"module": "./dist/index.
|
|
10
|
+
"main": "./dist/index.cjs",
|
|
11
|
+
"module": "./dist/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
-
"require": "./dist/index.
|
|
17
|
-
"import": "./dist/index.
|
|
16
|
+
"require": "./dist/index.cjs",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"source": "src/index.ts",
|
|
21
|
+
"type": "module",
|
|
21
22
|
"files": [
|
|
22
23
|
"dist",
|
|
23
24
|
"src",
|
|
@@ -30,13 +31,17 @@
|
|
|
30
31
|
],
|
|
31
32
|
"author": "Hugging Face",
|
|
32
33
|
"license": "MIT",
|
|
33
|
-
"devDependencies": {
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@types/node": "^20.11.5",
|
|
36
|
+
"quicktype-core": "https://github.com/huggingface/quicktype/raw/pack-18.0.15/packages/quicktype-core/quicktype-core-18.0.15.tgz"
|
|
37
|
+
},
|
|
34
38
|
"scripts": {
|
|
35
39
|
"lint": "eslint --quiet --fix --ext .cjs,.ts .",
|
|
36
40
|
"lint:check": "eslint --ext .cjs,.ts .",
|
|
37
41
|
"format": "prettier --write .",
|
|
38
42
|
"format:check": "prettier --check .",
|
|
39
|
-
"build": "tsup src/index.ts --format cjs,esm --clean --dts",
|
|
40
|
-
"check": "tsc"
|
|
43
|
+
"build": "tsup src/index.ts --format cjs,esm --clean --dts && pnpm run inference-codegen",
|
|
44
|
+
"check": "tsc",
|
|
45
|
+
"inference-codegen": "tsx scripts/inference-codegen.ts && prettier --write src/tasks/*/inference.ts"
|
|
41
46
|
}
|
|
42
47
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { LIBRARY_TASK_MAPPING_EXCLUDING_TRANSFORMERS } from "./library-to-tasks";
|
|
2
|
-
export { MODEL_LIBRARIES_UI_ELEMENTS } from "./library-ui-elements";
|
|
3
2
|
export { MAPPING_DEFAULT_WIDGET } from "./default-widget-inputs";
|
|
4
3
|
export type { TaskData, TaskDemo, TaskDemoEntry, ExampleRepo } from "./tasks";
|
|
5
4
|
export * from "./tasks";
|
|
@@ -14,8 +13,8 @@ export {
|
|
|
14
13
|
SUBTASK_TYPES,
|
|
15
14
|
PIPELINE_TYPES_SET,
|
|
16
15
|
} from "./pipelines";
|
|
17
|
-
export {
|
|
18
|
-
export type { ModelLibraryKey } from "./model-libraries";
|
|
16
|
+
export { ALL_DISPLAY_MODEL_LIBRARY_KEYS, ALL_MODEL_LIBRARY_KEYS, MODEL_LIBRARIES_UI_ELEMENTS } from "./model-libraries";
|
|
17
|
+
export type { LibraryUiElement, ModelLibraryKey } from "./model-libraries";
|
|
19
18
|
export type { ModelData, TransformersInfo } from "./model-data";
|
|
20
19
|
export type {
|
|
21
20
|
WidgetExample,
|
|
@@ -41,5 +40,3 @@ export { InferenceDisplayability } from "./model-data";
|
|
|
41
40
|
|
|
42
41
|
import * as snippets from "./snippets";
|
|
43
42
|
export { snippets };
|
|
44
|
-
|
|
45
|
-
export type { LibraryUiElement } from "./library-ui-elements";
|
package/src/library-to-tasks.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PipelineType } from "./pipelines";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Mapping from library name (excluding Transformers) to its supported tasks.
|
|
6
|
-
* Inference API should be disabled for all other (library, task) pairs beyond this mapping.
|
|
6
|
+
* Inference API (serverless) should be disabled for all other (library, task) pairs beyond this mapping.
|
|
7
7
|
* As an exception, we assume Transformers supports all inference tasks.
|
|
8
8
|
* This mapping is generated automatically by "python-api-export-tasks" action in huggingface/api-inference-community repo upon merge.
|
|
9
9
|
* Ref: https://github.com/huggingface/api-inference-community/pull/158
|
package/src/model-data.ts
CHANGED
|
@@ -78,7 +78,7 @@ export interface ModelData {
|
|
|
78
78
|
*/
|
|
79
79
|
widgetData?: WidgetExample[] | undefined;
|
|
80
80
|
/**
|
|
81
|
-
* Parameters that will be used by the widget when calling Inference
|
|
81
|
+
* Parameters that will be used by the widget when calling Inference Endpoints (serverless)
|
|
82
82
|
* https://huggingface.co/docs/api-inference/detailed_parameters
|
|
83
83
|
*
|
|
84
84
|
* can be set in the model card metadata (under `inference/parameters`)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file contains the (simplified) types used
|
|
3
|
+
* to represent queries that are made to Elastic
|
|
4
|
+
* in order to count number of model downloads
|
|
5
|
+
*
|
|
6
|
+
* Read this doc about download stats on the Hub:
|
|
7
|
+
*
|
|
8
|
+
* https://huggingface.co/docs/hub/models-download-stats
|
|
9
|
+
*
|
|
10
|
+
* see also:
|
|
11
|
+
* https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export type ElasticBoolQueryFilter =
|
|
15
|
+
// match a single filename
|
|
16
|
+
| { term?: { path: string } }
|
|
17
|
+
// match multiple possible filenames
|
|
18
|
+
| { terms?: { path: string[] } }
|
|
19
|
+
// match a wildcard
|
|
20
|
+
| { wildcard?: { path: string } };
|