-
Notifications
You must be signed in to change notification settings - Fork 507
Add Pruna AI library snippets (no formatting changes) #1733
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
Add Pruna AI library snippets (no formatting changes) #1733
Conversation
- Introduced `pruna` function to generate code snippets based on model library type. - Added support for `diffusers` and `transformers` libraries with specific snippet transformations. - Included a default snippet for models not matching the specified libraries. - Updated `MODEL_LIBRARIES_UI_ELEMENTS` to include Pruna AI with relevant repository and documentation links.
- Added a utility function to prepend the PrunaModel import to snippets if not already present. - Updated the `pruna` function to apply this import check to generated snippets. - Removed redundant import checks from `pruna_diffusers` and `pruna_transformers` functions for cleaner code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not check the diffusers/transformers snippets themselves but the PR looks good. I left a few comments to address but that's all :)
And thanks for opening a separate PR without reformatting!
- Refactored the `pruna` function to use model tags instead of library names for identifying model types. - Reintroduced the Pruna AI entry in `MODEL_LIBRARIES_UI_ELEMENTS` after its removal, ensuring it includes relevant repository and documentation links. - Improved code clarity by aligning snippet generation with updated model identification criteria.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I'll merge once lint CI is green :)
(expect 2-3 days before getting it live on the Hub) |
This update enhances support for Pruna AI, providing users with tailored code snippets for model integrations with Transformers and Diffusers.
TLDR: Pruna API normally mimics the Transformers and Diffusers API, so we can use
PrunaModel.from_pretrained
on top of pipelines or specific models. We re-use the underlying snippets for both the library and do some greedy replacements of certain part of the code snippets.example
becomes