@huggingface/tasks 0.13.4 → 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/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/tasks/audio-classification/inference.d.ts +3 -0
- package/dist/commonjs/tasks/audio-classification/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/text-classification/inference.d.ts +3 -0
- package/dist/commonjs/tasks/text-classification/inference.d.ts.map +1 -1
- 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/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/tasks/audio-classification/inference.d.ts +3 -0
- package/dist/esm/tasks/audio-classification/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/text-classification/inference.d.ts +3 -0
- package/dist/esm/tasks/text-classification/inference.d.ts.map +1 -1
- package/dist/esm/tasks/video-classification/inference.d.ts +3 -0
- package/dist/esm/tasks/video-classification/inference.d.ts.map +1 -1
- package/package.json +1 -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/tasks/audio-classification/inference.ts +3 -0
- package/src/tasks/audio-classification/spec/input.json +2 -1
- package/src/tasks/image-classification/inference.ts +3 -0
- package/src/tasks/image-classification/spec/input.json +2 -1
- package/src/tasks/text-classification/inference.ts +3 -0
- package/src/tasks/text-classification/spec/input.json +2 -1
- package/src/tasks/video-classification/inference.ts +3 -0
- package/src/tasks/video-classification/spec/input.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-apps.d.ts","sourceRoot":"","sources":["../../src/local-apps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"local-apps.d.ts","sourceRoot":"","sources":["../../src/local-apps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAKnD,MAAM,WAAW,eAAe;IAC/B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG;IACtB;;OAEG;IACH,W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|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LOCAL_APPS = void 0;
|
|
4
4
|
const gguf_js_1 = require("./gguf.js");
|
|
5
|
+
const common_js_1 = require("./snippets/common.js");
|
|
6
|
+
const inputs_js_1 = require("./snippets/inputs.js");
|
|
5
7
|
function isAwqModel(model) {
|
|
6
8
|
return model.config?.quantization_config?.quant_method === "awq";
|
|
7
9
|
}
|
|
@@ -27,14 +29,20 @@ function isMlxModel(model) {
|
|
|
27
29
|
return model.tags.includes("mlx");
|
|
28
30
|
}
|
|
29
31
|
const snippetLlamacpp = (model, filepath) => {
|
|
30
|
-
const command = (binary) =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
const command = (binary) => {
|
|
33
|
+
const snippet = [
|
|
34
|
+
"# Load and run the model:",
|
|
35
|
+
`${binary} \\`,
|
|
36
|
+
` --hf-repo "${model.id}" \\`,
|
|
37
|
+
` --hf-file ${filepath ?? "{{GGUF_FILE}}"} \\`,
|
|
38
|
+
` -p "${model.tags.includes("conversational") ? "You are a helpful assistant" : "Once upon a time,"}"`,
|
|
39
|
+
];
|
|
40
|
+
if (model.tags.includes("conversational")) {
|
|
41
|
+
snippet[snippet.length - 1] += " \\";
|
|
42
|
+
snippet.push(" --conversation");
|
|
43
|
+
}
|
|
44
|
+
return snippet.join("\n");
|
|
45
|
+
};
|
|
38
46
|
return [
|
|
39
47
|
{
|
|
40
48
|
title: "Install from brew",
|
|
@@ -105,22 +113,33 @@ const snippetLocalAI = (model, filepath) => {
|
|
|
105
113
|
];
|
|
106
114
|
};
|
|
107
115
|
const snippetVllm = (model) => {
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
const messages = (0, inputs_js_1.getModelInputSnippet)(model);
|
|
117
|
+
const runCommandInstruct = `# Call the server using curl:
|
|
118
|
+
curl -X POST "http://localhost:8000/v1/chat/completions" \\
|
|
119
|
+
-H "Content-Type: application/json" \\
|
|
120
|
+
--data '{
|
|
121
|
+
"model": "${model.id}",
|
|
122
|
+
"messages": ${(0, common_js_1.stringifyMessages)(messages, {
|
|
123
|
+
indent: "\t\t",
|
|
124
|
+
attributeKeyQuotes: true,
|
|
125
|
+
customContentEscaper: (str) => str.replace(/'/g, "'\\''"),
|
|
126
|
+
})}
|
|
127
|
+
}'`;
|
|
128
|
+
const runCommandNonInstruct = `# Call the server using curl:
|
|
129
|
+
curl -X POST "http://localhost:8000/v1/completions" \\
|
|
130
|
+
-H "Content-Type: application/json" \\
|
|
131
|
+
--data '{
|
|
132
|
+
"model": "${model.id}",
|
|
133
|
+
"prompt": "Once upon a time,",
|
|
134
|
+
"max_tokens": 512,
|
|
135
|
+
"temperature": 0.5
|
|
136
|
+
}'`;
|
|
137
|
+
const runCommand = model.tags.includes("conversational") ? runCommandInstruct : runCommandNonInstruct;
|
|
119
138
|
return [
|
|
120
139
|
{
|
|
121
140
|
title: "Install from pip",
|
|
122
141
|
setup: ["# Install vLLM from pip:", "pip install vllm"].join("\n"),
|
|
123
|
-
content: [`# Load and run the model:\nvllm serve "${model.id}"`, runCommand
|
|
142
|
+
content: [`# Load and run the model:\nvllm serve "${model.id}"`, runCommand],
|
|
124
143
|
},
|
|
125
144
|
{
|
|
126
145
|
title: "Use Docker images",
|
|
@@ -137,7 +156,7 @@ const snippetVllm = (model) => {
|
|
|
137
156
|
].join("\n"),
|
|
138
157
|
content: [
|
|
139
158
|
`# Load and run the model:\ndocker exec -it my_vllm_container bash -c "vllm serve ${model.id}"`,
|
|
140
|
-
runCommand
|
|
159
|
+
runCommand,
|
|
141
160
|
],
|
|
142
161
|
},
|
|
143
162
|
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-apps.spec.d.ts","sourceRoot":"","sources":["../../src/local-apps.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const local_apps_js_1 = require("./local-apps.js");
|
|
5
|
+
(0, vitest_1.describe)("local-apps", () => {
|
|
6
|
+
(0, vitest_1.it)("llama.cpp conversational", async () => {
|
|
7
|
+
const { snippet: snippetFunc } = local_apps_js_1.LOCAL_APPS["llama.cpp"];
|
|
8
|
+
const model = {
|
|
9
|
+
id: "bartowski/Llama-3.2-3B-Instruct-GGUF",
|
|
10
|
+
tags: ["conversational"],
|
|
11
|
+
inference: "",
|
|
12
|
+
};
|
|
13
|
+
const snippet = snippetFunc(model);
|
|
14
|
+
(0, vitest_1.expect)(snippet[0].content).toEqual(`# Load and run the model:
|
|
15
|
+
llama-cli \\
|
|
16
|
+
--hf-repo "bartowski/Llama-3.2-3B-Instruct-GGUF" \\
|
|
17
|
+
--hf-file {{GGUF_FILE}} \\
|
|
18
|
+
-p "You are a helpful assistant" \\
|
|
19
|
+
--conversation`);
|
|
20
|
+
});
|
|
21
|
+
(0, vitest_1.it)("llama.cpp non-conversational", async () => {
|
|
22
|
+
const { snippet: snippetFunc } = local_apps_js_1.LOCAL_APPS["llama.cpp"];
|
|
23
|
+
const model = {
|
|
24
|
+
id: "mlabonne/gemma-2b-GGUF",
|
|
25
|
+
tags: [],
|
|
26
|
+
inference: "",
|
|
27
|
+
};
|
|
28
|
+
const snippet = snippetFunc(model);
|
|
29
|
+
(0, vitest_1.expect)(snippet[0].content).toEqual(`# Load and run the model:
|
|
30
|
+
llama-cli \\
|
|
31
|
+
--hf-repo "mlabonne/gemma-2b-GGUF" \\
|
|
32
|
+
--hf-file {{GGUF_FILE}} \\
|
|
33
|
+
-p "Once upon a time,"`);
|
|
34
|
+
});
|
|
35
|
+
(0, vitest_1.it)("vLLM conversational llm", async () => {
|
|
36
|
+
const { snippet: snippetFunc } = local_apps_js_1.LOCAL_APPS["vllm"];
|
|
37
|
+
const model = {
|
|
38
|
+
id: "meta-llama/Llama-3.2-3B-Instruct",
|
|
39
|
+
pipeline_tag: "text-generation",
|
|
40
|
+
tags: ["conversational"],
|
|
41
|
+
inference: "",
|
|
42
|
+
};
|
|
43
|
+
const snippet = snippetFunc(model);
|
|
44
|
+
(0, vitest_1.expect)(snippet[0].content.join("\n")).toEqual(`# Load and run the model:
|
|
45
|
+
vllm serve "meta-llama/Llama-3.2-3B-Instruct"
|
|
46
|
+
# Call the server using curl:
|
|
47
|
+
curl -X POST "http://localhost:8000/v1/chat/completions" \\
|
|
48
|
+
-H "Content-Type: application/json" \\
|
|
49
|
+
--data '{
|
|
50
|
+
"model": "meta-llama/Llama-3.2-3B-Instruct",
|
|
51
|
+
"messages": [
|
|
52
|
+
{
|
|
53
|
+
"role": "user",
|
|
54
|
+
"content": "What is the capital of France?"
|
|
55
|
+
}
|
|
56
|
+
]
|
|
57
|
+
}'`);
|
|
58
|
+
});
|
|
59
|
+
(0, vitest_1.it)("vLLM non-conversational llm", async () => {
|
|
60
|
+
const { snippet: snippetFunc } = local_apps_js_1.LOCAL_APPS["vllm"];
|
|
61
|
+
const model = {
|
|
62
|
+
id: "meta-llama/Llama-3.2-3B",
|
|
63
|
+
tags: [""],
|
|
64
|
+
inference: "",
|
|
65
|
+
};
|
|
66
|
+
const snippet = snippetFunc(model);
|
|
67
|
+
(0, vitest_1.expect)(snippet[0].content.join("\n")).toEqual(`# Load and run the model:
|
|
68
|
+
vllm serve "meta-llama/Llama-3.2-3B"
|
|
69
|
+
# Call the server using curl:
|
|
70
|
+
curl -X POST "http://localhost:8000/v1/completions" \\
|
|
71
|
+
-H "Content-Type: application/json" \\
|
|
72
|
+
--data '{
|
|
73
|
+
"model": "meta-llama/Llama-3.2-3B",
|
|
74
|
+
"prompt": "Once upon a time,",
|
|
75
|
+
"max_tokens": 512,
|
|
76
|
+
"temperature": 0.5
|
|
77
|
+
}'`);
|
|
78
|
+
});
|
|
79
|
+
(0, vitest_1.it)("vLLM conversational vlm", async () => {
|
|
80
|
+
const { snippet: snippetFunc } = local_apps_js_1.LOCAL_APPS["vllm"];
|
|
81
|
+
const model = {
|
|
82
|
+
id: "meta-llama/Llama-3.2-11B-Vision-Instruct",
|
|
83
|
+
pipeline_tag: "image-text-to-text",
|
|
84
|
+
tags: ["conversational"],
|
|
85
|
+
inference: "",
|
|
86
|
+
};
|
|
87
|
+
const snippet = snippetFunc(model);
|
|
88
|
+
(0, vitest_1.expect)(snippet[0].content.join("\n")).toEqual(`# Load and run the model:
|
|
89
|
+
vllm serve "meta-llama/Llama-3.2-11B-Vision-Instruct"
|
|
90
|
+
# Call the server using curl:
|
|
91
|
+
curl -X POST "http://localhost:8000/v1/chat/completions" \\
|
|
92
|
+
-H "Content-Type: application/json" \\
|
|
93
|
+
--data '{
|
|
94
|
+
"model": "meta-llama/Llama-3.2-11B-Vision-Instruct",
|
|
95
|
+
"messages": [
|
|
96
|
+
{
|
|
97
|
+
"role": "user",
|
|
98
|
+
"content": [
|
|
99
|
+
{
|
|
100
|
+
"type": "text",
|
|
101
|
+
"text": "Describe this image in one sentence."
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"type": "image_url",
|
|
105
|
+
"image_url": {
|
|
106
|
+
"url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}'`);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-libraries-snippets.d.ts","sourceRoot":"","sources":["../../src/model-libraries-snippets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"model-libraries-snippets.d.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AAG,MAAM,EAOhD,CAAC;AAEF,eAAO,MAAM,QAAQ,UAAW,SAAS,KAAG,MAAM,EAYjD,CAAC;AAEF,eAAO,MAAM,GAAG,UAAW,SAAS,KAAG,MAAM,EAK5C,CAAC;AAEF,eAAO,MAAM,KAAK,UAAW,SAAS,KAAG,MAAM,EAI9C,CAAC;AAEF,eAAO,MAAM,SAAS,UAAW,SAAS,KAAG,MAAM,EAIlD,CAAC;AAEF,eAAO,MAAM,IAAI,UAAW,SAAS,KAAG,MAAM,EAQ7C,CAAC;AAEF,eAAO,MAAM,IAAI,UAAW,SAAS,KAAG,MAAM,EAI7C,CAAC;AAEF,eAAO,MAAM,MAAM,UAAW,SAAS,KAAG,MAAM,EAI/C,CAAC;AA6BF,eAAO,MAAM,UAAU,UAAW,SAAS,KAAG,MAAM,EAUnD,CAAC;AAEF,eAAO,MAAM,UAAU,QAAO,MAAM,EAYnC,CAAC;AAEF,eAAO,MAAM,cAAc,UAAW,SAAS,KAAG,MAAM,EAKvD,CAAC;AAEF,eAAO,MAAM,KAAK,UAAW,SAAS,KAAG,MAAM,EAI9C,CAAC"}
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.transformersJS = exports.transformers = exports.speechbrain = exports.stanza = exports.span_marker = exports.spacy = exports.setfit = exports.sentenceTransformers = exports.sampleFactory = exports.sam2 = exports.fastai = exports.stable_audio_tools = exports.sklearn = exports.seed_story = exports.saelens = exports.timm = exports.tensorflowtts = exports.relik = exports.pyannote_audio = exports.pyannote_audio_pipeline = exports.paddlenlp = exports.open_clip = exports.mesh_anything = exports.mars5_tts = exports.mamba_ssm = exports.tf_keras = exports.llama_cpp_python = exports.keras_hub = exports.keras_nlp = exports.keras = exports.htrflow = exports.gliner = exports.flair = exports.fairseq = exports.espnet = exports.espnetASR = exports.espnetTTS = exports.edsnlp = exports.cartesia_mlx = exports.cartesia_pytorch = exports.diffusionkit = exports.diffusers = exports.depth_pro = exports.depth_anything_v2 = exports.bm25s = exports.bertopic = exports.audioseal = exports.asteroid = exports.allennlp = exports.adapters = void 0;
|
|
4
4
|
exports.hezar = exports.threedtopia_xl = exports.whisperkit = exports.audiocraft = exports.pythae = exports.pxia = exports.nemo = exports.model2vec = exports.mlxim = exports.mlx = exports.birefnet = exports.yolov10 = exports.chattts = exports.voicecraft = exports.vfimamba = exports.sentis = exports.mlAgents = exports.stableBaselines3 = exports.fasttext = exports.peft = void 0;
|
|
5
5
|
const library_to_tasks_js_1 = require("./library-to-tasks.js");
|
|
6
|
+
const inputs_js_1 = require("./snippets/inputs.js");
|
|
7
|
+
const common_js_1 = require("./snippets/common.js");
|
|
6
8
|
const TAG_CUSTOM_CODE = "custom_code";
|
|
7
9
|
function nameWithoutNamespace(modelId) {
|
|
8
10
|
const splitted = modelId.split("/");
|
|
@@ -401,23 +403,32 @@ model = keras_hub.models.CausalLM.from_preset("hf://${model.id}", dtype="bfloat1
|
|
|
401
403
|
`,
|
|
402
404
|
];
|
|
403
405
|
exports.keras_hub = keras_hub;
|
|
404
|
-
const llama_cpp_python = (model) =>
|
|
405
|
-
|
|
406
|
+
const llama_cpp_python = (model) => {
|
|
407
|
+
const snippets = [
|
|
408
|
+
`from llama_cpp import Llama
|
|
406
409
|
|
|
407
410
|
llm = Llama.from_pretrained(
|
|
408
411
|
repo_id="${model.id}",
|
|
409
412
|
filename="{{GGUF_FILE}}",
|
|
410
413
|
)
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
414
|
+
`,
|
|
415
|
+
];
|
|
416
|
+
if (model.tags.includes("conversational")) {
|
|
417
|
+
const messages = (0, inputs_js_1.getModelInputSnippet)(model);
|
|
418
|
+
snippets.push(`llm.create_chat_completion(
|
|
419
|
+
messages = ${(0, common_js_1.stringifyMessages)(messages, { attributeKeyQuotes: true, indent: "\t" })}
|
|
420
|
+
)`);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
snippets.push(`output = llm(
|
|
424
|
+
"Once upon a time,",
|
|
425
|
+
max_tokens=512,
|
|
426
|
+
echo=True
|
|
427
|
+
)
|
|
428
|
+
print(output)`);
|
|
429
|
+
}
|
|
430
|
+
return snippets;
|
|
431
|
+
};
|
|
421
432
|
exports.llama_cpp_python = llama_cpp_python;
|
|
422
433
|
const tf_keras = (model) => [
|
|
423
434
|
`# Note: 'keras<3.x' or 'tf_keras' must be installed (legacy)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-libraries-snippets.spec.d.ts","sourceRoot":"","sources":["../../src/model-libraries-snippets.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const model_libraries_snippets_js_1 = require("./model-libraries-snippets.js");
|
|
5
|
+
(0, vitest_1.describe)("model-libraries-snippets", () => {
|
|
6
|
+
(0, vitest_1.it)("llama_cpp_python conversational", async () => {
|
|
7
|
+
const model = {
|
|
8
|
+
id: "bartowski/Llama-3.2-3B-Instruct-GGUF",
|
|
9
|
+
pipeline_tag: "text-generation",
|
|
10
|
+
tags: ["conversational"],
|
|
11
|
+
inference: "",
|
|
12
|
+
};
|
|
13
|
+
const snippet = (0, model_libraries_snippets_js_1.llama_cpp_python)(model);
|
|
14
|
+
(0, vitest_1.expect)(snippet.join("\n")).toEqual(`from llama_cpp import Llama
|
|
15
|
+
|
|
16
|
+
llm = Llama.from_pretrained(
|
|
17
|
+
repo_id="bartowski/Llama-3.2-3B-Instruct-GGUF",
|
|
18
|
+
filename="{{GGUF_FILE}}",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
llm.create_chat_completion(
|
|
22
|
+
messages = [
|
|
23
|
+
{
|
|
24
|
+
"role": "user",
|
|
25
|
+
"content": "What is the capital of France?"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
)`);
|
|
29
|
+
});
|
|
30
|
+
(0, vitest_1.it)("llama_cpp_python non-conversational", async () => {
|
|
31
|
+
const model = {
|
|
32
|
+
id: "mlabonne/gemma-2b-GGUF",
|
|
33
|
+
tags: [""],
|
|
34
|
+
inference: "",
|
|
35
|
+
};
|
|
36
|
+
const snippet = (0, model_libraries_snippets_js_1.llama_cpp_python)(model);
|
|
37
|
+
(0, vitest_1.expect)(snippet.join("\n")).toEqual(`from llama_cpp import Llama
|
|
38
|
+
|
|
39
|
+
llm = Llama.from_pretrained(
|
|
40
|
+
repo_id="mlabonne/gemma-2b-GGUF",
|
|
41
|
+
filename="{{GGUF_FILE}}",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
output = llm(
|
|
45
|
+
"Once upon a time,",
|
|
46
|
+
max_tokens=512,
|
|
47
|
+
echo=True
|
|
48
|
+
)
|
|
49
|
+
print(output)`);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/audio-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,6BAA6B,CAAC;IAC3C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC7C,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,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/audio-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;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,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,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"}
|
|
@@ -24,6 +24,9 @@ export interface ImageClassificationInput {
|
|
|
24
24
|
* Additional inference parameters for Image Classification
|
|
25
25
|
*/
|
|
26
26
|
export interface ImageClassificationParameters {
|
|
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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inference.d.ts","sourceRoot":"","sources":["../../../../src/tasks/image-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,6BAA6B,CAAC;IAC3C,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;CAC5B;AACD;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC7C,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,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/image-classification/inference.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACxC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;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,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,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"}
|
|
@@ -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"}
|
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-apps.d.ts","sourceRoot":"","sources":["../../src/local-apps.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,YAAY,EAA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e,EAAE;;;;;;;yBA0CzC,SAAS,aAAa,MAAM,KAAG,eAAe,EAAE;;;;;;oCA6JzD,SAAS;yBA5GX,SAAS,KAAG,eAAe,EAAE;;;;;;;yBAiD9B,SAAS,KAAG,eAAe,EAAE;;;;;;;;;;;;;;yBAxEzB,SAAS,aAAa,MAAM,KAAG,eAAe,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBATjD,SAAS,aAAa,MAAM,KAAG,MAAM;;CAiR/B,CAAC;AAErC,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,UAAU,CAAC"}
|
package/dist/esm/local-apps.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { parseGGUFQuantLabel } from "./gguf.js";
|
|
2
|
+
import { stringifyMessages } from "./snippets/common.js";
|
|
3
|
+
import { getModelInputSnippet } from "./snippets/inputs.js";
|
|
2
4
|
function isAwqModel(model) {
|
|
3
5
|
return model.config?.quantization_config?.quant_method === "awq";
|
|
4
6
|
}
|
|
@@ -24,14 +26,20 @@ function isMlxModel(model) {
|
|
|
24
26
|
return model.tags.includes("mlx");
|
|
25
27
|
}
|
|
26
28
|
const snippetLlamacpp = (model, filepath) => {
|
|
27
|
-
const command = (binary) =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
const command = (binary) => {
|
|
30
|
+
const snippet = [
|
|
31
|
+
"# Load and run the model:",
|
|
32
|
+
`${binary} \\`,
|
|
33
|
+
` --hf-repo "${model.id}" \\`,
|
|
34
|
+
` --hf-file ${filepath ?? "{{GGUF_FILE}}"} \\`,
|
|
35
|
+
` -p "${model.tags.includes("conversational") ? "You are a helpful assistant" : "Once upon a time,"}"`,
|
|
36
|
+
];
|
|
37
|
+
if (model.tags.includes("conversational")) {
|
|
38
|
+
snippet[snippet.length - 1] += " \\";
|
|
39
|
+
snippet.push(" --conversation");
|
|
40
|
+
}
|
|
41
|
+
return snippet.join("\n");
|
|
42
|
+
};
|
|
35
43
|
return [
|
|
36
44
|
{
|
|
37
45
|
title: "Install from brew",
|
|
@@ -102,22 +110,33 @@ const snippetLocalAI = (model, filepath) => {
|
|
|
102
110
|
];
|
|
103
111
|
};
|
|
104
112
|
const snippetVllm = (model) => {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
const messages = getModelInputSnippet(model);
|
|
114
|
+
const runCommandInstruct = `# Call the server using curl:
|
|
115
|
+
curl -X POST "http://localhost:8000/v1/chat/completions" \\
|
|
116
|
+
-H "Content-Type: application/json" \\
|
|
117
|
+
--data '{
|
|
118
|
+
"model": "${model.id}",
|
|
119
|
+
"messages": ${stringifyMessages(messages, {
|
|
120
|
+
indent: "\t\t",
|
|
121
|
+
attributeKeyQuotes: true,
|
|
122
|
+
customContentEscaper: (str) => str.replace(/'/g, "'\\''"),
|
|
123
|
+
})}
|
|
124
|
+
}'`;
|
|
125
|
+
const runCommandNonInstruct = `# Call the server using curl:
|
|
126
|
+
curl -X POST "http://localhost:8000/v1/completions" \\
|
|
127
|
+
-H "Content-Type: application/json" \\
|
|
128
|
+
--data '{
|
|
129
|
+
"model": "${model.id}",
|
|
130
|
+
"prompt": "Once upon a time,",
|
|
131
|
+
"max_tokens": 512,
|
|
132
|
+
"temperature": 0.5
|
|
133
|
+
}'`;
|
|
134
|
+
const runCommand = model.tags.includes("conversational") ? runCommandInstruct : runCommandNonInstruct;
|
|
116
135
|
return [
|
|
117
136
|
{
|
|
118
137
|
title: "Install from pip",
|
|
119
138
|
setup: ["# Install vLLM from pip:", "pip install vllm"].join("\n"),
|
|
120
|
-
content: [`# Load and run the model:\nvllm serve "${model.id}"`, runCommand
|
|
139
|
+
content: [`# Load and run the model:\nvllm serve "${model.id}"`, runCommand],
|
|
121
140
|
},
|
|
122
141
|
{
|
|
123
142
|
title: "Use Docker images",
|
|
@@ -134,7 +153,7 @@ const snippetVllm = (model) => {
|
|
|
134
153
|
].join("\n"),
|
|
135
154
|
content: [
|
|
136
155
|
`# Load and run the model:\ndocker exec -it my_vllm_container bash -c "vllm serve ${model.id}"`,
|
|
137
|
-
runCommand
|
|
156
|
+
runCommand,
|
|
138
157
|
],
|
|
139
158
|
},
|
|
140
159
|
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-apps.spec.d.ts","sourceRoot":"","sources":["../../src/local-apps.spec.ts"],"names":[],"mappings":""}
|