@huggingface/tasks 0.13.3 → 0.13.5
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/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/local-apps.d.ts.map +1 -1
- package/dist/commonjs/local-apps.js +40 -21
- package/dist/commonjs/local-apps.spec.d.ts +2 -0
- package/dist/commonjs/local-apps.spec.d.ts.map +1 -0
- package/dist/commonjs/local-apps.spec.js +114 -0
- package/dist/commonjs/model-libraries-snippets.d.ts.map +1 -1
- package/dist/commonjs/model-libraries-snippets.js +23 -12
- package/dist/commonjs/model-libraries-snippets.spec.d.ts +2 -0
- package/dist/commonjs/model-libraries-snippets.spec.d.ts.map +1 -0
- package/dist/commonjs/model-libraries-snippets.spec.js +51 -0
- package/dist/commonjs/model-libraries.d.ts +8 -1
- package/dist/commonjs/model-libraries.d.ts.map +1 -1
- package/dist/commonjs/model-libraries.js +7 -0
- package/dist/commonjs/tasks/audio-classification/inference.d.ts +3 -0
- package/dist/commonjs/tasks/audio-classification/inference.d.ts.map +1 -1
- package/dist/commonjs/tasks/document-question-answering/inference.d.ts +0 -4
- package/dist/commonjs/tasks/document-question-answering/inference.d.ts.map +1 -1
- package/dist/commonjs/tasks/image-classification/inference.d.ts +3 -0
- package/dist/commonjs/tasks/image-classification/inference.d.ts.map +1 -1
- package/dist/commonjs/tasks/index.d.ts +1 -1
- package/dist/commonjs/tasks/index.d.ts.map +1 -1
- package/dist/commonjs/tasks/text-classification/inference.d.ts +3 -0
- package/dist/commonjs/tasks/text-classification/inference.d.ts.map +1 -1
- package/dist/commonjs/tasks/text-to-speech/data.d.ts.map +1 -1
- package/dist/commonjs/tasks/text-to-speech/data.js +15 -7
- package/dist/commonjs/tasks/video-classification/inference.d.ts +3 -0
- package/dist/commonjs/tasks/video-classification/inference.d.ts.map +1 -1
- package/dist/commonjs/tasks/zero-shot-classification/inference.d.ts +9 -19
- package/dist/commonjs/tasks/zero-shot-classification/inference.d.ts.map +1 -1
- package/dist/commonjs/tasks/zero-shot-image-classification/inference.d.ts +9 -19
- package/dist/commonjs/tasks/zero-shot-image-classification/inference.d.ts.map +1 -1
- package/dist/commonjs/tasks/zero-shot-object-detection/inference.d.ts +8 -12
- package/dist/commonjs/tasks/zero-shot-object-detection/inference.d.ts.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/local-apps.d.ts.map +1 -1
- package/dist/esm/local-apps.js +40 -21
- package/dist/esm/local-apps.spec.d.ts +2 -0
- package/dist/esm/local-apps.spec.d.ts.map +1 -0
- package/dist/esm/local-apps.spec.js +112 -0
- package/dist/esm/model-libraries-snippets.d.ts.map +1 -1
- package/dist/esm/model-libraries-snippets.js +23 -12
- package/dist/esm/model-libraries-snippets.spec.d.ts +2 -0
- package/dist/esm/model-libraries-snippets.spec.d.ts.map +1 -0
- package/dist/esm/model-libraries-snippets.spec.js +49 -0
- package/dist/esm/model-libraries.d.ts +8 -1
- package/dist/esm/model-libraries.d.ts.map +1 -1
- package/dist/esm/model-libraries.js +7 -0
- package/dist/esm/tasks/audio-classification/inference.d.ts +3 -0
- package/dist/esm/tasks/audio-classification/inference.d.ts.map +1 -1
- package/dist/esm/tasks/document-question-answering/inference.d.ts +0 -4
- package/dist/esm/tasks/document-question-answering/inference.d.ts.map +1 -1
- package/dist/esm/tasks/image-classification/inference.d.ts +3 -0
- package/dist/esm/tasks/image-classification/inference.d.ts.map +1 -1
- package/dist/esm/tasks/index.d.ts +1 -1
- package/dist/esm/tasks/index.d.ts.map +1 -1
- package/dist/esm/tasks/text-classification/inference.d.ts +3 -0
- package/dist/esm/tasks/text-classification/inference.d.ts.map +1 -1
- package/dist/esm/tasks/text-to-speech/data.d.ts.map +1 -1
- package/dist/esm/tasks/text-to-speech/data.js +15 -7
- package/dist/esm/tasks/video-classification/inference.d.ts +3 -0
- package/dist/esm/tasks/video-classification/inference.d.ts.map +1 -1
- package/dist/esm/tasks/zero-shot-classification/inference.d.ts +9 -19
- package/dist/esm/tasks/zero-shot-classification/inference.d.ts.map +1 -1
- package/dist/esm/tasks/zero-shot-image-classification/inference.d.ts +9 -19
- package/dist/esm/tasks/zero-shot-image-classification/inference.d.ts.map +1 -1
- package/dist/esm/tasks/zero-shot-object-detection/inference.d.ts +8 -12
- package/dist/esm/tasks/zero-shot-object-detection/inference.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +0 -1
- package/src/local-apps.spec.ts +123 -0
- package/src/local-apps.ts +37 -18
- package/src/model-libraries-snippets.spec.ts +54 -0
- package/src/model-libraries-snippets.ts +24 -11
- package/src/model-libraries.ts +7 -0
- package/src/tasks/audio-classification/inference.ts +3 -0
- package/src/tasks/audio-classification/spec/input.json +2 -1
- package/src/tasks/document-question-answering/inference.ts +0 -4
- package/src/tasks/document-question-answering/spec/output.json +1 -8
- package/src/tasks/image-classification/inference.ts +3 -0
- package/src/tasks/image-classification/spec/input.json +2 -1
- package/src/tasks/index.ts +0 -1
- package/src/tasks/text-classification/inference.ts +3 -0
- package/src/tasks/text-classification/spec/input.json +2 -1
- package/src/tasks/text-to-speech/data.ts +15 -7
- package/src/tasks/video-classification/inference.ts +3 -0
- package/src/tasks/video-classification/spec/input.json +2 -1
- package/src/tasks/zero-shot-classification/inference.ts +9 -19
- package/src/tasks/zero-shot-classification/spec/input.json +13 -20
- package/src/tasks/zero-shot-image-classification/inference.ts +9 -19
- package/src/tasks/zero-shot-image-classification/spec/input.json +13 -19
- package/src/tasks/zero-shot-object-detection/inference.ts +8 -12
- package/src/tasks/zero-shot-object-detection/spec/input.json +13 -18
|
@@ -25,7 +25,7 @@ export type * from "./video-classification/inference.js";
|
|
|
25
25
|
export type * from "./visual-question-answering/inference.js";
|
|
26
26
|
export type * from "./zero-shot-classification/inference.js";
|
|
27
27
|
export type * from "./zero-shot-image-classification/inference.js";
|
|
28
|
-
export type { BoundingBox, ZeroShotObjectDetectionInput,
|
|
28
|
+
export type { BoundingBox, ZeroShotObjectDetectionInput, ZeroShotObjectDetectionOutput, ZeroShotObjectDetectionOutputElement, } from "./zero-shot-object-detection/inference.js";
|
|
29
29
|
import type { ModelLibraryKey } from "../model-libraries.js";
|
|
30
30
|
/**
|
|
31
31
|
* Model libraries compatible with each ML task
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tasks/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AA4CpD,mBAAmB,qCAAqC,CAAC;AACzD,mBAAmB,6CAA6C,CAAC;AACjE,YAAY,EACX,mBAAmB,EACnB,0BAA0B,EAC1B,oBAAoB,EACpB,4BAA4B,EAC5B,2BAA2B,EAC3B,0BAA0B,EAC1B,gCAAgC,EAChC,+BAA+B,GAC/B,MAAM,gCAAgC,CAAC;AACxC,mBAAmB,4CAA4C,CAAC;AAChE,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,0BAA0B,CAAC;AAC9C,YAAY,EACX,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,6BAA6B,GAC7B,MAAM,qCAAqC,CAAC;AAC7C,mBAAmB,+BAA+B,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC/G,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,iCAAiC,CAAC;AACrD,mBAAmB,iCAAiC,CAAC;AACrD,mBAAmB,mCAAmC,CAAC;AACvD,mBAAmB,oCAAoC,CAAC;AACxD,mBAAmB,8BAA8B,CAAC;AAClD,mBAAmB,yCAAyC,CAAC;AAC7D,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC/G,YAAY,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnH,mBAAmB,qCAAqC,CAAC;AACzD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AE,MAAM,EAAE,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,EAAE,IAAI,GAAG,OAAO,GAAG,WAAW,CAAC,CAAC"}
|
|
@@ -23,6 +23,9 @@ export interface TextClassificationInput {
|
|
|
23
23
|
* Additional inference parameters for Text Classification
|
|
24
24
|
*/
|
|
25
25
|
export interface TextClassificationParameters {
|
|
26
|
+
/**
|
|
27
|
+
* The function to apply to the model outputs in order to retrieve the scores.
|
|
28
|
+
*/
|
|
26
29
|
function_to_apply?: ClassificationOutputTransform;
|
|
27
30
|
/**
|
|
28
31
|
* When specified, limits the output to the top K most probable classes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,4BAA4B,CAAC;IAC1C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC5C,iBAAiB,CAAC,EAAE,6BAA6B,CAAC;IAClD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,wBAAwB,GAAG,+BAA+B,EAAE,CAAC;AACzE;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC/C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"}
|
|
1
|
+
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACvC;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,4BAA4B,CAAC;IAC1C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,iBAAiB,CAAC,EAAE,6BAA6B,CAAC;IAClD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,wBAAwB,GAAG,+BAA+B,EAAE,CAAC;AACzE;;GAEG;AACH,MAAM,WAAW,+BAA+B;IAC/C;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-speech/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../../../src/tasks/text-to-speech/data.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,QAAA,MAAM,QAAQ,EAAE,cAkFf,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -9,6 +9,10 @@ const taskData = {
|
|
|
9
9
|
description: "Multi-speaker English dataset.",
|
|
10
10
|
id: "mythicinfinity/libritts_r",
|
|
11
11
|
},
|
|
12
|
+
{
|
|
13
|
+
description: "Mulit-lingual dataset.",
|
|
14
|
+
id: "facebook/multilingual_librispeech",
|
|
15
|
+
},
|
|
12
16
|
],
|
|
13
17
|
demo: {
|
|
14
18
|
inputs: [
|
|
@@ -33,20 +37,24 @@ const taskData = {
|
|
|
33
37
|
],
|
|
34
38
|
models: [
|
|
35
39
|
{
|
|
36
|
-
description: "A powerful TTS model.",
|
|
40
|
+
description: "A prompt based, powerful TTS model.",
|
|
37
41
|
id: "parler-tts/parler-tts-large-v1",
|
|
38
42
|
},
|
|
43
|
+
{
|
|
44
|
+
description: "A powerful TTS model that supports English and Chinese.",
|
|
45
|
+
id: "SWivid/F5-TTS",
|
|
46
|
+
},
|
|
39
47
|
{
|
|
40
48
|
description: "A massively multi-lingual TTS model.",
|
|
41
49
|
id: "coqui/XTTS-v2",
|
|
42
50
|
},
|
|
43
51
|
{
|
|
44
|
-
description: "
|
|
45
|
-
id: "
|
|
52
|
+
description: "A powerful TTS model.",
|
|
53
|
+
id: "amphion/MaskGCT",
|
|
46
54
|
},
|
|
47
55
|
{
|
|
48
|
-
description: "A
|
|
49
|
-
id: "
|
|
56
|
+
description: "A Llama based TTS model.",
|
|
57
|
+
id: "OuteAI/OuteTTS-0.1-350M",
|
|
50
58
|
},
|
|
51
59
|
],
|
|
52
60
|
spaces: [
|
|
@@ -63,8 +71,8 @@ const taskData = {
|
|
|
63
71
|
id: "mrfakename/E2-F5-TTS",
|
|
64
72
|
},
|
|
65
73
|
{
|
|
66
|
-
description: "An application that synthesizes speech for diverse speaker prompts.",
|
|
67
|
-
id: "parler-tts/
|
|
74
|
+
description: "An application that synthesizes emotional speech for diverse speaker prompts.",
|
|
75
|
+
id: "parler-tts/parler-tts-expresso",
|
|
68
76
|
},
|
|
69
77
|
],
|
|
70
78
|
summary: "Text-to-Speech (TTS) is the task of generating natural sounding speech given text input. TTS models can be extended to have a single model that generates speech for multiple speakers and multiple languages.",
|
|
@@ -27,6 +27,9 @@ export interface VideoClassificationParameters {
|
|
|
27
27
|
* The sampling rate used to select frames from the video.
|
|
28
28
|
*/
|
|
29
29
|
frame_sampling_rate?: number;
|
|
30
|
+
/**
|
|
31
|
+
* The function to apply to the model outputs in order to retrieve the scores.
|
|
32
|
+
*/
|
|
30
33
|
function_to_apply?: ClassificationOutputTransform;
|
|
31
34
|
/**
|
|
32
35
|
* The number of sampled frames to consider for classification.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/video-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,6BAA6B,CAAC;IAC3C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,iBAAiB,CAAC,EAAE,6BAA6B,CAAC;IAClD;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,yBAAyB,GAAG,gCAAgC,EAAE,CAAC;AAC3E;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"}
|
|
1
|
+
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/video-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;OAEG;IACH,MAAM,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,6BAA6B,CAAC;IAC3C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC7C;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,iBAAiB,CAAC,EAAE,6BAA6B,CAAC;IAClD;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAC3E,MAAM,MAAM,yBAAyB,GAAG,gCAAgC,EAAE,CAAC;AAC3E;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"}
|
|
@@ -8,27 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export interface ZeroShotClassificationInput {
|
|
10
10
|
/**
|
|
11
|
-
* The
|
|
11
|
+
* The text to classify
|
|
12
12
|
*/
|
|
13
|
-
inputs:
|
|
13
|
+
inputs: string;
|
|
14
14
|
/**
|
|
15
15
|
* Additional inference parameters
|
|
16
16
|
*/
|
|
17
|
-
parameters
|
|
18
|
-
[property: string]: unknown;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The input text data, with candidate labels
|
|
22
|
-
*/
|
|
23
|
-
export interface ZeroShotClassificationInputData {
|
|
24
|
-
/**
|
|
25
|
-
* The set of possible class labels to classify the text into.
|
|
26
|
-
*/
|
|
27
|
-
candidateLabels: string[];
|
|
28
|
-
/**
|
|
29
|
-
* The text to classify
|
|
30
|
-
*/
|
|
31
|
-
text: string;
|
|
17
|
+
parameters: ZeroShotClassificationParameters;
|
|
32
18
|
[property: string]: unknown;
|
|
33
19
|
}
|
|
34
20
|
/**
|
|
@@ -38,8 +24,12 @@ export interface ZeroShotClassificationInputData {
|
|
|
38
24
|
*/
|
|
39
25
|
export interface ZeroShotClassificationParameters {
|
|
40
26
|
/**
|
|
41
|
-
* The
|
|
42
|
-
|
|
27
|
+
* The set of possible class labels to classify the text into.
|
|
28
|
+
*/
|
|
29
|
+
candidate_labels: string[];
|
|
30
|
+
/**
|
|
31
|
+
* The sentence used in conjunction with `candidate_labels` to attempt the text
|
|
32
|
+
* classification by replacing the placeholder with the candidate labels.
|
|
43
33
|
*/
|
|
44
34
|
hypothesis_template?: string;
|
|
45
35
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;OAEG;IACH,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC3C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,EAAE,gCAAgC,CAAC;IAC7C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,MAAM,4BAA4B,GAAG,mCAAmC,EAAE,CAAC;AACjF;;GAEG;AACH,MAAM,WAAW,mCAAmC;IACnD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"}
|
|
@@ -8,27 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export interface ZeroShotImageClassificationInput {
|
|
10
10
|
/**
|
|
11
|
-
* The input image data
|
|
11
|
+
* The input image data to classify as a base64-encoded string.
|
|
12
12
|
*/
|
|
13
|
-
inputs:
|
|
13
|
+
inputs: string;
|
|
14
14
|
/**
|
|
15
15
|
* Additional inference parameters
|
|
16
16
|
*/
|
|
17
|
-
parameters
|
|
18
|
-
[property: string]: unknown;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* The input image data, with candidate labels
|
|
22
|
-
*/
|
|
23
|
-
export interface ZeroShotImageClassificationInputData {
|
|
24
|
-
/**
|
|
25
|
-
* The candidate labels for this image
|
|
26
|
-
*/
|
|
27
|
-
candidateLabels: string[];
|
|
28
|
-
/**
|
|
29
|
-
* The image data to classify
|
|
30
|
-
*/
|
|
31
|
-
image: unknown;
|
|
17
|
+
parameters: ZeroShotImageClassificationParameters;
|
|
32
18
|
[property: string]: unknown;
|
|
33
19
|
}
|
|
34
20
|
/**
|
|
@@ -38,8 +24,12 @@ export interface ZeroShotImageClassificationInputData {
|
|
|
38
24
|
*/
|
|
39
25
|
export interface ZeroShotImageClassificationParameters {
|
|
40
26
|
/**
|
|
41
|
-
* The
|
|
42
|
-
|
|
27
|
+
* The candidate labels for this image
|
|
28
|
+
*/
|
|
29
|
+
candidate_labels: string[];
|
|
30
|
+
/**
|
|
31
|
+
* The sentence used in conjunction with `candidate_labels` to attempt the image
|
|
32
|
+
* classification by replacing the placeholder with the candidate labels.
|
|
43
33
|
*/
|
|
44
34
|
hypothesis_template?: string;
|
|
45
35
|
[property: string]: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-image-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-image-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAChD;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,EAAE,qCAAqC,CAAC;IAClD,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH,MAAM,WAAW,qCAAqC;IACrD;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B;;;OAGG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,MAAM,iCAAiC,GAAG,wCAAwC,EAAE,CAAC;AAC3F;;GAEG;AACH,MAAM,WAAW,wCAAwC;IACxD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"}
|
|
@@ -8,29 +8,25 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export interface ZeroShotObjectDetectionInput {
|
|
10
10
|
/**
|
|
11
|
-
* The input image data
|
|
11
|
+
* The input image data as a base64-encoded string.
|
|
12
12
|
*/
|
|
13
|
-
inputs:
|
|
13
|
+
inputs: string;
|
|
14
14
|
/**
|
|
15
15
|
* Additional inference parameters
|
|
16
16
|
*/
|
|
17
|
-
parameters
|
|
18
|
-
[key: string]: unknown;
|
|
19
|
-
};
|
|
17
|
+
parameters: ZeroShotObjectDetectionParameters;
|
|
20
18
|
[property: string]: unknown;
|
|
21
19
|
}
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
21
|
+
* Additional inference parameters
|
|
22
|
+
*
|
|
23
|
+
* Additional inference parameters for Zero Shot Object Detection
|
|
24
24
|
*/
|
|
25
|
-
export interface
|
|
25
|
+
export interface ZeroShotObjectDetectionParameters {
|
|
26
26
|
/**
|
|
27
27
|
* The candidate labels for this image
|
|
28
28
|
*/
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* The image data to generate bounding boxes from
|
|
32
|
-
*/
|
|
33
|
-
image: unknown;
|
|
29
|
+
candidate_labels: string[];
|
|
34
30
|
[property: string]: unknown;
|
|
35
31
|
}
|
|
36
32
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-object-detection/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/zero-shot-object-detection/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC5C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,EAAE,iCAAiC,CAAC;IAC9C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH,MAAM,WAAW,iCAAiC;IACjD;;OAEG;IACH,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD,MAAM,MAAM,6BAA6B,GAAG,oCAAoC,EAAE,CAAC;AACnF;;GAEG;AACH,MAAM,WAAW,oCAAoC;IACpD;;;OAGG;IACH,GAAG,EAAE,WAAW,CAAC;IACjB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@huggingface/tasks",
|
|
3
3
|
"packageManager": "pnpm@8.10.5",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.5",
|
|
5
5
|
"description": "List of ML tasks for huggingface.co/tasks",
|
|
6
6
|
"repository": "https://github.com/huggingface/huggingface.js.git",
|
|
7
7
|
"publishConfig": {
|
package/src/index.ts
CHANGED
|
@@ -51,7 +51,6 @@ export * from "./gguf.js";
|
|
|
51
51
|
export { snippets };
|
|
52
52
|
export type { InferenceSnippet } from "./snippets/index.js";
|
|
53
53
|
|
|
54
|
-
|
|
55
54
|
export { SKUS, DEFAULT_MEMORY_OPTIONS } from "./hardware.js";
|
|
56
55
|
export type { HardwareSpec, SkuType } from "./hardware.js";
|
|
57
56
|
export { LOCAL_APPS } from "./local-apps.js";
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { LOCAL_APPS } from "./local-apps.js";
|
|
3
|
+
import type { ModelData } from "./model-data.js";
|
|
4
|
+
|
|
5
|
+
describe("local-apps", () => {
|
|
6
|
+
it("llama.cpp conversational", async () => {
|
|
7
|
+
const { snippet: snippetFunc } = LOCAL_APPS["llama.cpp"];
|
|
8
|
+
const model: ModelData = {
|
|
9
|
+
id: "bartowski/Llama-3.2-3B-Instruct-GGUF",
|
|
10
|
+
tags: ["conversational"],
|
|
11
|
+
inference: "",
|
|
12
|
+
};
|
|
13
|
+
const snippet = snippetFunc(model);
|
|
14
|
+
|
|
15
|
+
expect(snippet[0].content).toEqual(`# Load and run the model:
|
|
16
|
+
llama-cli \\
|
|
17
|
+
--hf-repo "bartowski/Llama-3.2-3B-Instruct-GGUF" \\
|
|
18
|
+
--hf-file {{GGUF_FILE}} \\
|
|
19
|
+
-p "You are a helpful assistant" \\
|
|
20
|
+
--conversation`);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("llama.cpp non-conversational", async () => {
|
|
24
|
+
const { snippet: snippetFunc } = LOCAL_APPS["llama.cpp"];
|
|
25
|
+
const model: ModelData = {
|
|
26
|
+
id: "mlabonne/gemma-2b-GGUF",
|
|
27
|
+
tags: [],
|
|
28
|
+
inference: "",
|
|
29
|
+
};
|
|
30
|
+
const snippet = snippetFunc(model);
|
|
31
|
+
|
|
32
|
+
expect(snippet[0].content).toEqual(`# Load and run the model:
|
|
33
|
+
llama-cli \\
|
|
34
|
+
--hf-repo "mlabonne/gemma-2b-GGUF" \\
|
|
35
|
+
--hf-file {{GGUF_FILE}} \\
|
|
36
|
+
-p "Once upon a time,"`);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("vLLM conversational llm", async () => {
|
|
40
|
+
const { snippet: snippetFunc } = LOCAL_APPS["vllm"];
|
|
41
|
+
const model: ModelData = {
|
|
42
|
+
id: "meta-llama/Llama-3.2-3B-Instruct",
|
|
43
|
+
pipeline_tag: "text-generation",
|
|
44
|
+
tags: ["conversational"],
|
|
45
|
+
inference: "",
|
|
46
|
+
};
|
|
47
|
+
const snippet = snippetFunc(model);
|
|
48
|
+
|
|
49
|
+
expect((snippet[0].content as string[]).join("\n")).toEqual(`# Load and run the model:
|
|
50
|
+
vllm serve "meta-llama/Llama-3.2-3B-Instruct"
|
|
51
|
+
# Call the server using curl:
|
|
52
|
+
curl -X POST "http://localhost:8000/v1/chat/completions" \\
|
|
53
|
+
-H "Content-Type: application/json" \\
|
|
54
|
+
--data '{
|
|
55
|
+
"model": "meta-llama/Llama-3.2-3B-Instruct",
|
|
56
|
+
"messages": [
|
|
57
|
+
{
|
|
58
|
+
"role": "user",
|
|
59
|
+
"content": "What is the capital of France?"
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
}'`);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("vLLM non-conversational llm", async () => {
|
|
66
|
+
const { snippet: snippetFunc } = LOCAL_APPS["vllm"];
|
|
67
|
+
const model: ModelData = {
|
|
68
|
+
id: "meta-llama/Llama-3.2-3B",
|
|
69
|
+
tags: [""],
|
|
70
|
+
inference: "",
|
|
71
|
+
};
|
|
72
|
+
const snippet = snippetFunc(model);
|
|
73
|
+
|
|
74
|
+
expect((snippet[0].content as string[]).join("\n")).toEqual(`# Load and run the model:
|
|
75
|
+
vllm serve "meta-llama/Llama-3.2-3B"
|
|
76
|
+
# Call the server using curl:
|
|
77
|
+
curl -X POST "http://localhost:8000/v1/completions" \\
|
|
78
|
+
-H "Content-Type: application/json" \\
|
|
79
|
+
--data '{
|
|
80
|
+
"model": "meta-llama/Llama-3.2-3B",
|
|
81
|
+
"prompt": "Once upon a time,",
|
|
82
|
+
"max_tokens": 512,
|
|
83
|
+
"temperature": 0.5
|
|
84
|
+
}'`);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("vLLM conversational vlm", async () => {
|
|
88
|
+
const { snippet: snippetFunc } = LOCAL_APPS["vllm"];
|
|
89
|
+
const model: ModelData = {
|
|
90
|
+
id: "meta-llama/Llama-3.2-11B-Vision-Instruct",
|
|
91
|
+
pipeline_tag: "image-text-to-text",
|
|
92
|
+
tags: ["conversational"],
|
|
93
|
+
inference: "",
|
|
94
|
+
};
|
|
95
|
+
const snippet = snippetFunc(model);
|
|
96
|
+
|
|
97
|
+
expect((snippet[0].content as string[]).join("\n")).toEqual(`# Load and run the model:
|
|
98
|
+
vllm serve "meta-llama/Llama-3.2-11B-Vision-Instruct"
|
|
99
|
+
# Call the server using curl:
|
|
100
|
+
curl -X POST "http://localhost:8000/v1/chat/completions" \\
|
|
101
|
+
-H "Content-Type: application/json" \\
|
|
102
|
+
--data '{
|
|
103
|
+
"model": "meta-llama/Llama-3.2-11B-Vision-Instruct",
|
|
104
|
+
"messages": [
|
|
105
|
+
{
|
|
106
|
+
"role": "user",
|
|
107
|
+
"content": [
|
|
108
|
+
{
|
|
109
|
+
"type": "text",
|
|
110
|
+
"text": "Describe this image in one sentence."
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"type": "image_url",
|
|
114
|
+
"image_url": {
|
|
115
|
+
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
}'`);
|
|
122
|
+
});
|
|
123
|
+
});
|
package/src/local-apps.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { parseGGUFQuantLabel } from "./gguf.js";
|
|
2
2
|
import type { ModelData } from "./model-data.js";
|
|
3
3
|
import type { PipelineType } from "./pipelines.js";
|
|
4
|
+
import { stringifyMessages } from "./snippets/common.js";
|
|
5
|
+
import { getModelInputSnippet } from "./snippets/inputs.js";
|
|
6
|
+
import type { ChatCompletionInputMessage } from "./tasks/index.js";
|
|
4
7
|
|
|
5
8
|
export interface LocalAppSnippet {
|
|
6
9
|
/**
|
|
@@ -92,15 +95,20 @@ function isMlxModel(model: ModelData) {
|
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
const snippetLlamacpp = (model: ModelData, filepath?: string): LocalAppSnippet[] => {
|
|
95
|
-
const command = (binary: string) =>
|
|
96
|
-
[
|
|
98
|
+
const command = (binary: string) => {
|
|
99
|
+
const snippet = [
|
|
97
100
|
"# Load and run the model:",
|
|
98
101
|
`${binary} \\`,
|
|
99
102
|
` --hf-repo "${model.id}" \\`,
|
|
100
103
|
` --hf-file ${filepath ?? "{{GGUF_FILE}}"} \\`,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
` -p "${model.tags.includes("conversational") ? "You are a helpful assistant" : "Once upon a time,"}"`,
|
|
105
|
+
];
|
|
106
|
+
if (model.tags.includes("conversational")) {
|
|
107
|
+
snippet[snippet.length - 1] += " \\";
|
|
108
|
+
snippet.push(" --conversation");
|
|
109
|
+
}
|
|
110
|
+
return snippet.join("\n");
|
|
111
|
+
};
|
|
104
112
|
return [
|
|
105
113
|
{
|
|
106
114
|
title: "Install from brew",
|
|
@@ -178,22 +186,33 @@ const snippetLocalAI = (model: ModelData, filepath?: string): LocalAppSnippet[]
|
|
|
178
186
|
};
|
|
179
187
|
|
|
180
188
|
const snippetVllm = (model: ModelData): LocalAppSnippet[] => {
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
const messages = getModelInputSnippet(model) as ChatCompletionInputMessage[];
|
|
190
|
+
const runCommandInstruct = `# Call the server using curl:
|
|
191
|
+
curl -X POST "http://localhost:8000/v1/chat/completions" \\
|
|
192
|
+
-H "Content-Type: application/json" \\
|
|
193
|
+
--data '{
|
|
194
|
+
"model": "${model.id}",
|
|
195
|
+
"messages": ${stringifyMessages(messages, {
|
|
196
|
+
indent: "\t\t",
|
|
197
|
+
attributeKeyQuotes: true,
|
|
198
|
+
customContentEscaper: (str) => str.replace(/'/g, "'\\''"),
|
|
199
|
+
})}
|
|
200
|
+
}'`;
|
|
201
|
+
const runCommandNonInstruct = `# Call the server using curl:
|
|
202
|
+
curl -X POST "http://localhost:8000/v1/completions" \\
|
|
203
|
+
-H "Content-Type: application/json" \\
|
|
204
|
+
--data '{
|
|
205
|
+
"model": "${model.id}",
|
|
206
|
+
"prompt": "Once upon a time,",
|
|
207
|
+
"max_tokens": 512,
|
|
208
|
+
"temperature": 0.5
|
|
209
|
+
}'`;
|
|
210
|
+
const runCommand = model.tags.includes("conversational") ? runCommandInstruct : runCommandNonInstruct;
|
|
192
211
|
return [
|
|
193
212
|
{
|
|
194
213
|
title: "Install from pip",
|
|
195
214
|
setup: ["# Install vLLM from pip:", "pip install vllm"].join("\n"),
|
|
196
|
-
content: [`# Load and run the model:\nvllm serve "${model.id}"`, runCommand
|
|
215
|
+
content: [`# Load and run the model:\nvllm serve "${model.id}"`, runCommand],
|
|
197
216
|
},
|
|
198
217
|
{
|
|
199
218
|
title: "Use Docker images",
|
|
@@ -210,7 +229,7 @@ const snippetVllm = (model: ModelData): LocalAppSnippet[] => {
|
|
|
210
229
|
].join("\n"),
|
|
211
230
|
content: [
|
|
212
231
|
`# Load and run the model:\ndocker exec -it my_vllm_container bash -c "vllm serve ${model.id}"`,
|
|
213
|
-
runCommand
|
|
232
|
+
runCommand,
|
|
214
233
|
],
|
|
215
234
|
},
|
|
216
235
|
];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import type { ModelData } from "./model-data.js";
|
|
3
|
+
import { llama_cpp_python } from "./model-libraries-snippets.js";
|
|
4
|
+
|
|
5
|
+
describe("model-libraries-snippets", () => {
|
|
6
|
+
it("llama_cpp_python conversational", async () => {
|
|
7
|
+
const model: ModelData = {
|
|
8
|
+
id: "bartowski/Llama-3.2-3B-Instruct-GGUF",
|
|
9
|
+
pipeline_tag: "text-generation",
|
|
10
|
+
tags: ["conversational"],
|
|
11
|
+
inference: "",
|
|
12
|
+
};
|
|
13
|
+
const snippet = llama_cpp_python(model);
|
|
14
|
+
|
|
15
|
+
expect(snippet.join("\n")).toEqual(`from llama_cpp import Llama
|
|
16
|
+
|
|
17
|
+
llm = Llama.from_pretrained(
|
|
18
|
+
repo_id="bartowski/Llama-3.2-3B-Instruct-GGUF",
|
|
19
|
+
filename="{{GGUF_FILE}}",
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
llm.create_chat_completion(
|
|
23
|
+
messages = [
|
|
24
|
+
{
|
|
25
|
+
"role": "user",
|
|
26
|
+
"content": "What is the capital of France?"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
)`);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("llama_cpp_python non-conversational", async () => {
|
|
33
|
+
const model: ModelData = {
|
|
34
|
+
id: "mlabonne/gemma-2b-GGUF",
|
|
35
|
+
tags: [""],
|
|
36
|
+
inference: "",
|
|
37
|
+
};
|
|
38
|
+
const snippet = llama_cpp_python(model);
|
|
39
|
+
|
|
40
|
+
expect(snippet.join("\n")).toEqual(`from llama_cpp import Llama
|
|
41
|
+
|
|
42
|
+
llm = Llama.from_pretrained(
|
|
43
|
+
repo_id="mlabonne/gemma-2b-GGUF",
|
|
44
|
+
filename="{{GGUF_FILE}}",
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
output = llm(
|
|
48
|
+
"Once upon a time,",
|
|
49
|
+
max_tokens=512,
|
|
50
|
+
echo=True
|
|
51
|
+
)
|
|
52
|
+
print(output)`);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ModelData } from "./model-data.js";
|
|
2
2
|
import type { WidgetExampleTextInput, WidgetExampleSentenceSimilarityInput } from "./widget-example.js";
|
|
3
3
|
import { LIBRARY_TASK_MAPPING } from "./library-to-tasks.js";
|
|
4
|
+
import { getModelInputSnippet } from "./snippets/inputs.js";
|
|
5
|
+
import type { ChatCompletionInputMessage } from "./tasks/index.js";
|
|
6
|
+
import { stringifyMessages } from "./snippets/common.js";
|
|
4
7
|
|
|
5
8
|
const TAG_CUSTOM_CODE = "custom_code";
|
|
6
9
|
|
|
@@ -418,23 +421,33 @@ model = keras_hub.models.CausalLM.from_preset("hf://${model.id}", dtype="bfloat1
|
|
|
418
421
|
`,
|
|
419
422
|
];
|
|
420
423
|
|
|
421
|
-
export const llama_cpp_python = (model: ModelData): string[] =>
|
|
422
|
-
|
|
424
|
+
export const llama_cpp_python = (model: ModelData): string[] => {
|
|
425
|
+
const snippets = [
|
|
426
|
+
`from llama_cpp import Llama
|
|
423
427
|
|
|
424
428
|
llm = Llama.from_pretrained(
|
|
425
429
|
repo_id="${model.id}",
|
|
426
430
|
filename="{{GGUF_FILE}}",
|
|
427
431
|
)
|
|
432
|
+
`,
|
|
433
|
+
];
|
|
428
434
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
435
|
+
if (model.tags.includes("conversational")) {
|
|
436
|
+
const messages = getModelInputSnippet(model) as ChatCompletionInputMessage[];
|
|
437
|
+
snippets.push(`llm.create_chat_completion(
|
|
438
|
+
messages = ${stringifyMessages(messages, { attributeKeyQuotes: true, indent: "\t" })}
|
|
439
|
+
)`);
|
|
440
|
+
} else {
|
|
441
|
+
snippets.push(`output = llm(
|
|
442
|
+
"Once upon a time,",
|
|
443
|
+
max_tokens=512,
|
|
444
|
+
echo=True
|
|
445
|
+
)
|
|
446
|
+
print(output)`);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return snippets;
|
|
450
|
+
};
|
|
438
451
|
|
|
439
452
|
export const tf_keras = (model: ModelData): string[] => [
|
|
440
453
|
`# Note: 'keras<3.x' or 'tf_keras' must be installed (legacy)
|
package/src/model-libraries.ts
CHANGED
|
@@ -212,6 +212,13 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
|
|
|
212
212
|
repoUrl: "https://github.com/cartesia-ai/cartesia_mlx",
|
|
213
213
|
snippets: snippets.cartesia_mlx,
|
|
214
214
|
},
|
|
215
|
+
clipscope: {
|
|
216
|
+
prettyLabel: "clipscope",
|
|
217
|
+
repoName: "clipscope",
|
|
218
|
+
repoUrl: "https://github.com/Lewington-pitsos/clipscope",
|
|
219
|
+
filter: false,
|
|
220
|
+
countDownloads: `path_extension:"pt"`,
|
|
221
|
+
},
|
|
215
222
|
cotracker: {
|
|
216
223
|
prettyLabel: "CoTracker",
|
|
217
224
|
repoName: "CoTracker",
|
|
@@ -24,6 +24,9 @@ export interface AudioClassificationInput {
|
|
|
24
24
|
* Additional inference parameters for Audio Classification
|
|
25
25
|
*/
|
|
26
26
|
export interface AudioClassificationParameters {
|
|
27
|
+
/**
|
|
28
|
+
* The function to apply to the model outputs in order to retrieve the scores.
|
|
29
|
+
*/
|
|
27
30
|
function_to_apply?: ClassificationOutputTransform;
|
|
28
31
|
/**
|
|
29
32
|
* When specified, limits the output to the top K most probable classes.
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"properties": {
|
|
23
23
|
"function_to_apply": {
|
|
24
24
|
"title": "AudioClassificationOutputTransform",
|
|
25
|
-
"$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform"
|
|
25
|
+
"$ref": "/inference/schemas/common-definitions.json#/definitions/ClassificationOutputTransform",
|
|
26
|
+
"description": "The function to apply to the model outputs in order to retrieve the scores."
|
|
26
27
|
},
|
|
27
28
|
"top_k": {
|
|
28
29
|
"type": "integer",
|