huggingface / huggingface_hub

The official Python client for the Huggingface Hub.
https://huggingface.co/docs/huggingface_hub
Apache License 2.0
2.14k stars 559 forks source link

Show number of parameters on model card #1596

Closed darabos closed 1 year ago

darabos commented 1 year ago

Is your feature request related to a problem? Please describe. I often want to see the model size (the number of parameters). Often this is documented on the model card (or even the model name), but not always. So I sometimes have to download the model and check the size myself.

Describe the solution you'd like There could be a dedicated spot on the model card page that lists the number of parameters. It could list more details that can be read from the model files: the layers it has, parameters in each layer, and quantization.

Describe alternatives you've considered It's possible that this information is already on the model card and I'm just missing it. Or I'm in the wrong repo! Deep apologies in either case.

Additional context I would be happy to help implement this if it's a reasonable feature request. (I don't know whether there is already a pipeline that extracts something from the model files. Or if I'm in the right repo. 😰 )

Wauplin commented 1 year ago

Hey @darabos, thanks for your interest. This is actually a feature we launched a few weeks ago! Here is an example for bigscience/bloomz which has 176B BF16 parameters.

image

You can even have the details of all the layers when clicking on the arrow.

image

This feature is enabled only for models saved in the safetensors format. This is a format made to be both safe and fast to use. Even though not every model uses safetensors, a growing number of projects is using it by default which should hopefully solve your issue.

The main reason why we implement your requested feature only for safetensors is that reading the layer structure is made very easy by design as opposite to pickle formats where we would need to actually load the model on your server to get the information.

darabos commented 1 year ago

Oh, this is fantastic, thanks! Only doing it for safetensors makes sense! Thanks for the explanation.

julien-c commented 1 year ago

some doc about how it works under the hood is here, @darabos: https://huggingface.co/docs/safetensors/metadata_parsing