-
Notifications
You must be signed in to change notification settings - Fork 52
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
ENH populate model card metadata with info from config.json #71
Conversation
I think we can proceed in this direction. It makes sense to use what's already there in the |
This finally makes the model work out of the box, example: https://huggingface.co/skops/hf_hub_example-bdc26c1f-7e82-42eb-9657-0318315f2df0 Note: the output is actually not reliable yet, for the model to get the right input, huggingface/api-inference-community#79 needs to be merged first. @osanseviero you might like this one ;) Running |
(There are some issues with the widget in linux, both Firefox and Chrome, and I've already told Mishig about them). Edit: fixed upstream: huggingface/hub-docs#276 |
Indeed I like this one, very cool! 🔥 |
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.
Overall, this looks good to me, it's a nice convenience for the user. I have a few nits, please take a look at the comments.
API-wise, there could be a little bit of dissonance now. To add non-metadata to the card, users use a method: card.add(foo=bar)
. To add metadata, they set attributes: card.metadata.foo = bar
. I believe it's good that the distinction between non-metadata and metadata is not hidden from the user (as it was before), but it's still a bit strange to set them so differently.
As a proposal (could be added later), what do you think about providing a new method, add_metadata
, which for users works exactly the same as add
(i.e. works with **kwargs and returns self) and under the hood sets attributes on the metadata?
# We will now create a model card and save it. For more information about how | ||
# to create a good model card, refer to the :ref:`model card example | ||
# <sphx_glr_auto_examples_plot_model_card.py>` | ||
model_card = card.Card(model, metadata=card.metadata_from_config(Path(local_repo))) |
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.
As a user, I might be confused about where the config comes from. How about adding a comment above the init
call that mentions that a config.json
is created for the user, similar to the comment in plot_model_card.py
?
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.
clarified!
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'm not sure about the idea of add_metadata
, let's see how this goes I'd say.
# We will now create a model card and save it. For more information about how | ||
# to create a good model card, refer to the :ref:`model card example | ||
# <sphx_glr_auto_examples_plot_model_card.py>` | ||
model_card = card.Card(model, metadata=card.metadata_from_config(Path(local_repo))) |
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.
clarified!
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.
LGTM
@@ -76,14 +140,18 @@ class Card: | |||
>>> model_card.add_plot(confusion_matrix="confusion_matrix.png") # doctest: +ELLIPSIS | |||
Card( | |||
model=LogisticRegression(random_state=0), | |||
license='mit', |
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.
Opened a separate issue to fix repr to include metadata here: #75
This PR adds a convenience function to populate the metadata section of model cards from the info available in
config.json
.I'll be adding tests, but I'm wondering what you think of the API @merveenoyan @BenjaminBossan ?