@huggingface/tasks 0.21.54 → 0.21.56
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/hardware-amd.d.ts.map +1 -1
- package/dist/commonjs/hardware-amd.js +48 -0
- package/dist/commonjs/hardware-nvidia.d.ts +1 -0
- package/dist/commonjs/hardware-nvidia.d.ts.map +1 -1
- package/dist/commonjs/hardware-nvidia.js +122 -0
- package/dist/commonjs/library-to-tasks.d.ts.map +1 -1
- package/dist/commonjs/library-to-tasks.js +8 -1
- package/dist/commonjs/model-libraries-snippets.d.ts +3 -1
- package/dist/commonjs/model-libraries-snippets.d.ts.map +1 -1
- package/dist/commonjs/model-libraries-snippets.js +349 -154
- package/dist/commonjs/model-libraries-snippets.spec.js +300 -0
- package/dist/commonjs/model-libraries.d.ts +11 -2
- package/dist/commonjs/model-libraries.d.ts.map +1 -1
- package/dist/commonjs/model-libraries.js +10 -1
- package/dist/esm/hardware-amd.d.ts.map +1 -1
- package/dist/esm/hardware-amd.js +48 -0
- package/dist/esm/hardware-nvidia.d.ts +1 -0
- package/dist/esm/hardware-nvidia.d.ts.map +1 -1
- package/dist/esm/hardware-nvidia.js +122 -0
- package/dist/esm/library-to-tasks.d.ts.map +1 -1
- package/dist/esm/library-to-tasks.js +8 -1
- package/dist/esm/model-libraries-snippets.d.ts +3 -1
- package/dist/esm/model-libraries-snippets.d.ts.map +1 -1
- package/dist/esm/model-libraries-snippets.js +344 -151
- package/dist/esm/model-libraries-snippets.spec.js +301 -1
- package/dist/esm/model-libraries.d.ts +11 -2
- package/dist/esm/model-libraries.d.ts.map +1 -1
- package/dist/esm/model-libraries.js +10 -1
- package/package.json +1 -1
- package/src/hardware-amd.ts +48 -0
- package/src/hardware-nvidia.ts +122 -0
- package/src/library-to-tasks.ts +8 -1
- package/src/model-libraries-snippets.spec.ts +389 -0
- package/src/model-libraries-snippets.ts +364 -149
- package/src/model-libraries.ts +10 -1
package/src/hardware-nvidia.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface NvidiaHardwareSpec extends HardwareSpec {
|
|
|
12
12
|
export enum NvidiaComputeCapabilities {
|
|
13
13
|
BLACKWELL_ULTRA = 12.1,
|
|
14
14
|
BLACKWELL_RTX = 12.0,
|
|
15
|
+
THOR = 11.0,
|
|
15
16
|
BLACKWELL = 10.0,
|
|
16
17
|
HOPPER = 9.0,
|
|
17
18
|
ADA_LOVELACE = 8.9,
|
|
@@ -717,6 +718,14 @@ export const NVIDIA_SKUS: Record<string, NvidiaHardwareSpec> = {
|
|
|
717
718
|
power: 170,
|
|
718
719
|
releaseYear: 2021,
|
|
719
720
|
},
|
|
721
|
+
"RTX 3050": {
|
|
722
|
+
tflops: 9.098,
|
|
723
|
+
memory: [8, 6],
|
|
724
|
+
computeCapability: 8.6,
|
|
725
|
+
msrp: 249,
|
|
726
|
+
power: 130,
|
|
727
|
+
releaseYear: 2022,
|
|
728
|
+
},
|
|
720
729
|
"RTX 2080 Ti": {
|
|
721
730
|
tflops: 26.9,
|
|
722
731
|
memory: [11, 22], // 22GB: modded 2080ti
|
|
@@ -733,6 +742,14 @@ export const NVIDIA_SKUS: Record<string, NvidiaHardwareSpec> = {
|
|
|
733
742
|
power: 215,
|
|
734
743
|
releaseYear: 2018,
|
|
735
744
|
},
|
|
745
|
+
"RTX 2080 SUPER": {
|
|
746
|
+
tflops: 22.3,
|
|
747
|
+
memory: [8],
|
|
748
|
+
computeCapability: 7.5,
|
|
749
|
+
msrp: 699,
|
|
750
|
+
power: 250,
|
|
751
|
+
releaseYear: 2019,
|
|
752
|
+
},
|
|
736
753
|
"RTX 2070": {
|
|
737
754
|
tflops: 14.93,
|
|
738
755
|
memory: [8],
|
|
@@ -773,6 +790,14 @@ export const NVIDIA_SKUS: Record<string, NvidiaHardwareSpec> = {
|
|
|
773
790
|
power: 95,
|
|
774
791
|
releaseYear: 2022,
|
|
775
792
|
},
|
|
793
|
+
"RTX 2060 SUPER": {
|
|
794
|
+
tflops: 14.36,
|
|
795
|
+
memory: [8],
|
|
796
|
+
computeCapability: 7.5,
|
|
797
|
+
msrp: 399,
|
|
798
|
+
power: 175,
|
|
799
|
+
releaseYear: 2019,
|
|
800
|
+
},
|
|
776
801
|
"RTX 2060": {
|
|
777
802
|
tflops: 12.9,
|
|
778
803
|
memory: [6],
|
|
@@ -861,6 +886,30 @@ export const NVIDIA_SKUS: Record<string, NvidiaHardwareSpec> = {
|
|
|
861
886
|
power: 280,
|
|
862
887
|
releaseYear: 2018,
|
|
863
888
|
},
|
|
889
|
+
"GTX 1660 Ti": {
|
|
890
|
+
tflops: 10.87,
|
|
891
|
+
memory: [6],
|
|
892
|
+
computeCapability: 7.5,
|
|
893
|
+
msrp: 279,
|
|
894
|
+
power: 120,
|
|
895
|
+
releaseYear: 2019,
|
|
896
|
+
},
|
|
897
|
+
"GTX 1660 Ti Mobile": {
|
|
898
|
+
tflops: 9.769,
|
|
899
|
+
memory: [6],
|
|
900
|
+
computeCapability: 7.5,
|
|
901
|
+
msrp: 250,
|
|
902
|
+
power: 80,
|
|
903
|
+
releaseYear: 2019,
|
|
904
|
+
},
|
|
905
|
+
"GTX 1660 SUPER": {
|
|
906
|
+
tflops: 10.05,
|
|
907
|
+
memory: [6],
|
|
908
|
+
computeCapability: 7.5,
|
|
909
|
+
msrp: 229,
|
|
910
|
+
power: 125,
|
|
911
|
+
releaseYear: 2019,
|
|
912
|
+
},
|
|
864
913
|
"GTX 1660": {
|
|
865
914
|
tflops: 10.05,
|
|
866
915
|
memory: [6],
|
|
@@ -869,6 +918,30 @@ export const NVIDIA_SKUS: Record<string, NvidiaHardwareSpec> = {
|
|
|
869
918
|
power: 120,
|
|
870
919
|
releaseYear: 2019,
|
|
871
920
|
},
|
|
921
|
+
"GTX 1650 SUPER": {
|
|
922
|
+
tflops: 8.832,
|
|
923
|
+
memory: [4],
|
|
924
|
+
computeCapability: 7.5,
|
|
925
|
+
msrp: 159,
|
|
926
|
+
power: 100,
|
|
927
|
+
releaseYear: 2019,
|
|
928
|
+
},
|
|
929
|
+
"GTX 1650": {
|
|
930
|
+
tflops: 5.967,
|
|
931
|
+
memory: [4],
|
|
932
|
+
computeCapability: 7.5,
|
|
933
|
+
msrp: 149,
|
|
934
|
+
power: 75,
|
|
935
|
+
releaseYear: 2019,
|
|
936
|
+
},
|
|
937
|
+
"GTX 1650 Ti Mobile": {
|
|
938
|
+
tflops: 6.083,
|
|
939
|
+
memory: [4],
|
|
940
|
+
computeCapability: 7.5,
|
|
941
|
+
msrp: 200,
|
|
942
|
+
power: 55,
|
|
943
|
+
releaseYear: 2020,
|
|
944
|
+
},
|
|
872
945
|
"GTX 1650 Mobile": {
|
|
873
946
|
tflops: 6.39,
|
|
874
947
|
memory: [4],
|
|
@@ -877,6 +950,14 @@ export const NVIDIA_SKUS: Record<string, NvidiaHardwareSpec> = {
|
|
|
877
950
|
power: 50,
|
|
878
951
|
releaseYear: 2019,
|
|
879
952
|
},
|
|
953
|
+
"GTX 1630": {
|
|
954
|
+
tflops: 3.656,
|
|
955
|
+
memory: [4],
|
|
956
|
+
computeCapability: 7.5,
|
|
957
|
+
msrp: 170,
|
|
958
|
+
power: 75,
|
|
959
|
+
releaseYear: 2022,
|
|
960
|
+
},
|
|
880
961
|
T4: {
|
|
881
962
|
tflops: 65.13,
|
|
882
963
|
memory: [16],
|
|
@@ -885,6 +966,14 @@ export const NVIDIA_SKUS: Record<string, NvidiaHardwareSpec> = {
|
|
|
885
966
|
power: 70,
|
|
886
967
|
releaseYear: 2018,
|
|
887
968
|
},
|
|
969
|
+
T40: {
|
|
970
|
+
tflops: 28.75,
|
|
971
|
+
memory: [24],
|
|
972
|
+
computeCapability: 7.5,
|
|
973
|
+
msrp: 4_000,
|
|
974
|
+
power: 250,
|
|
975
|
+
releaseYear: 2019,
|
|
976
|
+
},
|
|
888
977
|
T10: {
|
|
889
978
|
tflops: 20.0,
|
|
890
979
|
memory: [16],
|
|
@@ -901,6 +990,30 @@ export const NVIDIA_SKUS: Record<string, NvidiaHardwareSpec> = {
|
|
|
901
990
|
power: 300,
|
|
902
991
|
releaseYear: 2017,
|
|
903
992
|
},
|
|
993
|
+
"Quadro RTX 8000": {
|
|
994
|
+
tflops: 32.63,
|
|
995
|
+
memory: [48],
|
|
996
|
+
computeCapability: 7.5,
|
|
997
|
+
msrp: 10_000,
|
|
998
|
+
power: 295,
|
|
999
|
+
releaseYear: 2018,
|
|
1000
|
+
},
|
|
1001
|
+
"Quadro RTX 6000": {
|
|
1002
|
+
tflops: 32.63,
|
|
1003
|
+
memory: [24],
|
|
1004
|
+
computeCapability: 7.5,
|
|
1005
|
+
msrp: 6_300,
|
|
1006
|
+
power: 295,
|
|
1007
|
+
releaseYear: 2018,
|
|
1008
|
+
},
|
|
1009
|
+
"Quadro RTX 5000": {
|
|
1010
|
+
tflops: 22.3,
|
|
1011
|
+
memory: [16],
|
|
1012
|
+
computeCapability: 7.5,
|
|
1013
|
+
msrp: 2_300,
|
|
1014
|
+
power: 265,
|
|
1015
|
+
releaseYear: 2018,
|
|
1016
|
+
},
|
|
904
1017
|
"Quadro P6000": {
|
|
905
1018
|
tflops: 12.63, // float32 (GPU does not support native float16)
|
|
906
1019
|
memory: [24],
|
|
@@ -925,6 +1038,15 @@ export const NVIDIA_SKUS: Record<string, NvidiaHardwareSpec> = {
|
|
|
925
1038
|
power: 300,
|
|
926
1039
|
releaseYear: 2016,
|
|
927
1040
|
},
|
|
1041
|
+
"Jetson T5000": {
|
|
1042
|
+
tflops: 258.5, // half the sparse fp16 figure
|
|
1043
|
+
memory: [128],
|
|
1044
|
+
computeCapability: 11.0,
|
|
1045
|
+
msrp: 3_499,
|
|
1046
|
+
power: 130,
|
|
1047
|
+
releaseYear: 2025,
|
|
1048
|
+
aliases: ["Jetson AGX Thor"],
|
|
1049
|
+
},
|
|
928
1050
|
"Jetson AGX Orin 64GB": {
|
|
929
1051
|
tflops: 10.65,
|
|
930
1052
|
memory: [64],
|
package/src/library-to-tasks.ts
CHANGED
|
@@ -72,4 +72,11 @@ export const LIBRARY_TASK_MAPPING: Partial<Record<ModelLibraryKey, PipelineType[
|
|
|
72
72
|
};
|
|
73
73
|
|
|
74
74
|
// Pipeline types that were supported in legacy transformers versions (<5.0.0)
|
|
75
|
-
export const REMOVED_IN_V5_TRANSFORMERS_PIPELINES: PipelineType[] = [
|
|
75
|
+
export const REMOVED_IN_V5_TRANSFORMERS_PIPELINES: PipelineType[] = [
|
|
76
|
+
"image-to-image",
|
|
77
|
+
"image-to-text",
|
|
78
|
+
"question-answering",
|
|
79
|
+
"summarization",
|
|
80
|
+
"translation",
|
|
81
|
+
"visual-question-answering",
|
|
82
|
+
];
|
|
@@ -2,14 +2,36 @@ import { describe, expect, it } from "vitest";
|
|
|
2
2
|
import type { ModelData } from "./model-data.js";
|
|
3
3
|
import {
|
|
4
4
|
adapters,
|
|
5
|
+
cartesia_pytorch,
|
|
6
|
+
depth_anything_v2,
|
|
7
|
+
describe_anything,
|
|
5
8
|
diffusers,
|
|
9
|
+
diffusionkit,
|
|
10
|
+
gliner2,
|
|
11
|
+
indextts,
|
|
6
12
|
keras_hub,
|
|
13
|
+
kernels,
|
|
14
|
+
kimi_audio,
|
|
15
|
+
litert_lm,
|
|
7
16
|
llama_cpp_python,
|
|
17
|
+
microduck,
|
|
18
|
+
mlAgents,
|
|
19
|
+
mlxim,
|
|
8
20
|
multimolecule,
|
|
9
21
|
paddlenlp,
|
|
10
22
|
peft,
|
|
23
|
+
phantom_wan,
|
|
24
|
+
pruna,
|
|
25
|
+
sam2,
|
|
26
|
+
sam_3d_body,
|
|
27
|
+
sentenceTransformers,
|
|
11
28
|
sklearn,
|
|
29
|
+
speechbrain,
|
|
30
|
+
timm,
|
|
12
31
|
transformers,
|
|
32
|
+
transformersJS,
|
|
33
|
+
ultralytics,
|
|
34
|
+
vui,
|
|
13
35
|
} from "./model-libraries-snippets.js";
|
|
14
36
|
|
|
15
37
|
describe("model-libraries-snippets", () => {
|
|
@@ -66,6 +88,29 @@ output = llm(
|
|
|
66
88
|
print(output)`);
|
|
67
89
|
});
|
|
68
90
|
|
|
91
|
+
describe("microduck", () => {
|
|
92
|
+
it("uses an explicit slot tag even when the repo name and other tags suggest walking", () => {
|
|
93
|
+
const model: ModelData = {
|
|
94
|
+
id: "user/microduck-walk",
|
|
95
|
+
tags: ["microduck", "walk", "microduck-slot:stand", "microduck-slot:stand"],
|
|
96
|
+
inference: "",
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
expect(microduck(model)).toEqual(["sudo robotctl policy load stand user/microduck-walk"]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it.each([
|
|
103
|
+
{ scenario: "missing slot tags", tags: ["microduck", "walk"] },
|
|
104
|
+
{ scenario: "unsupported slot tags", tags: ["microduck-slot:bow"] },
|
|
105
|
+
{ scenario: "conflicting slot tags", tags: ["microduck-slot:walk", "microduck-slot:stand"] },
|
|
106
|
+
])("requires a slot choice for $scenario", ({ tags }) => {
|
|
107
|
+
const snippet = microduck({ id: "user/microduck-walk", tags, inference: "" }).join("\n");
|
|
108
|
+
|
|
109
|
+
expect(snippet).toContain("# Replace SLOT with the slot specified in the model card");
|
|
110
|
+
expect(snippet).toContain("sudo robotctl policy load SLOT user/microduck-walk");
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
69
114
|
// a repo owner can put anything in config.json / the model card, so every interpolated value
|
|
70
115
|
// must either be escaped (string literals) or rejected (bare identifiers)
|
|
71
116
|
describe("repo-controlled values are not injectable", () => {
|
|
@@ -75,6 +120,7 @@ print(output)`);
|
|
|
75
120
|
["adapters", adapters, { config: { adapter_transformers: { model_name: PAYLOAD } } }],
|
|
76
121
|
["diffusers", diffusers, { tags: ["lora"], cardData: { base_model: PAYLOAD, instance_prompt: PAYLOAD } }],
|
|
77
122
|
["keras_hub", keras_hub, { config: { keras_hub: { tasks: [PAYLOAD, "TextClassifier"] } } }],
|
|
123
|
+
["microduck", microduck, { tags: [`microduck-slot:${PAYLOAD}`] }],
|
|
78
124
|
["paddlenlp", paddlenlp, { config: { architectures: [PAYLOAD] } }],
|
|
79
125
|
["peft", peft, { config: { peft: { base_model_name_or_path: PAYLOAD, task_type: "CAUSAL_LM" } } }],
|
|
80
126
|
["multimolecule", multimolecule, { widgetData: [{ text: PAYLOAD }] }],
|
|
@@ -100,4 +146,347 @@ print(output)`);
|
|
|
100
146
|
expect(keras_hub(model as ModelData).join("\n")).toContain("keras_hub.models.TextClassifier.from_preset");
|
|
101
147
|
});
|
|
102
148
|
});
|
|
149
|
+
|
|
150
|
+
describe("snippets stay runnable for the common repo shapes", () => {
|
|
151
|
+
const base = { id: "user/model", tags: [] as string[], inference: "" };
|
|
152
|
+
|
|
153
|
+
it("transformers: the chat example needs a chat template, not only the conversational tag", () => {
|
|
154
|
+
const chatModel = {
|
|
155
|
+
...base,
|
|
156
|
+
pipeline_tag: "text-generation",
|
|
157
|
+
tags: ["conversational"],
|
|
158
|
+
transformersInfo: { auto_model: "AutoModelForCausalLM", processor: "AutoTokenizer" },
|
|
159
|
+
} as ModelData;
|
|
160
|
+
const [pipelineWithoutTemplate] = transformers(chatModel);
|
|
161
|
+
expect(pipelineWithoutTemplate).not.toContain("messages");
|
|
162
|
+
|
|
163
|
+
const [pipelineSnippet, autoSnippet] = transformers({
|
|
164
|
+
...chatModel,
|
|
165
|
+
config: { tokenizer_config: { chat_template: "{{ messages }}" } },
|
|
166
|
+
} as ModelData);
|
|
167
|
+
expect(pipelineSnippet).toContain("pipe(messages)");
|
|
168
|
+
expect(autoSnippet).toContain("max_new_tokens=256");
|
|
169
|
+
expect(autoSnippet).toContain("# pip install -U transformers accelerate");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("transformers: pipelines removed in v5 get a warning with a valid pip command", () => {
|
|
173
|
+
const [snippet] = transformers({
|
|
174
|
+
...base,
|
|
175
|
+
pipeline_tag: "question-answering",
|
|
176
|
+
transformersInfo: { auto_model: "AutoModelForQuestionAnswering", processor: "AutoTokenizer" },
|
|
177
|
+
} as ModelData);
|
|
178
|
+
expect(snippet).toContain("no longer supported in transformers v5");
|
|
179
|
+
expect(snippet).toContain(`# pip install "transformers<5.0.0"`);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it("sentence-transformers: rerankers tagged text-classification use CrossEncoder", () => {
|
|
183
|
+
const [reranker] = sentenceTransformers({
|
|
184
|
+
...base,
|
|
185
|
+
pipeline_tag: "text-classification",
|
|
186
|
+
config: { architectures: ["XLMRobertaForSequenceClassification"] },
|
|
187
|
+
} as ModelData);
|
|
188
|
+
expect(reranker).toContain("CrossEncoder(");
|
|
189
|
+
|
|
190
|
+
const [biEncoder] = sentenceTransformers({
|
|
191
|
+
...base,
|
|
192
|
+
pipeline_tag: "sentence-similarity",
|
|
193
|
+
config: { architectures: ["BertModel"] },
|
|
194
|
+
} as ModelData);
|
|
195
|
+
expect(biEncoder).toContain("SentenceTransformer(");
|
|
196
|
+
|
|
197
|
+
// SetFit bi-encoders can carry a *ForSequenceClassification config too (e.g. NW-temp/previous-best-my-awesome-setfit-model)
|
|
198
|
+
const [setfitModel] = sentenceTransformers({
|
|
199
|
+
...base,
|
|
200
|
+
tags: ["setfit"],
|
|
201
|
+
pipeline_tag: "text-classification",
|
|
202
|
+
config: { architectures: ["DistilBertForSequenceClassification"] },
|
|
203
|
+
} as ModelData);
|
|
204
|
+
expect(setfitModel).not.toContain("CrossEncoder(");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it("sentence-transformers: sparse encoders use SparseEncoder", () => {
|
|
208
|
+
const [snippet] = sentenceTransformers({ ...base, tags: ["sparse-encoder"] } as ModelData);
|
|
209
|
+
expect(snippet).toContain("SparseEncoder(");
|
|
210
|
+
expect(snippet).toContain("encode_query(");
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it("sentence-transformers: multi-vector encoders use MultiVectorEncoder", () => {
|
|
214
|
+
// e.g. answerdotai/answerai-colbert-small-v1, tagged multi-vector by the library on push
|
|
215
|
+
const [snippet] = sentenceTransformers({ ...base, tags: ["multi-vector"] } as ModelData);
|
|
216
|
+
expect(snippet).toContain(`MultiVectorEncoder("user/model")`);
|
|
217
|
+
expect(snippet).toContain("encode_document(");
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("diffusers: prefixed pipeline class tags reach the dedicated branches", () => {
|
|
221
|
+
const inpainting = diffusers({ ...base, tags: ["diffusers:StableDiffusionInpaintPipeline"] } as ModelData);
|
|
222
|
+
expect(inpainting.join("\n")).toContain("AutoPipelineForInpainting");
|
|
223
|
+
// several inpainting repos only ship non-variant weights
|
|
224
|
+
expect(inpainting.join("\n")).not.toContain('variant="fp16"');
|
|
225
|
+
|
|
226
|
+
const fluxFill = diffusers({ ...base, config: { diffusers: { _class_name: "FluxFillPipeline" } } } as ModelData);
|
|
227
|
+
expect(fluxFill.join("\n")).toContain("FluxFillPipeline");
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it("diffusers: the first base model is used when several are listed", () => {
|
|
231
|
+
const snippet = diffusers({
|
|
232
|
+
...base,
|
|
233
|
+
tags: ["lora"],
|
|
234
|
+
cardData: { base_model: ["org/base", "org/base-turbo"] },
|
|
235
|
+
} as ModelData).join("\n");
|
|
236
|
+
expect(snippet).toContain(`"org/base"`);
|
|
237
|
+
expect(snippet).not.toContain("org/base,org/base-turbo");
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("diffusers: a listed Diffusers conversion is preferred over the original checkpoint", () => {
|
|
241
|
+
// e.g. Remade-AI/Rotate: only the -Diffusers repo has a model_index.json
|
|
242
|
+
const snippet = diffusers({
|
|
243
|
+
...base,
|
|
244
|
+
tags: ["lora"],
|
|
245
|
+
pipeline_tag: "image-to-video",
|
|
246
|
+
cardData: { base_model: ["Wan-AI/Wan2.1-I2V-14B-480P", "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers"] },
|
|
247
|
+
} as ModelData).join("\n");
|
|
248
|
+
expect(snippet).toContain(`DiffusionPipeline.from_pretrained("Wan-AI/Wan2.1-I2V-14B-480P-Diffusers"`);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it("diffusers: LoRA image-to-video exports the generated frames", () => {
|
|
252
|
+
const snippet = diffusers({
|
|
253
|
+
...base,
|
|
254
|
+
tags: ["lora"],
|
|
255
|
+
pipeline_tag: "image-to-video",
|
|
256
|
+
cardData: { base_model: "org/base" },
|
|
257
|
+
} as ModelData).join("\n");
|
|
258
|
+
expect(snippet).toContain("output = pipe(");
|
|
259
|
+
expect(snippet).toContain(`export_to_video(output, "output.mp4")`);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it("transformers.js: Hub tasks without a pipeline() task of the same name are mapped", () => {
|
|
263
|
+
expect(transformersJS({ ...base, pipeline_tag: "sentence-similarity" } as ModelData)[0]).toContain(
|
|
264
|
+
"pipeline('feature-extraction'",
|
|
265
|
+
);
|
|
266
|
+
expect(transformersJS({ ...base, pipeline_tag: "fill-mask" } as ModelData)[0]).toContain("pipeline('fill-mask'");
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it("transformers.js: rerankers score query/document pairs instead of using the text-classification pipeline", () => {
|
|
270
|
+
// the text-classification pipeline takes no text pairs and softmaxes a single logit, so every score is 1
|
|
271
|
+
const [snippet] = transformersJS({ ...base, pipeline_tag: "text-ranking" } as ModelData);
|
|
272
|
+
expect(snippet).not.toContain("pipeline(");
|
|
273
|
+
expect(snippet).toContain("AutoModelForSequenceClassification.from_pretrained('user/model')");
|
|
274
|
+
expect(snippet).toContain("text_pair: documents");
|
|
275
|
+
expect(snippet).toContain("logits.sigmoid()");
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
it("peft: every PEFT task type has a loader", () => {
|
|
279
|
+
const adapter = (task_type: string) =>
|
|
280
|
+
({ ...base, config: { peft: { base_model_name_or_path: "org/base", task_type } } }) as ModelData;
|
|
281
|
+
expect(peft(adapter("FEATURE_EXTRACTION"))[0]).toContain("AutoModel.from_pretrained");
|
|
282
|
+
expect(peft(adapter("QUESTION_ANS"))[0]).toContain("AutoModelForQuestionAnswering");
|
|
283
|
+
expect(peft(adapter("CAUSAL_LM"))[0]).toContain("AutoModelForCausalLM");
|
|
284
|
+
expect(peft(adapter("UNKNOWN"))[0]).toEqual("Task type is invalid.");
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
it("peft: speech seq2seq adapters use the speech auto class", () => {
|
|
288
|
+
const whisper = peft({
|
|
289
|
+
...base,
|
|
290
|
+
config: { peft: { base_model_name_or_path: "openai/whisper-large-v3", task_type: "SEQ_2_SEQ_LM" } },
|
|
291
|
+
} as ModelData)[0];
|
|
292
|
+
expect(whisper).toContain("AutoModelForSpeechSeq2Seq");
|
|
293
|
+
for (const baseId of [
|
|
294
|
+
"facebook/s2t-small-librispeech-asr",
|
|
295
|
+
"facebook/seamless-m4t-v2-large",
|
|
296
|
+
"microsoft/speecht5_asr",
|
|
297
|
+
]) {
|
|
298
|
+
expect(
|
|
299
|
+
peft({
|
|
300
|
+
...base,
|
|
301
|
+
config: { peft: { base_model_name_or_path: baseId, task_type: "SEQ_2_SEQ_LM" } },
|
|
302
|
+
} as ModelData)[0],
|
|
303
|
+
).toContain("AutoModelForSpeechSeq2Seq");
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const t5 = peft({
|
|
307
|
+
...base,
|
|
308
|
+
config: { peft: { base_model_name_or_path: "google/flan-t5-base", task_type: "SEQ_2_SEQ_LM" } },
|
|
309
|
+
} as ModelData)[0];
|
|
310
|
+
expect(t5).toContain("AutoModelForSeq2SeqLM");
|
|
311
|
+
|
|
312
|
+
// audio models that transformers registers under the text seq2seq class must not be overridden
|
|
313
|
+
const qwenAudio = peft({
|
|
314
|
+
...base,
|
|
315
|
+
pipeline_tag: "automatic-speech-recognition",
|
|
316
|
+
config: { peft: { base_model_name_or_path: "Qwen/Qwen2-Audio-7B", task_type: "SEQ_2_SEQ_LM" } },
|
|
317
|
+
} as ModelData)[0];
|
|
318
|
+
expect(qwenAudio).toContain("AutoModelForSeq2SeqLM");
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
it("peft: multi-task speech bases only get the speech class for speech-to-text adapters", () => {
|
|
322
|
+
const adapter = (baseId: string, extra: Partial<ModelData> = {}) =>
|
|
323
|
+
peft({
|
|
324
|
+
...base,
|
|
325
|
+
...extra,
|
|
326
|
+
config: { peft: { base_model_name_or_path: baseId, task_type: "SEQ_2_SEQ_LM" } },
|
|
327
|
+
} as ModelData)[0];
|
|
328
|
+
|
|
329
|
+
// SeamlessM4T text translation adapters need the text-to-text head (e.g. maxbsdv/LEO-SeamlessM4T-v2-Large-Roverplastik)
|
|
330
|
+
expect(adapter("facebook/seamless-m4t-v2-large", { pipeline_tag: "translation" })).toContain(
|
|
331
|
+
"AutoModelForSeq2SeqLM",
|
|
332
|
+
);
|
|
333
|
+
expect(adapter("facebook/seamless-m4t-v2-large", { tags: ["translation"] })).toContain("AutoModelForSeq2SeqLM");
|
|
334
|
+
// speech adapters, tagged or not, keep the speech-to-text head
|
|
335
|
+
expect(adapter("facebook/seamless-m4t-v2-large", { tags: ["speech-translation"] })).toContain(
|
|
336
|
+
"AutoModelForSpeechSeq2Seq",
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
// SpeechT5 text-to-speech bases load the text-to-spectrogram head, not the speech-to-text one
|
|
340
|
+
// e.g. Solo448/SpeechT5-Unified-TTS-PEFT; PEFT's seq2seq wrapper cannot wrap it, so the task type is dropped
|
|
341
|
+
const tts = adapter("microsoft/speecht5_tts");
|
|
342
|
+
expect(tts).toContain(`AutoModelForTextToSpectrogram.from_pretrained("microsoft/speecht5_tts")`);
|
|
343
|
+
expect(tts).toContain("config.task_type = None");
|
|
344
|
+
expect(adapter("user/speecht5_finetuned_voxpopuli_nl")).toContain("AutoModelForTextToSpectrogram");
|
|
345
|
+
expect(adapter("user/speecht5_tts_basrah_dialect")).not.toContain("AutoModelForSpeechSeq2Seq");
|
|
346
|
+
expect(
|
|
347
|
+
adapter("user/speecht5_finetuned_librispeech", { pipeline_tag: "automatic-speech-recognition" }),
|
|
348
|
+
).toContain("AutoModelForSpeechSeq2Seq");
|
|
349
|
+
// the ASR task can also come from the tags alone
|
|
350
|
+
expect(adapter("user/speecht5_finetuned_librispeech", { tags: ["automatic-speech-recognition"] })).toContain(
|
|
351
|
+
"AutoModelForSpeechSeq2Seq",
|
|
352
|
+
);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it("peft: falls back to the model card's base model", () => {
|
|
356
|
+
const snippet = peft({
|
|
357
|
+
...base,
|
|
358
|
+
cardData: { base_model: "org/base" },
|
|
359
|
+
config: { peft: { task_type: "CAUSAL_LM" } },
|
|
360
|
+
} as ModelData)[0];
|
|
361
|
+
expect(snippet).toContain(`"org/base"`);
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it("ultralytics: mainline loads weights with YOLO(), the yolov10 fork keeps its own loader", () => {
|
|
365
|
+
expect(ultralytics(base as ModelData)[0]).toContain("model = YOLO(weights)");
|
|
366
|
+
expect(ultralytics({ ...base, tags: ["yolov10", "safetensors"] } as ModelData)[0]).toContain(
|
|
367
|
+
"YOLOv10.from_pretrained",
|
|
368
|
+
);
|
|
369
|
+
expect(
|
|
370
|
+
ultralytics({ ...base, library_name: "yolov10", tags: ["yolov10", "safetensors"] } as ModelData)[0],
|
|
371
|
+
).toContain("YOLOv10.from_pretrained");
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
it("ultralytics: yolov10 fork repos that only ship .pt weights load them with YOLOv10()", () => {
|
|
375
|
+
// e.g. kadirnar/Yolov10: from_pretrained needs the config.json and model.safetensors of a fork push
|
|
376
|
+
const [snippet] = ultralytics({ ...base, library_name: "yolov10", tags: ["yolov10"] } as ModelData);
|
|
377
|
+
expect(snippet).toContain("model = YOLOv10(weights)");
|
|
378
|
+
expect(snippet).not.toContain("from_pretrained");
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
it("ultralytics: mainline repos listing a yolov10 tag stay on the mainline loader", () => {
|
|
382
|
+
// e.g. Ultralytics/YOLOv8 is tagged yolov3 ... yolov10 but only ships .pt files for mainline YOLO()
|
|
383
|
+
const versionTags = ["ultralytics", "yolov8", "yolov9", "yolov10"];
|
|
384
|
+
for (const model of [
|
|
385
|
+
{ ...base, library_name: "ultralytics", tags: versionTags },
|
|
386
|
+
{ ...base, tags: versionTags },
|
|
387
|
+
]) {
|
|
388
|
+
const [snippet] = ultralytics(model as ModelData);
|
|
389
|
+
expect(snippet).toContain("model = YOLO(weights)");
|
|
390
|
+
expect(snippet).not.toContain("YOLOv10");
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
it("ultralytics: fork pushes tagged ultralytics keep the yolov10 loader", () => {
|
|
395
|
+
// e.g. kairess/baby-face-detection-yolov10: library ultralytics, but only the fork's model.safetensors
|
|
396
|
+
const [snippet] = ultralytics({
|
|
397
|
+
...base,
|
|
398
|
+
library_name: "ultralytics",
|
|
399
|
+
tags: ["ultralytics", "safetensors", "yolov10"],
|
|
400
|
+
} as ModelData);
|
|
401
|
+
expect(snippet).toContain("YOLOv10.from_pretrained");
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
it("pruna: the pro variant never rewrites the repo id", () => {
|
|
405
|
+
const snippet = pruna({ ...base, id: "pruna-test/model", tags: ["pruna_pro-ai"] } as ModelData).join("\n");
|
|
406
|
+
expect(snippet).toContain("from pruna_pro import PrunaProModel");
|
|
407
|
+
expect(snippet).toContain(`"pruna-test/model"`);
|
|
408
|
+
expect(snippet).not.toContain("pruna_pro-test");
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
it("sklearn: joblib repos use the filename declared in config.json", () => {
|
|
412
|
+
expect(sklearn({ ...base, config: { sklearn: { model: { file: "model.pkl" } } } } as ModelData)[0]).toContain(
|
|
413
|
+
`"model.pkl"`,
|
|
414
|
+
);
|
|
415
|
+
expect(sklearn(base as ModelData)[0]).toContain(`"sklearn_model.joblib"`);
|
|
416
|
+
// a declared name that is not a pickle (typo'd in e.g. danupurnomo/dummy-titanic) falls back to the default
|
|
417
|
+
expect(
|
|
418
|
+
sklearn({ ...base, config: { sklearn: { model: { file: "sklean_model.jpblib" } } } } as ModelData)[0],
|
|
419
|
+
).toContain(`"sklearn_model.joblib"`);
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it("sklearn: skops repos download with huggingface_hub", () => {
|
|
423
|
+
// skops.hub_utils was removed in skops 0.12
|
|
424
|
+
const skops = (sklearnConfig: Record<string, unknown>) =>
|
|
425
|
+
sklearn({ ...base, tags: ["skops"], config: { sklearn: sklearnConfig } } as ModelData)[0];
|
|
426
|
+
|
|
427
|
+
const skopsFile = skops({ model: { file: "model.skops" }, model_format: "skops" });
|
|
428
|
+
expect(skopsFile).toContain(`model = load(hf_hub_download("user/model", "model.skops"))`);
|
|
429
|
+
expect(skopsFile).not.toContain("hub_utils");
|
|
430
|
+
|
|
431
|
+
const pickled = skops({ model: { file: "model.pkl" }, model_format: "pickle" });
|
|
432
|
+
expect(pickled).toContain(`joblib.load(\n\thf_hub_download("user/model", "model.pkl")`);
|
|
433
|
+
expect(pickled).not.toContain("hub_utils");
|
|
434
|
+
|
|
435
|
+
// a pickled file without a declared model_format (e.g. julien-c/skops-digits) is not read with skops.io
|
|
436
|
+
const undeclared = skops({ model: { file: "sklearn_model.joblib" } });
|
|
437
|
+
expect(undeclared).toContain("joblib.load(");
|
|
438
|
+
expect(undeclared).not.toContain("skops.io");
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
it("speechbrain: speaker verification compares two recordings", () => {
|
|
442
|
+
const [snippet] = speechbrain({
|
|
443
|
+
...base,
|
|
444
|
+
config: { speechbrain: { speechbrain_interface: "SpeakerRecognition" } },
|
|
445
|
+
} as ModelData);
|
|
446
|
+
expect(snippet).toContain(`verify_files("speaker1.wav", "speaker2.wav")`);
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
it("repo ids are quoted in generated Python", () => {
|
|
450
|
+
const model = { ...base, id: "org/some-model" } as ModelData;
|
|
451
|
+
for (const snippetFn of [sam2, sam_3d_body, mlxim, indextts, describe_anything, diffusionkit, phantom_wan]) {
|
|
452
|
+
for (const snippet of snippetFn(model)) {
|
|
453
|
+
expect(snippet).not.toMatch(/[(=,]\s*org\/some-model/);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
it("mlx-image: create_model receives the registry name, not the repo id", () => {
|
|
459
|
+
const [snippet] = mlxim({ ...base, id: "mlx-vision/vit_small_patch16_224.dinov3-mlxim" } as ModelData);
|
|
460
|
+
expect(snippet).toContain(`create_model("vit_small_patch16_224.dinov3")`);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
it("litert-lm: the command runs as pasted, without a placeholder file argument", () => {
|
|
464
|
+
// litert-lm picks the repo's .litertlm file itself; an unedited `<file>` would be read by the shell as a redirection
|
|
465
|
+
const [snippet] = litert_lm(base as ModelData);
|
|
466
|
+
expect(snippet).toContain("--from-huggingface-repo=user/model \\\n");
|
|
467
|
+
expect(snippet.slice(snippet.indexOf("litert-lm run"))).not.toMatch(/[<>]/);
|
|
468
|
+
});
|
|
469
|
+
|
|
470
|
+
it("static templates no longer carry typos", () => {
|
|
471
|
+
expect(mlAgents(base as ModelData)[0]).toContain(`--local-dir="./downloads"`);
|
|
472
|
+
expect(timm(base as ModelData)[0]).toContain(`"hf-hub:user/model"`);
|
|
473
|
+
expect(kernels(base as ModelData)[0]).toContain(`get_kernel("user/model", version=1)`);
|
|
474
|
+
expect(gliner2(base as ModelData)[0]).toContain("extractor = AutoExtractor.from_pretrained");
|
|
475
|
+
expect(cartesia_pytorch(base as ModelData)[0].trimEnd()).toMatch(/print\(out_message\)$/);
|
|
476
|
+
expect(vui()[0]).toContain("from vui.legacy import Vui, render\n");
|
|
477
|
+
expect(phantom_wan(base as ModelData)[0]).toContain('Image.open("path/to/image.jpg")');
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
it("templates run as pasted", () => {
|
|
481
|
+
expect(sam2(base as ModelData)[1]).toContain("predictor.add_new_points(state, <your_prompts>)\n");
|
|
482
|
+
expect(depth_anything_v2(base as ModelData)[0]).toContain("model.load_state_dict(state_dict)\nmodel.eval()");
|
|
483
|
+
const [sam3dBody] = sam_3d_body(base as ModelData);
|
|
484
|
+
expect(sam3dBody).toContain("from tools.vis_utils import visualize_sample_together");
|
|
485
|
+
expect(sam3dBody).toContain('img_bgr = cv2.imread("path/to/image.jpg")');
|
|
486
|
+
expect(kimi_audio(base as ModelData)[0]).toContain(`"transformers<5"`);
|
|
487
|
+
const [cartesia] = cartesia_pytorch(base as ModelData);
|
|
488
|
+
expect(cartesia).toContain("from cartesia_pytorch.Rene import ReneLMHeadModel");
|
|
489
|
+
expect(cartesia).toContain(`.from_pretrained("user/model").half().cuda()`);
|
|
490
|
+
});
|
|
491
|
+
});
|
|
103
492
|
});
|