11import * as snippets from "./model-libraries-snippets" ;
22import type { ModelData } from "./model-data" ;
3+ import type { ElasticBoolQueryFilter } from "./model-libraries-downloads" ;
34
45/**
56 * Elements configurable by a model library.
@@ -27,6 +28,13 @@ export interface LibraryUiElement {
2728 * Code snippet(s) displayed on model page
2829 */
2930 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 ;
3038 /**
3139 * should we display this library in hf.co/models filter
3240 * (only for popular libraries with > 100 models)
@@ -57,6 +65,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
5765 docsUrl : "https://huggingface.co/docs/hub/adapters" ,
5866 snippets : snippets . adapters ,
5967 filter : true ,
68+ countDownloads : {
69+ term : { path : "adapter_config.json" } ,
70+ } ,
6071 } ,
6172 allennlp : {
6273 prettyLabel : "AllenNLP" ,
@@ -73,6 +84,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
7384 docsUrl : "https://huggingface.co/docs/hub/asteroid" ,
7485 snippets : snippets . asteroid ,
7586 filter : true ,
87+ countDownloads : {
88+ term : { path : "pytorch_model.bin" } ,
89+ } ,
7690 } ,
7791 bertopic : {
7892 prettyLabel : "BERTopic" ,
@@ -88,6 +102,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
88102 docsUrl : "https://huggingface.co/docs/hub/diffusers" ,
89103 snippets : snippets . diffusers ,
90104 filter : true ,
105+ /// diffusers has its own more complex "countDownloads" query
91106 } ,
92107 doctr : {
93108 prettyLabel : "docTR" ,
@@ -131,6 +146,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
131146 docsUrl : "https://huggingface.co/docs/hub/flair" ,
132147 snippets : snippets . flair ,
133148 filter : true ,
149+ countDownloads : {
150+ term : { path : "pytorch_model.bin" } ,
151+ } ,
134152 } ,
135153 keras : {
136154 prettyLabel : "Keras" ,
@@ -139,6 +157,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
139157 docsUrl : "https://huggingface.co/docs/hub/keras" ,
140158 snippets : snippets . keras ,
141159 filter : true ,
160+ countDownloads : { term : { path : "saved_model.pb" } } ,
142161 } ,
143162 k2 : {
144163 prettyLabel : "K2" ,
@@ -157,6 +176,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
157176 docsUrl : "https://huggingface.co/docs/hub/ml-agents" ,
158177 snippets : snippets . mlAgents ,
159178 filter : true ,
179+ countDownloads : { wildcard : { path : "*.onnx" } } ,
160180 } ,
161181 mlx : {
162182 prettyLabel : "MLX" ,
@@ -171,13 +191,15 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
171191 repoUrl : "https://github.com/NVIDIA/NeMo" ,
172192 snippets : snippets . nemo ,
173193 filter : true ,
194+ countDownloads : { wildcard : { path : "*.nemo" } } ,
174195 } ,
175196 open_clip : {
176197 prettyLabel : "OpenCLIP" ,
177198 repoName : "OpenCLIP" ,
178199 repoUrl : "https://github.com/mlfoundations/open_clip" ,
179200 snippets : snippets . open_clip ,
180201 filter : true ,
202+ countDownloads : { wildcard : { path : "*pytorch_model.bin" } } ,
181203 } ,
182204 paddlenlp : {
183205 prettyLabel : "paddlenlp" ,
@@ -186,13 +208,19 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
186208 docsUrl : "https://huggingface.co/docs/hub/paddlenlp" ,
187209 snippets : snippets . paddlenlp ,
188210 filter : true ,
211+ countDownloads : {
212+ term : { path : "model_config.json" } ,
213+ } ,
189214 } ,
190215 peft : {
191216 prettyLabel : "PEFT" ,
192217 repoName : "PEFT" ,
193218 repoUrl : "https://github.com/huggingface/peft" ,
194219 snippets : snippets . peft ,
195220 filter : true ,
221+ countDownloads : {
222+ term : { path : "adapter_config.json" } ,
223+ } ,
196224 } ,
197225 "pyannote-audio" : {
198226 prettyLabel : "pyannote.audio" ,
@@ -215,6 +243,7 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
215243 docsUrl : "https://huggingface.co/docs/hub/sample-factory" ,
216244 snippets : snippets . sampleFactory ,
217245 filter : true ,
246+ countDownloads : { term : { path : "cfg.json" } } ,
218247 } ,
219248 "sentence-transformers" : {
220249 prettyLabel : "sentence-transformers" ,
@@ -238,6 +267,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
238267 repoUrl : "https://github.com/scikit-learn/scikit-learn" ,
239268 snippets : snippets . sklearn ,
240269 filter : true ,
270+ countDownloads : {
271+ term : { path : "sklearn_model.joblib" } ,
272+ } ,
241273 } ,
242274 spacy : {
243275 prettyLabel : "spaCy" ,
@@ -246,6 +278,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
246278 docsUrl : "https://huggingface.co/docs/hub/spacy" ,
247279 snippets : snippets . spacy ,
248280 filter : true ,
281+ countDownloads : {
282+ wildcard : { path : "*.whl" } ,
283+ } ,
249284 } ,
250285 "span-marker" : {
251286 prettyLabel : "SpanMarker" ,
@@ -262,6 +297,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
262297 docsUrl : "https://huggingface.co/docs/hub/speechbrain" ,
263298 snippets : snippets . speechbrain ,
264299 filter : true ,
300+ countDownloads : {
301+ term : { path : "hyperparams.yaml" } ,
302+ } ,
265303 } ,
266304 "stable-baselines3" : {
267305 prettyLabel : "stable-baselines3" ,
@@ -270,6 +308,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
270308 docsUrl : "https://huggingface.co/docs/hub/stable-baselines3" ,
271309 snippets : snippets . stableBaselines3 ,
272310 filter : true ,
311+ countDownloads : {
312+ wildcard : { path : "*.zip" } ,
313+ } ,
273314 } ,
274315 stanza : {
275316 prettyLabel : "Stanza" ,
@@ -278,6 +319,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
278319 docsUrl : "https://huggingface.co/docs/hub/stanza" ,
279320 snippets : snippets . stanza ,
280321 filter : true ,
322+ countDownloads : {
323+ term : { path : "models/default.zip" } ,
324+ } ,
281325 } ,
282326 tensorflowtts : {
283327 prettyLabel : "TensorFlowTTS" ,
@@ -292,6 +336,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
292336 docsUrl : "https://huggingface.co/docs/hub/timm" ,
293337 snippets : snippets . timm ,
294338 filter : true ,
339+ countDownloads : {
340+ terms : { path : [ "pytorch_model.bin" , "model.safetensors" ] } ,
341+ } ,
295342 } ,
296343 transformers : {
297344 prettyLabel : "Transformers" ,
@@ -315,6 +362,9 @@ export const MODEL_LIBRARIES_UI_ELEMENTS = {
315362 repoUrl : "https://github.com/Unity-Technologies/sentis-samples" ,
316363 snippets : snippets . sentis ,
317364 filter : true ,
365+ countDownloads : {
366+ wildcard : { path : "*.sentis" } ,
367+ } ,
318368 } ,
319369} satisfies Record < string , LibraryUiElement > ;
320370
0 commit comments