@huggingface/tasks 0.9.1 → 0.10.1

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.
Files changed (190) hide show
  1. package/README.md +12 -14
  2. package/dist/index.cjs +91 -18
  3. package/dist/index.js +90 -18
  4. package/dist/scripts/inference-codegen.d.ts +2 -0
  5. package/dist/scripts/inference-codegen.d.ts.map +1 -0
  6. package/dist/scripts/inference-tgi-import.d.ts +2 -0
  7. package/dist/scripts/inference-tgi-import.d.ts.map +1 -0
  8. package/dist/src/default-widget-inputs.d.ts +6 -0
  9. package/dist/src/default-widget-inputs.d.ts.map +1 -0
  10. package/dist/src/index.d.ts +17 -0
  11. package/dist/src/index.d.ts.map +1 -0
  12. package/dist/src/library-to-tasks.d.ts +11 -0
  13. package/dist/src/library-to-tasks.d.ts.map +1 -0
  14. package/dist/src/local-apps.d.ts +104 -0
  15. package/dist/src/local-apps.d.ts.map +1 -0
  16. package/dist/src/model-data.d.ts +144 -0
  17. package/dist/src/model-data.d.ts.map +1 -0
  18. package/dist/src/model-libraries-downloads.d.ts +26 -0
  19. package/dist/src/model-libraries-downloads.d.ts.map +1 -0
  20. package/dist/src/model-libraries-snippets.d.ts +43 -0
  21. package/dist/src/model-libraries-snippets.d.ts.map +1 -0
  22. package/dist/src/model-libraries.d.ts +501 -0
  23. package/dist/src/model-libraries.d.ts.map +1 -0
  24. package/dist/src/pipelines.d.ts +404 -0
  25. package/dist/src/pipelines.d.ts.map +1 -0
  26. package/dist/src/snippets/curl.d.ts +9 -0
  27. package/dist/src/snippets/curl.d.ts.map +1 -0
  28. package/dist/src/snippets/index.d.ts +6 -0
  29. package/dist/src/snippets/index.d.ts.map +1 -0
  30. package/dist/src/snippets/inputs.d.ts +3 -0
  31. package/dist/src/snippets/inputs.d.ts.map +1 -0
  32. package/dist/src/snippets/js.d.ts +11 -0
  33. package/dist/src/snippets/js.d.ts.map +1 -0
  34. package/dist/src/snippets/python.d.ts +14 -0
  35. package/dist/src/snippets/python.d.ts.map +1 -0
  36. package/dist/src/snippets/types.d.ts +8 -0
  37. package/dist/src/snippets/types.d.ts.map +1 -0
  38. package/dist/src/tasks/audio-classification/data.d.ts +4 -0
  39. package/dist/src/tasks/audio-classification/data.d.ts.map +1 -0
  40. package/dist/src/tasks/audio-classification/inference.d.ts +52 -0
  41. package/dist/src/tasks/audio-classification/inference.d.ts.map +1 -0
  42. package/dist/src/tasks/audio-to-audio/data.d.ts +4 -0
  43. package/dist/src/tasks/audio-to-audio/data.d.ts.map +1 -0
  44. package/dist/src/tasks/automatic-speech-recognition/data.d.ts +4 -0
  45. package/dist/src/tasks/automatic-speech-recognition/data.d.ts.map +1 -0
  46. package/dist/src/tasks/automatic-speech-recognition/inference.d.ts +154 -0
  47. package/dist/src/tasks/automatic-speech-recognition/inference.d.ts.map +1 -0
  48. package/dist/src/tasks/chat-completion/inference.d.ts +254 -0
  49. package/dist/src/tasks/chat-completion/inference.d.ts.map +1 -0
  50. package/dist/src/tasks/depth-estimation/data.d.ts +4 -0
  51. package/dist/src/tasks/depth-estimation/data.d.ts.map +1 -0
  52. package/dist/src/tasks/depth-estimation/inference.d.ts +36 -0
  53. package/dist/src/tasks/depth-estimation/inference.d.ts.map +1 -0
  54. package/dist/src/tasks/document-question-answering/data.d.ts +4 -0
  55. package/dist/src/tasks/document-question-answering/data.d.ts.map +1 -0
  56. package/dist/src/tasks/document-question-answering/inference.d.ts +111 -0
  57. package/dist/src/tasks/document-question-answering/inference.d.ts.map +1 -0
  58. package/dist/src/tasks/feature-extraction/data.d.ts +4 -0
  59. package/dist/src/tasks/feature-extraction/data.d.ts.map +1 -0
  60. package/dist/src/tasks/feature-extraction/inference.d.ts +23 -0
  61. package/dist/src/tasks/feature-extraction/inference.d.ts.map +1 -0
  62. package/dist/src/tasks/fill-mask/data.d.ts +4 -0
  63. package/dist/src/tasks/fill-mask/data.d.ts.map +1 -0
  64. package/dist/src/tasks/fill-mask/inference.d.ts +63 -0
  65. package/dist/src/tasks/fill-mask/inference.d.ts.map +1 -0
  66. package/dist/src/tasks/image-classification/data.d.ts +4 -0
  67. package/dist/src/tasks/image-classification/data.d.ts.map +1 -0
  68. package/dist/src/tasks/image-classification/inference.d.ts +52 -0
  69. package/dist/src/tasks/image-classification/inference.d.ts.map +1 -0
  70. package/dist/src/tasks/image-feature-extraction/data.d.ts +4 -0
  71. package/dist/src/tasks/image-feature-extraction/data.d.ts.map +1 -0
  72. package/dist/src/tasks/image-segmentation/data.d.ts +4 -0
  73. package/dist/src/tasks/image-segmentation/data.d.ts.map +1 -0
  74. package/dist/src/tasks/image-segmentation/inference.d.ts +66 -0
  75. package/dist/src/tasks/image-segmentation/inference.d.ts.map +1 -0
  76. package/dist/src/tasks/image-to-image/data.d.ts +4 -0
  77. package/dist/src/tasks/image-to-image/data.d.ts.map +1 -0
  78. package/dist/src/tasks/image-to-image/inference.d.ts +64 -0
  79. package/dist/src/tasks/image-to-image/inference.d.ts.map +1 -0
  80. package/dist/src/tasks/image-to-text/data.d.ts +4 -0
  81. package/dist/src/tasks/image-to-text/data.d.ts.map +1 -0
  82. package/dist/src/tasks/image-to-text/inference.d.ts +139 -0
  83. package/dist/src/tasks/image-to-text/inference.d.ts.map +1 -0
  84. package/dist/src/tasks/index.d.ts +87 -0
  85. package/dist/src/tasks/index.d.ts.map +1 -0
  86. package/dist/src/tasks/mask-generation/data.d.ts +4 -0
  87. package/dist/src/tasks/mask-generation/data.d.ts.map +1 -0
  88. package/dist/src/tasks/object-detection/data.d.ts +4 -0
  89. package/dist/src/tasks/object-detection/data.d.ts.map +1 -0
  90. package/dist/src/tasks/object-detection/inference.d.ts +63 -0
  91. package/dist/src/tasks/object-detection/inference.d.ts.map +1 -0
  92. package/dist/src/tasks/placeholder/data.d.ts +4 -0
  93. package/dist/src/tasks/placeholder/data.d.ts.map +1 -0
  94. package/dist/src/tasks/question-answering/data.d.ts +4 -0
  95. package/dist/src/tasks/question-answering/data.d.ts.map +1 -0
  96. package/dist/src/tasks/question-answering/inference.d.ts +100 -0
  97. package/dist/src/tasks/question-answering/inference.d.ts.map +1 -0
  98. package/dist/src/tasks/reinforcement-learning/data.d.ts +4 -0
  99. package/dist/src/tasks/reinforcement-learning/data.d.ts.map +1 -0
  100. package/dist/src/tasks/sentence-similarity/data.d.ts +4 -0
  101. package/dist/src/tasks/sentence-similarity/data.d.ts.map +1 -0
  102. package/dist/src/tasks/sentence-similarity/inference.d.ts +32 -0
  103. package/dist/src/tasks/sentence-similarity/inference.d.ts.map +1 -0
  104. package/dist/src/tasks/summarization/data.d.ts +4 -0
  105. package/dist/src/tasks/summarization/data.d.ts.map +1 -0
  106. package/dist/src/tasks/summarization/inference.d.ts +55 -0
  107. package/dist/src/tasks/summarization/inference.d.ts.map +1 -0
  108. package/dist/src/tasks/table-question-answering/data.d.ts +4 -0
  109. package/dist/src/tasks/table-question-answering/data.d.ts.map +1 -0
  110. package/dist/src/tasks/table-question-answering/inference.d.ts +62 -0
  111. package/dist/src/tasks/table-question-answering/inference.d.ts.map +1 -0
  112. package/dist/src/tasks/tabular-classification/data.d.ts +4 -0
  113. package/dist/src/tasks/tabular-classification/data.d.ts.map +1 -0
  114. package/dist/src/tasks/tabular-regression/data.d.ts +4 -0
  115. package/dist/src/tasks/tabular-regression/data.d.ts.map +1 -0
  116. package/dist/src/tasks/text-classification/data.d.ts +4 -0
  117. package/dist/src/tasks/text-classification/data.d.ts.map +1 -0
  118. package/dist/src/tasks/text-classification/inference.d.ts +52 -0
  119. package/dist/src/tasks/text-classification/inference.d.ts.map +1 -0
  120. package/dist/src/tasks/text-generation/data.d.ts +4 -0
  121. package/dist/src/tasks/text-generation/data.d.ts.map +1 -0
  122. package/dist/src/tasks/text-generation/inference.d.ts +126 -0
  123. package/dist/src/tasks/text-generation/inference.d.ts.map +1 -0
  124. package/dist/src/tasks/text-to-audio/inference.d.ts +139 -0
  125. package/dist/src/tasks/text-to-audio/inference.d.ts.map +1 -0
  126. package/dist/src/tasks/text-to-image/data.d.ts +4 -0
  127. package/dist/src/tasks/text-to-image/data.d.ts.map +1 -0
  128. package/dist/src/tasks/text-to-image/inference.d.ts +68 -0
  129. package/dist/src/tasks/text-to-image/inference.d.ts.map +1 -0
  130. package/dist/src/tasks/text-to-speech/data.d.ts +4 -0
  131. package/dist/src/tasks/text-to-speech/data.d.ts.map +1 -0
  132. package/dist/src/tasks/text-to-speech/inference.d.ts +143 -0
  133. package/dist/src/tasks/text-to-speech/inference.d.ts.map +1 -0
  134. package/dist/src/tasks/text-to-video/data.d.ts +4 -0
  135. package/dist/src/tasks/text-to-video/data.d.ts.map +1 -0
  136. package/dist/src/tasks/text2text-generation/inference.d.ts +54 -0
  137. package/dist/src/tasks/text2text-generation/inference.d.ts.map +1 -0
  138. package/dist/src/tasks/token-classification/data.d.ts +4 -0
  139. package/dist/src/tasks/token-classification/data.d.ts.map +1 -0
  140. package/dist/src/tasks/token-classification/inference.d.ts +83 -0
  141. package/dist/src/tasks/token-classification/inference.d.ts.map +1 -0
  142. package/dist/src/tasks/translation/data.d.ts +4 -0
  143. package/dist/src/tasks/translation/data.d.ts.map +1 -0
  144. package/dist/src/tasks/translation/inference.d.ts +55 -0
  145. package/dist/src/tasks/translation/inference.d.ts.map +1 -0
  146. package/dist/src/tasks/unconditional-image-generation/data.d.ts +4 -0
  147. package/dist/src/tasks/unconditional-image-generation/data.d.ts.map +1 -0
  148. package/dist/src/tasks/video-classification/data.d.ts +4 -0
  149. package/dist/src/tasks/video-classification/data.d.ts.map +1 -0
  150. package/dist/src/tasks/video-classification/inference.d.ts +60 -0
  151. package/dist/src/tasks/video-classification/inference.d.ts.map +1 -0
  152. package/dist/src/tasks/visual-question-answering/data.d.ts +4 -0
  153. package/dist/src/tasks/visual-question-answering/data.d.ts.map +1 -0
  154. package/dist/src/tasks/visual-question-answering/inference.d.ts +64 -0
  155. package/dist/src/tasks/visual-question-answering/inference.d.ts.map +1 -0
  156. package/dist/src/tasks/zero-shot-classification/data.d.ts +4 -0
  157. package/dist/src/tasks/zero-shot-classification/data.d.ts.map +1 -0
  158. package/dist/src/tasks/zero-shot-classification/inference.d.ts +68 -0
  159. package/dist/src/tasks/zero-shot-classification/inference.d.ts.map +1 -0
  160. package/dist/src/tasks/zero-shot-image-classification/data.d.ts +4 -0
  161. package/dist/src/tasks/zero-shot-image-classification/data.d.ts.map +1 -0
  162. package/dist/src/tasks/zero-shot-image-classification/inference.d.ts +62 -0
  163. package/dist/src/tasks/zero-shot-image-classification/inference.d.ts.map +1 -0
  164. package/dist/src/tasks/zero-shot-object-detection/data.d.ts +4 -0
  165. package/dist/src/tasks/zero-shot-object-detection/data.d.ts.map +1 -0
  166. package/dist/src/tasks/zero-shot-object-detection/inference.d.ts +67 -0
  167. package/dist/src/tasks/zero-shot-object-detection/inference.d.ts.map +1 -0
  168. package/dist/src/tokenizer-data.d.ts +26 -0
  169. package/dist/src/tokenizer-data.d.ts.map +1 -0
  170. package/dist/src/widget-example.d.ts +86 -0
  171. package/dist/src/widget-example.d.ts.map +1 -0
  172. package/package.json +8 -6
  173. package/src/index.ts +3 -0
  174. package/src/local-apps.ts +119 -0
  175. package/src/model-data.ts +1 -5
  176. package/src/model-libraries-snippets.ts +21 -18
  177. package/src/model-libraries.ts +9 -0
  178. package/src/tasks/chat-completion/inference.ts +204 -85
  179. package/src/tasks/chat-completion/spec/input.json +198 -34
  180. package/src/tasks/chat-completion/spec/output.json +178 -40
  181. package/src/tasks/chat-completion/spec/stream_output.json +170 -0
  182. package/src/tasks/index.ts +7 -8
  183. package/src/tasks/text-generation/inference.ts +58 -170
  184. package/src/tasks/text-generation/spec/input.json +130 -29
  185. package/src/tasks/text-generation/spec/output.json +104 -90
  186. package/src/tasks/text-generation/spec/stream_output.json +97 -0
  187. package/tsconfig.json +3 -1
  188. package/dist/index.d.ts +0 -3542
  189. package/src/tasks/chat-completion/spec/output_stream.json +0 -48
  190. package/src/tasks/text-generation/spec/output_stream.json +0 -47
@@ -0,0 +1,119 @@
1
+ import type { ModelData } from "./model-data";
2
+ import type { PipelineType } from "./pipelines";
3
+
4
+ /**
5
+ * Elements configurable by a local app.
6
+ */
7
+ export type LocalApp = {
8
+ /**
9
+ * Name that appears in buttons
10
+ */
11
+ prettyLabel: string;
12
+ /**
13
+ * Link to get more info about a local app (website etc)
14
+ */
15
+ docsUrl: string;
16
+ /**
17
+ * main category of app
18
+ */
19
+ mainTask: PipelineType;
20
+ /**
21
+ * Whether to display a pill "macOS-only"
22
+ */
23
+ macOSOnly?: boolean;
24
+
25
+ comingSoon?: boolean;
26
+ /**
27
+ * IMPORTANT: function to figure out whether to display the button on a model page's main "Use this model" dropdown.
28
+ */
29
+ displayOnModelPage: (model: ModelData) => boolean;
30
+ } & (
31
+ | {
32
+ /**
33
+ * If the app supports deeplink, URL to open.
34
+ */
35
+ deeplink: (model: ModelData) => URL;
36
+ }
37
+ | {
38
+ /**
39
+ * And if not (mostly llama.cpp), snippet to copy/paste in your terminal
40
+ */
41
+ snippet: (model: ModelData) => string;
42
+ }
43
+ );
44
+
45
+ function isGgufModel(model: ModelData) {
46
+ return model.tags.includes("gguf");
47
+ }
48
+
49
+ const snippetLlamacpp = (model: ModelData): string => {
50
+ return `./main \
51
+ --hf-repo ${model.id} \
52
+ -m file.gguf \
53
+ -p "I believe the meaning of life is " -n 128`;
54
+ };
55
+
56
+ /**
57
+ * Add your new local app here.
58
+ *
59
+ * This is open to new suggestions and awesome upcoming apps.
60
+ *
61
+ * /!\ IMPORTANT
62
+ *
63
+ * If possible, you need to support deeplinks and be as cross-platform as possible.
64
+ *
65
+ * Ping the HF team if we can help with anything!
66
+ */
67
+ export const LOCAL_APPS = {
68
+ "llama.cpp": {
69
+ prettyLabel: "llama.cpp",
70
+ docsUrl: "https://github.com/ggerganov/llama.cpp",
71
+ mainTask: "text-generation",
72
+ displayOnModelPage: isGgufModel,
73
+ snippet: snippetLlamacpp,
74
+ },
75
+ lmstudio: {
76
+ prettyLabel: "LM Studio",
77
+ docsUrl: "https://lmstudio.ai",
78
+ mainTask: "text-generation",
79
+ displayOnModelPage: isGgufModel,
80
+ deeplink: (model) => new URL(`lmstudio://open_from_hf?model=${model.id}`),
81
+ },
82
+ jan: {
83
+ prettyLabel: "Jan",
84
+ docsUrl: "https://jan.ai",
85
+ mainTask: "text-generation",
86
+ displayOnModelPage: isGgufModel,
87
+ deeplink: (model) => new URL(`jan://open_from_hf?model=${model.id}`),
88
+ },
89
+ faraday: {
90
+ prettyLabel: "Faraday",
91
+ docsUrl: "https://faraday.dev",
92
+ mainTask: "text-generation",
93
+ macOSOnly: true,
94
+ displayOnModelPage: isGgufModel,
95
+ deeplink: (model) => new URL(`faraday://open_from_hf?model=${model.id}`),
96
+ },
97
+ drawthings: {
98
+ prettyLabel: "Draw Things",
99
+ docsUrl: "https://drawthings.ai",
100
+ mainTask: "text-to-image",
101
+ macOSOnly: true,
102
+ /**
103
+ * random function, will need to refine the actual conditions:
104
+ */
105
+ displayOnModelPage: (model) => model.tags.includes("textual_inversion"),
106
+ deeplink: (model) => new URL(`drawthings://open_from_hf?model=${model.id}`),
107
+ },
108
+ diffusionbee: {
109
+ prettyLabel: "DiffusionBee",
110
+ docsUrl: "https://diffusionbee.com",
111
+ mainTask: "text-to-image",
112
+ macOSOnly: true,
113
+ comingSoon: true,
114
+ displayOnModelPage: (model) => model.library_name === "diffusers" && model.pipeline_tag === "text-to-image",
115
+ deeplink: (model) => new URL(`diffusionbee://open_from_hf?model=${model.id}`),
116
+ },
117
+ } satisfies Record<string, LocalApp>;
118
+
119
+ export type LocalAppKey = keyof typeof LOCAL_APPS;
package/src/model-data.ts CHANGED
@@ -25,10 +25,6 @@ export interface ModelData {
25
25
  * id of model (e.g. 'user/repo_name')
26
26
  */
27
27
  id: string;
28
- /**
29
- * Kept for backward compatibility
30
- */
31
- modelId?: string;
32
28
  /**
33
29
  * Whether or not to enable inference widget for this model
34
30
  */
@@ -84,7 +80,7 @@ export interface ModelData {
84
80
  /**
85
81
  * all the model tags
86
82
  */
87
- tags?: string[];
83
+ tags: string[];
88
84
  /**
89
85
  * transformers-specific info to display in the code sample.
90
86
  */
@@ -33,7 +33,7 @@ predictions = predictor.predict_json(predictor_input)`,
33
33
  ];
34
34
 
35
35
  export const allennlp = (model: ModelData): string[] => {
36
- if (model.tags?.includes("question-answering")) {
36
+ if (model.tags.includes("question-answering")) {
37
37
  return allennlpQuestionAnswering(model);
38
38
  }
39
39
  return allennlpUnknown(model);
@@ -85,11 +85,11 @@ pipeline.load_textual_inversion("${model.id}")`,
85
85
  ];
86
86
 
87
87
  export const diffusers = (model: ModelData): string[] => {
88
- if (model.tags?.includes("controlnet")) {
88
+ if (model.tags.includes("controlnet")) {
89
89
  return diffusers_controlnet(model);
90
- } else if (model.tags?.includes("lora")) {
90
+ } else if (model.tags.includes("lora")) {
91
91
  return diffusers_lora(model);
92
- } else if (model.tags?.includes("textual_inversion")) {
92
+ } else if (model.tags.includes("textual_inversion")) {
93
93
  return diffusers_textual_inversion(model);
94
94
  } else {
95
95
  return diffusers_default(model);
@@ -118,9 +118,9 @@ text, *_ = model(speech)[0]`,
118
118
  const espnetUnknown = () => [`unknown model type (must be text-to-speech or automatic-speech-recognition)`];
119
119
 
120
120
  export const espnet = (model: ModelData): string[] => {
121
- if (model.tags?.includes("text-to-speech")) {
121
+ if (model.tags.includes("text-to-speech")) {
122
122
  return espnetTTS(model);
123
- } else if (model.tags?.includes("automatic-speech-recognition")) {
123
+ } else if (model.tags.includes("automatic-speech-recognition")) {
124
124
  return espnetASR(model);
125
125
  }
126
126
  return espnetUnknown();
@@ -154,7 +154,10 @@ model = from_pretrained_keras("${model.id}")
154
154
  ];
155
155
 
156
156
  export const keras_nlp = (model: ModelData): string[] => [
157
- `import keras_nlp
157
+ `# Available backend options are: "jax", "tensorflow", "torch".
158
+ os.environ["KERAS_BACKEND"] = "tensorflow"
159
+
160
+ import keras_nlp
158
161
 
159
162
  tokenizer = keras_nlp.models.Tokenizer.from_preset("hf://${model.id}")
160
163
  backbone = keras_nlp.models.Backbone.from_preset("hf://${model.id}")
@@ -225,7 +228,7 @@ inference.crop("file.wav", excerpt)`,
225
228
  ];
226
229
 
227
230
  export const pyannote_audio = (model: ModelData): string[] => {
228
- if (model.tags?.includes("pyannote-audio-pipeline")) {
231
+ if (model.tags.includes("pyannote-audio-pipeline")) {
229
232
  return pyannote_audio_pipeline(model);
230
233
  }
231
234
  return pyannote_audio_model(model);
@@ -255,9 +258,9 @@ model = TFAutoModel.from_pretrained("${model.id}")
255
258
  ];
256
259
 
257
260
  export const tensorflowtts = (model: ModelData): string[] => {
258
- if (model.tags?.includes("text-to-mel")) {
261
+ if (model.tags.includes("text-to-mel")) {
259
262
  return tensorflowttsTextToMel(model);
260
- } else if (model.tags?.includes("mel-to-wav")) {
263
+ } else if (model.tags.includes("mel-to-wav")) {
261
264
  return tensorflowttsMelToWav(model);
262
265
  }
263
266
  return tensorflowttsUnknown(model);
@@ -306,7 +309,7 @@ model = joblib.load(
306
309
  };
307
310
 
308
311
  export const sklearn = (model: ModelData): string[] => {
309
- if (model.tags?.includes("skops")) {
312
+ if (model.tags.includes("skops")) {
310
313
  const skopsmodelFile = model.config?.sklearn?.model?.file;
311
314
  const skopssaveFormat = model.config?.sklearn?.model_format;
312
315
  if (!skopsmodelFile) {
@@ -410,7 +413,7 @@ export const transformers = (model: ModelData): string[] => {
410
413
  if (!info) {
411
414
  return [`# ⚠️ Type of model unknown`];
412
415
  }
413
- const remote_code_snippet = model.tags?.includes(TAG_CUSTOM_CODE) ? ", trust_remote_code=True" : "";
416
+ const remote_code_snippet = model.tags.includes(TAG_CUSTOM_CODE) ? ", trust_remote_code=True" : "";
414
417
 
415
418
  let autoSnippet: string;
416
419
  if (info.processor) {
@@ -493,8 +496,8 @@ export const peft = (model: ModelData): string[] => {
493
496
  from transformers import AutoModelFor${pefttask}
494
497
 
495
498
  config = PeftConfig.from_pretrained("${model.id}")
496
- model = AutoModelFor${pefttask}.from_pretrained("${peftBaseModel}")
497
- model = PeftModel.from_pretrained(model, "${model.id}")`,
499
+ base_model = AutoModelFor${pefttask}.from_pretrained("${peftBaseModel}")
500
+ model = PeftModel.from_pretrained(base_model, "${model.id}")`,
498
501
  ];
499
502
  };
500
503
 
@@ -561,7 +564,7 @@ model = create_model(${model.id})`,
561
564
  export const nemo = (model: ModelData): string[] => {
562
565
  let command: string[] | undefined = undefined;
563
566
  // Resolve the tag to a nemo domain/sub-domain
564
- if (model.tags?.includes("automatic-speech-recognition")) {
567
+ if (model.tags.includes("automatic-speech-recognition")) {
565
568
  command = nemoDomainResolver("ASR", model);
566
569
  }
567
570
 
@@ -602,11 +605,11 @@ wav = model.generate(descriptions) # generates 3 samples.`,
602
605
  ];
603
606
 
604
607
  export const audiocraft = (model: ModelData): string[] => {
605
- if (model.tags?.includes("musicgen")) {
608
+ if (model.tags.includes("musicgen")) {
606
609
  return musicgen(model);
607
- } else if (model.tags?.includes("audiogen")) {
610
+ } else if (model.tags.includes("audiogen")) {
608
611
  return audiogen(model);
609
- } else if (model.tags?.includes("magnet")) {
612
+ } else if (model.tags.includes("magnet")) {
610
613
  return magnet(model);
611
614
  } else {
612
615
  return [`# Type of model unknown.`];
@@ -380,6 +380,15 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
380
380
  repoUrl: "https://github.com/TensorSpeech/TensorFlowTTS",
381
381
  snippets: snippets.tensorflowtts,
382
382
  },
383
+ timesfm: {
384
+ prettyLabel: "TimesFM",
385
+ repoName: "timesfm",
386
+ repoUrl: "https://github.com/google-research/timesfm",
387
+ filter: false,
388
+ countDownloads: {
389
+ term: { path: "checkpoints/checkpoint_1100000/state/checkpoint" },
390
+ },
391
+ },
383
392
  timm: {
384
393
  prettyLabel: "timm",
385
394
  repoName: "pytorch-image-models",
@@ -5,154 +5,273 @@
5
5
  */
6
6
 
7
7
  /**
8
- * Inputs for ChatCompletion inference
8
+ * Chat Completion Input.
9
+ *
10
+ * Auto-generated from TGI specs.
11
+ * For more details, check out
12
+ * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
9
13
  */
10
14
  export interface ChatCompletionInput {
11
15
  /**
12
16
  * Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing
13
- * frequency in the text so far, decreasing the model's likelihood to repeat the same line
14
- * verbatim.
17
+ * frequency in the text so far,
18
+ * decreasing the model's likelihood to repeat the same line verbatim.
15
19
  */
16
20
  frequency_penalty?: number;
21
+ /**
22
+ * UNUSED
23
+ * Modify the likelihood of specified tokens appearing in the completion. Accepts a JSON
24
+ * object that maps tokens
25
+ * (specified by their token ID in the tokenizer) to an associated bias value from -100 to
26
+ * 100. Mathematically,
27
+ * the bias is added to the logits generated by the model prior to sampling. The exact
28
+ * effect will vary per model,
29
+ * but values between -1 and 1 should decrease or increase likelihood of selection; values
30
+ * like -100 or 100 should
31
+ * result in a ban or exclusive selection of the relevant token.
32
+ */
33
+ logit_bias?: number[];
34
+ /**
35
+ * Whether to return log probabilities of the output tokens or not. If true, returns the log
36
+ * probabilities of each
37
+ * output token returned in the content of message.
38
+ */
39
+ logprobs?: boolean;
17
40
  /**
18
41
  * The maximum number of tokens that can be generated in the chat completion.
19
42
  */
20
43
  max_tokens?: number;
44
+ /**
45
+ * A list of messages comprising the conversation so far.
46
+ */
21
47
  messages: ChatCompletionInputMessage[];
22
48
  /**
23
- * The random sampling seed.
49
+ * [UNUSED] ID of the model to use. See the model endpoint compatibility table for details
50
+ * on which models work with the Chat API.
24
51
  */
25
- seed?: number;
52
+ model: string;
53
+ /**
54
+ * UNUSED
55
+ * How many chat completion choices to generate for each input message. Note that you will
56
+ * be charged based on the
57
+ * number of generated tokens across all of the choices. Keep n as 1 to minimize costs.
58
+ */
59
+ n?: number;
26
60
  /**
27
- * Stop generating tokens if a stop token is generated.
61
+ * Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they
62
+ * appear in the text so far,
63
+ * increasing the model's likelihood to talk about new topics
28
64
  */
29
- stop?: ChatCompletionInputStopReason;
65
+ presence_penalty?: number;
66
+ seed?: number;
30
67
  /**
31
- * If set, partial message deltas will be sent.
68
+ * Up to 4 sequences where the API will stop generating further tokens.
32
69
  */
70
+ stop?: string[];
33
71
  stream?: boolean;
34
72
  /**
35
- * The value used to modulate the logits distribution.
73
+ * What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the
74
+ * output more random, while
75
+ * lower values like 0.2 will make it more focused and deterministic.
76
+ *
77
+ * We generally recommend altering this or `top_p` but not both.
36
78
  */
37
79
  temperature?: number;
80
+ tool_choice?: ChatCompletionInputToolType;
81
+ /**
82
+ * A prompt to be appended before the tools
83
+ */
84
+ tool_prompt?: string;
38
85
  /**
39
- * If set to < 1, only the smallest set of most probable tokens with probabilities that add
40
- * up to `top_p` or higher are kept for generation.
86
+ * A list of tools the model may call. Currently, only functions are supported as a tool.
87
+ * Use this to provide a list of
88
+ * functions the model may generate JSON inputs for.
89
+ */
90
+ tools?: ChatCompletionInputTool[];
91
+ /**
92
+ * An integer between 0 and 5 specifying the number of most likely tokens to return at each
93
+ * token position, each with
94
+ * an associated log probability. logprobs must be set to true if this parameter is used.
95
+ */
96
+ top_logprobs?: number;
97
+ /**
98
+ * An alternative to sampling with temperature, called nucleus sampling, where the model
99
+ * considers the results of the
100
+ * tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10%
101
+ * probability mass are considered.
41
102
  */
42
103
  top_p?: number;
43
104
  [property: string]: unknown;
44
105
  }
45
106
 
46
107
  export interface ChatCompletionInputMessage {
47
- /**
48
- * The content of the message.
49
- */
50
- content: string;
51
- role: ChatCompletionMessageRole;
108
+ content?: string;
109
+ name?: string;
110
+ role: string;
111
+ tool_calls?: ChatCompletionInputToolCall[];
52
112
  [property: string]: unknown;
53
113
  }
54
114
 
55
- /**
56
- * The role of the message author.
57
- */
58
- export type ChatCompletionMessageRole = "assistant" | "system" | "user";
115
+ export interface ChatCompletionInputToolCall {
116
+ function: ChatCompletionInputFunctionDefinition;
117
+ id: number;
118
+ type: string;
119
+ [property: string]: unknown;
120
+ }
59
121
 
60
- /**
61
- * Stop generating tokens if a stop token is generated.
62
- */
63
- export type ChatCompletionInputStopReason = string[] | string;
122
+ export interface ChatCompletionInputFunctionDefinition {
123
+ arguments: unknown;
124
+ description?: string;
125
+ name: string;
126
+ [property: string]: unknown;
127
+ }
128
+
129
+ export type ChatCompletionInputToolType = "OneOf" | ChatCompletionInputToolTypeObject;
130
+
131
+ export interface ChatCompletionInputToolTypeObject {
132
+ FunctionName: string;
133
+ [property: string]: unknown;
134
+ }
135
+
136
+ export interface ChatCompletionInputTool {
137
+ function: ChatCompletionInputFunctionDefinition;
138
+ type: string;
139
+ [property: string]: unknown;
140
+ }
64
141
 
65
142
  /**
66
- * Outputs for Chat Completion inference
143
+ * Chat Completion Output.
144
+ *
145
+ * Auto-generated from TGI specs.
146
+ * For more details, check out
147
+ * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
67
148
  */
68
149
  export interface ChatCompletionOutput {
69
- /**
70
- * A list of chat completion choices.
71
- */
72
- choices: ChatCompletionOutputChoice[];
73
- /**
74
- * The Unix timestamp (in seconds) of when the chat completion was created.
75
- */
150
+ choices: ChatCompletionOutputComplete[];
76
151
  created: number;
152
+ id: string;
153
+ model: string;
154
+ object: string;
155
+ system_fingerprint: string;
156
+ usage: ChatCompletionOutputUsage;
77
157
  [property: string]: unknown;
78
158
  }
79
159
 
80
- export interface ChatCompletionOutputChoice {
81
- /**
82
- * The reason why the generation was stopped.
83
- */
84
- finish_reason: ChatCompletionFinishReason;
85
- /**
86
- * The index of the choice in the list of choices.
87
- */
160
+ export interface ChatCompletionOutputComplete {
161
+ finish_reason: string;
88
162
  index: number;
89
- message: ChatCompletionOutputChoiceMessage;
163
+ logprobs?: ChatCompletionOutputLogprobs;
164
+ message: ChatCompletionOutputMessage;
90
165
  [property: string]: unknown;
91
166
  }
92
167
 
93
- /**
94
- * The reason why the generation was stopped.
95
- *
96
- * The generated sequence reached the maximum allowed length
97
- *
98
- * The model generated an end-of-sentence (EOS) token
99
- *
100
- * One of the sequence in stop_sequences was generated
101
- */
102
- export type ChatCompletionFinishReason = "length" | "eos_token" | "stop_sequence";
168
+ export interface ChatCompletionOutputLogprobs {
169
+ content: ChatCompletionOutputLogprob[];
170
+ [property: string]: unknown;
171
+ }
103
172
 
104
- export interface ChatCompletionOutputChoiceMessage {
105
- /**
106
- * The content of the chat completion message.
107
- */
108
- content: string;
109
- role: ChatCompletionMessageRole;
173
+ export interface ChatCompletionOutputLogprob {
174
+ logprob: number;
175
+ token: string;
176
+ top_logprobs: ChatCompletionOutputTopLogprob[];
177
+ [property: string]: unknown;
178
+ }
179
+
180
+ export interface ChatCompletionOutputTopLogprob {
181
+ logprob: number;
182
+ token: string;
183
+ [property: string]: unknown;
184
+ }
185
+
186
+ export interface ChatCompletionOutputMessage {
187
+ content?: string;
188
+ name?: string;
189
+ role: string;
190
+ tool_calls?: ChatCompletionOutputToolCall[];
191
+ [property: string]: unknown;
192
+ }
193
+
194
+ export interface ChatCompletionOutputToolCall {
195
+ function: ChatCompletionOutputFunctionDefinition;
196
+ id: number;
197
+ type: string;
198
+ [property: string]: unknown;
199
+ }
200
+
201
+ export interface ChatCompletionOutputFunctionDefinition {
202
+ arguments: unknown;
203
+ description?: string;
204
+ name: string;
205
+ [property: string]: unknown;
206
+ }
207
+
208
+ export interface ChatCompletionOutputUsage {
209
+ completion_tokens: number;
210
+ prompt_tokens: number;
211
+ total_tokens: number;
110
212
  [property: string]: unknown;
111
213
  }
112
214
 
113
215
  /**
114
- * Chat Completion Stream Output
216
+ * Chat Completion Stream Output.
217
+ *
218
+ * Auto-generated from TGI specs.
219
+ * For more details, check out
220
+ * https://github.com/huggingface/huggingface.js/blob/main/packages/tasks/scripts/inference-tgi-import.ts.
115
221
  */
116
222
  export interface ChatCompletionStreamOutput {
117
- /**
118
- * A list of chat completion choices.
119
- */
120
223
  choices: ChatCompletionStreamOutputChoice[];
121
- /**
122
- * The Unix timestamp (in seconds) of when the chat completion was created. Each chunk has
123
- * the same timestamp.
124
- */
125
224
  created: number;
225
+ id: string;
226
+ model: string;
227
+ object: string;
228
+ system_fingerprint: string;
126
229
  [property: string]: unknown;
127
230
  }
128
231
 
129
232
  export interface ChatCompletionStreamOutputChoice {
130
- /**
131
- * A chat completion delta generated by streamed model responses.
132
- */
133
233
  delta: ChatCompletionStreamOutputDelta;
134
- /**
135
- * The reason why the generation was stopped.
136
- */
137
- finish_reason?: ChatCompletionFinishReason;
138
- /**
139
- * The index of the choice in the list of choices.
140
- */
234
+ finish_reason?: string;
141
235
  index: number;
236
+ logprobs?: ChatCompletionStreamOutputLogprobs;
142
237
  [property: string]: unknown;
143
238
  }
144
239
 
145
- /**
146
- * A chat completion delta generated by streamed model responses.
147
- */
148
240
  export interface ChatCompletionStreamOutputDelta {
149
- /**
150
- * The contents of the chunk message.
151
- */
152
241
  content?: string;
153
- /**
154
- * The role of the author of this message.
155
- */
156
- role?: string;
242
+ role: string;
243
+ tool_calls?: ChatCompletionStreamOutputDeltaToolCall;
244
+ [property: string]: unknown;
245
+ }
246
+
247
+ export interface ChatCompletionStreamOutputDeltaToolCall {
248
+ function: ChatCompletionStreamOutputFunction;
249
+ id: string;
250
+ index: number;
251
+ type: string;
252
+ [property: string]: unknown;
253
+ }
254
+
255
+ export interface ChatCompletionStreamOutputFunction {
256
+ arguments: string;
257
+ name?: string;
258
+ [property: string]: unknown;
259
+ }
260
+
261
+ export interface ChatCompletionStreamOutputLogprobs {
262
+ content: ChatCompletionStreamOutputLogprob[];
263
+ [property: string]: unknown;
264
+ }
265
+
266
+ export interface ChatCompletionStreamOutputLogprob {
267
+ logprob: number;
268
+ token: string;
269
+ top_logprobs: ChatCompletionStreamOutputTopLogprob[];
270
+ [property: string]: unknown;
271
+ }
272
+
273
+ export interface ChatCompletionStreamOutputTopLogprob {
274
+ logprob: number;
275
+ token: string;
157
276
  [property: string]: unknown;
158
277
  }