Created
July 14, 2025 06:06
-
-
Save ytxmobile98/5b1a22a089a16aacb884a9bc5e835fcd to your computer and use it in GitHub Desktop.
How to find out the parameter size for a transformers model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from transformers import AutoModel | |
| import torch | |
| model_path = "./my_downloaded_model" | |
| model = AutoModel.from_pretrained(model_path, local_files_only=True) | |
| total_params = sum(p.numel() for p in model.parameters()) | |
| trainable_params = sum(p.numel() for p in model.parameters() if p.requires_grad) | |
| print(f"Total parameters: {total_params}") | |
| print(f"Trainable parameters: {trainable_params}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment