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

FEAT Helper to check if a model is a PEFT model #1713

Conversation

BenjaminBossan
Copy link
Member

@BenjaminBossan BenjaminBossan commented May 6, 2024

After internal discussion, we decided to add this convenience function.

>>> from peft.helpers import check_is_peft_model
>>> check_is_peft_model("gpt2")
False
>>> check_is_peft_model("peft-internal-testing/gpt2-lora-random")
True
>>> check_is_peft_model("peft-internal-testing/non-existing-model")
False
>>> check_is_peft_model("path/to/local/model/also/works")

@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.

@BenjaminBossan
Copy link
Member Author

Ping @stas00

@stas00
Copy link
Contributor

stas00 commented May 6, 2024

Excellent, thank you @BenjaminBossan.

The only possible suggestion is for a different naming as check and is are both verbs, so perhaps either is_peft_model or check_if_peft_model?

I'm not sure if you have a precedent for other similar check-if utils to follow the same convention.

Copy link
Contributor

@younesbelkada younesbelkada left a comment

Choose a reason for hiding this comment

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

Nice API ! Thanks !

@BenjaminBossan
Copy link
Member Author

The only possible suggestion is for a different naming as check and is are both verbs, so perhaps either is_peft_model or check_if_peft_model?

Good point, I renamed it to check_if_peft_model. My reasoning for not using is_peft_model is that I often want to call the variable that name in similar situations, e.g. is_peft_model = check_if_peft_model(...); if is_peft_model: ...

@BenjaminBossan BenjaminBossan merged commit 86d086e into huggingface:main May 7, 2024
14 checks passed
@BenjaminBossan BenjaminBossan deleted the feat-utitily-to-check-if-peft-model branch May 7, 2024 09:06
@stas00
Copy link
Contributor

stas00 commented May 7, 2024

yes, I totally agree that:

is_peft_model = check_if_peft_model()

sounds perfect to me.

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.

4 participants