Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: highlight difference between num_parameters() and get_nb_trainable_parameters() in PEFT #1531

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

kmehant
Copy link
Contributor

@kmehant kmehant commented Mar 4, 2024

related to #1526

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the docstrings. I made some comments where I think it can be improved. Please check them out.

@@ -515,7 +515,12 @@ def get_nb_trainable_parameters(self) -> tuple[int, int]:

def print_trainable_parameters(self) -> None:
"""
Prints the number of trainable parameters in the model.
Prints the number of trainable parameters in the model. Note: print_trainable_parameters() uses
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please add 1 empty line after the first sentence (before "Note")?

@@ -515,7 +515,12 @@ def get_nb_trainable_parameters(self) -> tuple[int, int]:

def print_trainable_parameters(self) -> None:
"""
Prints the number of trainable parameters in the model.
Prints the number of trainable parameters in the model. Note: print_trainable_parameters() uses
get_nb_trainable_parameters() which is different from num_parameters(only_trainable=True).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's mention that num_parameters is a method from transformers.

Prints the number of trainable parameters in the model.
Prints the number of trainable parameters in the model. Note: print_trainable_parameters() uses
get_nb_trainable_parameters() which is different from num_parameters(only_trainable=True).
get_nb_trainable_parameters() returns (trainable parameters, all paramters) of the Peft Model which includes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

paramters -> parameters

get_nb_trainable_parameters() returns (trainable parameters, all paramters) of the Peft Model which includes
modified backbone transformer model. For techniques like LoRA, the backbone transformer model is modified in
place with LoRA modules. However, for prompt tuning, the backbone transformer model is unmodified.
num_parameters(only_trainable=True) returns number of trainable parameters of the backbone transformer model.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make it totally clear, let's add here that this can result in a different number :)

…ble_parameters() in PEFT

Signed-off-by: Mehant Kammakomati <[email protected]>
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@BenjaminBossan BenjaminBossan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this informative docstring!

@BenjaminBossan BenjaminBossan merged commit 7662f34 into huggingface:main Mar 5, 2024
14 checks passed
BenjaminBossan pushed a commit to BenjaminBossan/peft that referenced this pull request Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants