1
1
import * as snippets from "./model-libraries-snippets" ;
2
2
import type { ModelData } from "./model-data" ;
3
+ import type { ElasticBoolQueryFilter } from "./model-libraries-downloads" ;
3
4
4
5
/**
5
6
* Elements configurable by a model library.
@@ -27,6 +28,13 @@ export interface LibraryUiElement {
27
28
* Code snippet(s) displayed on model page
28
29
*/
29
30
snippets ?: ( model : ModelData ) => string [ ] ;
31
+ /**
32
+ * Elastic query used to count this library's model downloads
33
+ *
34
+ * By default, those files are counted:
35
+ * "config.json", "config.yaml", "hyperparams.yaml", "meta.yaml"
36
+ */
37
+ countDownloads ?: ElasticBoolQueryFilter ;
30
38
/**
31
39
* should we display this library in hf.co/models filter
32
40
* (only for popular libraries with > 100 models)
@@ -57,6 +65,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
57
65
docsUrl : "https://huggingface.co/docs/hub/adapters" ,
58
66
snippets : snippets . adapters ,
59
67
filter : true ,
68
+ countDownloads : {
69
+ term : { path : "adapter_config.json" } ,
70
+ } ,
60
71
} ,
61
72
allennlp : {
62
73
prettyLabel : "AllenNLP" ,
@@ -73,6 +84,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
73
84
docsUrl : "https://huggingface.co/docs/hub/asteroid" ,
74
85
snippets : snippets . asteroid ,
75
86
filter : true ,
87
+ countDownloads : {
88
+ term : { path : "pytorch_model.bin" } ,
89
+ } ,
76
90
} ,
77
91
bertopic : {
78
92
prettyLabel : "BERTopic" ,
@@ -88,6 +102,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
88
102
docsUrl : "https://huggingface.co/docs/hub/diffusers" ,
89
103
snippets : snippets . diffusers ,
90
104
filter : true ,
105
+ /// diffusers has its own more complex "countDownloads" query
91
106
} ,
92
107
doctr : {
93
108
prettyLabel : "docTR" ,
@@ -131,6 +146,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
131
146
docsUrl : "https://huggingface.co/docs/hub/flair" ,
132
147
snippets : snippets . flair ,
133
148
filter : true ,
149
+ countDownloads : {
150
+ term : { path : "pytorch_model.bin" } ,
151
+ } ,
134
152
} ,
135
153
keras : {
136
154
prettyLabel : "Keras" ,
@@ -139,6 +157,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
139
157
docsUrl : "https://huggingface.co/docs/hub/keras" ,
140
158
snippets : snippets . keras ,
141
159
filter : true ,
160
+ countDownloads : { term : { path : "saved_model.pb" } } ,
142
161
} ,
143
162
k2 : {
144
163
prettyLabel : "K2" ,
@@ -157,6 +176,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
157
176
docsUrl : "https://huggingface.co/docs/hub/ml-agents" ,
158
177
snippets : snippets . mlAgents ,
159
178
filter : true ,
179
+ countDownloads : { wildcard : { path : "*.onnx" } } ,
160
180
} ,
161
181
mlx : {
162
182
prettyLabel : "MLX" ,
@@ -171,13 +191,15 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
171
191
repoUrl : "https://github.com/NVIDIA/NeMo" ,
172
192
snippets : snippets . nemo ,
173
193
filter : true ,
194
+ countDownloads : { wildcard : { path : "*.nemo" } } ,
174
195
} ,
175
196
open_clip : {
176
197
prettyLabel : "OpenCLIP" ,
177
198
repoName : "OpenCLIP" ,
178
199
repoUrl : "https://github.com/mlfoundations/open_clip" ,
179
200
snippets : snippets . open_clip ,
180
201
filter : true ,
202
+ countDownloads : { wildcard : { path : "*pytorch_model.bin" } } ,
181
203
} ,
182
204
paddlenlp : {
183
205
prettyLabel : "paddlenlp" ,
@@ -186,13 +208,19 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
186
208
docsUrl : "https://huggingface.co/docs/hub/paddlenlp" ,
187
209
snippets : snippets . paddlenlp ,
188
210
filter : true ,
211
+ countDownloads : {
212
+ term : { path : "model_config.json" } ,
213
+ } ,
189
214
} ,
190
215
peft : {
191
216
prettyLabel : "PEFT" ,
192
217
repoName : "PEFT" ,
193
218
repoUrl : "https://github.com/huggingface/peft" ,
194
219
snippets : snippets . peft ,
195
220
filter : true ,
221
+ countDownloads : {
222
+ term : { path : "adapter_config.json" } ,
223
+ } ,
196
224
} ,
197
225
"pyannote-audio" : {
198
226
prettyLabel : "pyannote.audio" ,
@@ -215,6 +243,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
215
243
docsUrl : "https://huggingface.co/docs/hub/sample-factory" ,
216
244
snippets : snippets . sampleFactory ,
217
245
filter : true ,
246
+ countDownloads : { term : { path : "cfg.json" } } ,
218
247
} ,
219
248
"sentence-transformers" : {
220
249
prettyLabel : "sentence-transformers" ,
@@ -238,6 +267,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
238
267
repoUrl : "https://github.com/scikit-learn/scikit-learn" ,
239
268
snippets : snippets . sklearn ,
240
269
filter : true ,
270
+ countDownloads : {
271
+ term : { path : "sklearn_model.joblib" } ,
272
+ } ,
241
273
} ,
242
274
spacy : {
243
275
prettyLabel : "spaCy" ,
@@ -246,6 +278,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
246
278
docsUrl : "https://huggingface.co/docs/hub/spacy" ,
247
279
snippets : snippets . spacy ,
248
280
filter : true ,
281
+ countDownloads : {
282
+ wildcard : { path : "*.whl" } ,
283
+ } ,
249
284
} ,
250
285
"span-marker" : {
251
286
prettyLabel : "SpanMarker" ,
@@ -262,6 +297,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
262
297
docsUrl : "https://huggingface.co/docs/hub/speechbrain" ,
263
298
snippets : snippets . speechbrain ,
264
299
filter : true ,
300
+ countDownloads : {
301
+ term : { path : "hyperparams.yaml" } ,
302
+ } ,
265
303
} ,
266
304
"stable-baselines3" : {
267
305
prettyLabel : "stable-baselines3" ,
@@ -270,6 +308,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
270
308
docsUrl : "https://huggingface.co/docs/hub/stable-baselines3" ,
271
309
snippets : snippets . stableBaselines3 ,
272
310
filter : true ,
311
+ countDownloads : {
312
+ wildcard : { path : "*.zip" } ,
313
+ } ,
273
314
} ,
274
315
stanza : {
275
316
prettyLabel : "Stanza" ,
@@ -278,6 +319,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
278
319
docsUrl : "https://huggingface.co/docs/hub/stanza" ,
279
320
snippets : snippets . stanza ,
280
321
filter : true ,
322
+ countDownloads : {
323
+ term : { path : "models/default.zip" } ,
324
+ } ,
281
325
} ,
282
326
tensorflowtts : {
283
327
prettyLabel : "TensorFlowTTS" ,
@@ -292,6 +336,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
292
336
docsUrl : "https://huggingface.co/docs/hub/timm" ,
293
337
snippets : snippets . timm ,
294
338
filter : true ,
339
+ countDownloads : {
340
+ terms : { path : [ "pytorch_model.bin" , "model.safetensors" ] } ,
341
+ } ,
295
342
} ,
296
343
transformers : {
297
344
prettyLabel : "Transformers" ,
@@ -315,6 +362,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
315
362
repoUrl : "https://github.com/Unity-Technologies/sentis-samples" ,
316
363
snippets : snippets . sentis ,
317
364
filter : true ,
365
+ countDownloads : {
366
+ wildcard : { path : "*.sentis" } ,
367
+ } ,
318
368
} ,
319
369
} satisfies Record < string , LibraryUiElement > ;
320
370
0 commit comments