# How to get model size?

**URL:** <https://discuss.huggingface.co/t/how-to-get-model-size/11038>\
**Category:** Models\
**Created:** [October 25, 2021, 6:28am UTC](https://discuss.huggingface.co/t/how-to-get-model-size/11038 "2021-10-25T06:28:56Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexgrishin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/alexgrishin/32/19744_2.png) [@alexgrishin](https://discuss.huggingface.co/u/alexgrishin)\
**Post date:** [October 25, 2021, 6:28am UTC](https://discuss.huggingface.co/t/how-to-get-model-size/11038/1 "2021-10-25T06:28:56Z")

</div>

Hi, everyone!  
Is there a quick way to get model size for an arbitrary transformers model?

---

<div class="post-metadata">

**Author:** ![Kirili4ik](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/kirili4ik/32/2911_2.png) [@Kirili4ik](https://discuss.huggingface.co/u/Kirili4ik)\
**Post date:** [October 25, 2021, 7:46am UTC](https://discuss.huggingface.co/t/how-to-get-model-size/11038/2 "2021-10-25T07:46:38Z")

</div>

Hi🤗  
Do you mean size in mb or the number of the parameters used?

Regarding size check this:

> <https://stackoverflow.com/questions/68086929/how-to-get-the-size-of-a-hugging-face-pretrained-model/68167668#68167668>

Regarding the number of the parameters in PyTorch you can use:  
`sum(p.numel() for p in model.parameters())`

---

<div class="post-metadata">

**Author:** ![nielsr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/nielsr/32/39617_2.png) [@nielsr](https://discuss.huggingface.co/u/nielsr)\
**Post date:** [October 25, 2021, 9:21am UTC](https://discuss.huggingface.co/t/how-to-get-model-size/11038/3 "2021-10-25T09:21:48Z")

</div>

For me, the simplest way is to go to the “Files and versions” tab of a given model on the hub, and then check the size in MB/GB of the `pytorch_model.bin` file (or equivalently, the Flax/Tensorflow model file).

e.g. [GPT-J-6B](https://huggingface.co/EleutherAI/gpt-j-6B/tree/main) is 22.5 GB, as can be seen here:

 ![Schermafbeelding 2021-10-25 om 11.19.51](https://us1.discourse-cdn.com/hellohellohello/original/2X/f/fc129ad98236e630dcaf6c248ac3246511e9bce8.png)

---

<div class="post-metadata">

**Author:** ![alexgrishin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/alexgrishin/32/19744_2.png) [@alexgrishin](https://discuss.huggingface.co/u/alexgrishin)\
**Post date:** [October 25, 2021, 7:03pm UTC](https://discuss.huggingface.co/t/how-to-get-model-size/11038/4 "2021-10-25T19:03:08Z")

</div>

Hi Kirill!  
Thank you!  
Inspired by the number-of-parameters part of your answer I figured, I could actually get it in a slightly simpler way:

> model.num\_parameters()

which returns the same number as your solution.  
Thanks for help!

---

<div class="post-metadata">

**Author:** ![alexgrishin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/alexgrishin/32/19744_2.png) [@alexgrishin](https://discuss.huggingface.co/u/alexgrishin)\
**Post date:** [October 25, 2021, 7:04pm UTC](https://discuss.huggingface.co/t/how-to-get-model-size/11038/5 "2021-10-25T19:04:15Z")

</div>

Hi Niels!  
Thank you!!

---

<div class="post-metadata">

**Author:** ![Aleem](https://avatars.discourse-cdn.com/v4/letter/a/bc79bd/32.png) [@Aleem](https://discuss.huggingface.co/u/Aleem)\
**Post date:** [October 9, 2022, 7:33pm UTC](https://discuss.huggingface.co/t/how-to-get-model-size/11038/6 "2022-10-09T19:33:40Z")

</div>

Is there a way to sort or filter models by file size?

---

<div class="post-metadata">

**Author:** ![endolith](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/endolith/32/26419_2.png) [@endolith](https://discuss.huggingface.co/u/endolith)\
**Post date:** [July 15, 2023, 6:30pm UTC](https://discuss.huggingface.co/t/how-to-get-model-size/11038/7 "2023-07-15T18:30:54Z")

</div>

Is there a way to get the size of pytorch\_model.bin without actually downloading the file? [mteb/leaderboard · Add size and language to table?](https://huggingface.co/spaces/mteb/leaderboard/discussions/15#64adbeebb2f83dec962c5ffc)

Nevermind, figured it out:

```auto
git clone --no-checkout https://huggingface.co/intfloat/multilingual-e5-large
cd multilingual-e5-large\

```

```auto
λ git lfs ls-files -s
020afdebf2 - model.safetensors (2.2 GB)
bb5a52503a - onnx/model.onnx (546 KB)
0cf1883fee - onnx/model.onnx_data (2.2 GB)
cfc8146abe - onnx/sentencepiece.bpe.model (5.1 MB)
62c24cdc13 - onnx/tokenizer.json (17 MB)
9aaa222c5a - pytorch_model.bin (2.2 GB)
cfc8146abe - sentencepiece.bpe.model (5.1 MB)
62c24cdc13 - tokenizer.json (17 MB)

```

Even better:

```auto
λ git lfs ls-files -s --include=pytorch_model.bin
9aaa222c5a - pytorch_model.bin (2.2 GB)

```
