-
Notifications
You must be signed in to change notification settings - Fork 421
feat: automatic model card generation on save
#3857
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: automatic model card generation on save
#3857
Conversation
src/argilla/client/feedback/integrations/huggingface/card/argilla_model_template.md
Outdated
Show resolved
Hide resolved
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.
Hi @plaguss,
This is looking good already. Some remarks.
For a separate PR:
[ ] I think we should add a push_to_huggingface
method to each of the trainers. Here we can nicely include the cards.
[ ] Also, we need a call
or predict
method for each for each of the trainers.
I believe there are some issues on GitHub but otherwise feel free to create them.
For this PR:
[ ] Missing some tests.
[ ] missing some docs.
[ ] We should add model_card_data
to the from argilla.client.feedback.training
ABC base class.
model_card_data
might be renamed to get_model_card_data
maybe integrations/huggingface/model_card
is more explicit?
src/argilla/client/feedback/training/frameworks/transformers.py
Outdated
Show resolved
Hide resolved
src/argilla/client/feedback/integrations/huggingface/card/model_card.py
Outdated
Show resolved
Hide resolved
src/argilla/client/feedback/integrations/huggingface/card/model_card.py
Outdated
Show resolved
Hide resolved
src/argilla/client/feedback/integrations/huggingface/card/model_card.py
Outdated
Show resolved
Hide resolved
src/argilla/client/feedback/integrations/huggingface/card/model_card.py
Outdated
Show resolved
Hide resolved
src/argilla/client/feedback/integrations/huggingface/card/model_card.py
Outdated
Show resolved
Hide resolved
src/argilla/client/feedback/integrations/huggingface/card/model_card.py
Outdated
Show resolved
Hide resolved
src/argilla/client/feedback/integrations/huggingface/card/model_card.py
Outdated
Show resolved
Hide resolved
src/argilla/client/feedback/integrations/huggingface/card/model_card.py
Outdated
Show resolved
Hide resolved
) | ||
|
||
trainer.update_config( | ||
# The non default hyperparameters will be filled here |
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.
is there a way to get these arguments too?
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.
Don't spend too much time on this.
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 working on this right now, but its so draft to push the commits yet. They are a bit trickier depending on the model. For example, transformers
is almost done as the inner trainer_kwargs
is relatively simple, but in the trl
framework it will take some work to nicely print config=PPOConfig(batch_size=1, ppo_epochs=1)
I think. I'm working on it, if I see that it needs too much effort I'll let you know 😃.
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.
With the current implementation we cannot write the arguments passed by the user to update_config
in the following cases:
spacy
: it jdoesn't work due to how the training configuration is defined with nested dicts, the (naive) function_updated_arguments
which grabs the user arguments cannot currently deal with nested dicts. For example, the default configuration for spacy is:
{
'dev_corpus': 'corpora.dev',
'train_corpus': 'corpora.train',
'batcher': {
'@batchers': 'spacy.batch_by_words.v1',
'discard_oversize': False,
'tolerance': 0.2,
'size': {'@schedules': 'compounding.v1', 'start': 100, 'stop': 1000, 'compound': 1.001, 't': 0.0},
'get_length': None
},
'optimizer': {'@optimizers': 'Adam.v1', 'beta1': 0.9, 'beta2': 0.999, 'L2_is_weight_decay': True, 'L2': 0.01, 'grad_clip': 1.0, 'use_averages': False, 'eps': 1e-08, 'learn_rate': 0.001},
'seed': '${system.seed}',
'gpu_allocator': '${system.gpu_allocator}',
'dropout': 0.1,
'accumulate_gradient': 1,
'patience': 1600,
'max_epochs': 0,
'max_steps': 20000,
'eval_frequency': 200,
'score_weights': {
'cats_score': 1.0,
'cats_score_desc': None,
'cats_micro_p': None,
'cats_micro_r': None,
'cats_micro_f': None,
'cats_macro_p': None,
'cats_macro_r': None,
'cats_macro_f': None,
'cats_macro_auc': None,
'cats_f_per_type': None
},
'frozen_components': [],
'annotating_components': [],
'before_to_disk': None,
'before_update': None,
'logger': {'@loggers': 'spacy.ConsoleLogger.v1', 'progress_bar': False}
}
trl
(when usingPPO
only), the internal configuration makes it harder to print a nice representation for this case, mainly due toPPOConfig
, so I prefer to let this for the.
For the moment I'm generating the call to the
Working on the tests! I didn't forgot them, I'm still refining them. I wasn't sure of adding it to the ABC base class, but will do it.
Agree, I'll do it. I've found a decent amount of details, but it's already taking form. As soon as I got more time I'll let it ready for review 😄 Update:
|
Hello @davidberenstein1957, |
…on and rename to get_model_card_data
Hi @plaguss, thanks for the iteration 👍 I think we can also just call the The tests look fine, I think these need to be fixtures and can be added to a In terms of the docs, I would say adding it here would be great. |
…ry and check against the contents instead of reading from the file
with TemporaryDirectory() as tmpdirname:
content = trainer.generate_model_card(tmpdirname) I think it's a good idea to move all |
https://www.digitalocean.com/community/tutorials/python-io-bytesio-stringio and a separate PR would be great. Also, we can think of creating common |
…model card generation to True by default
We could add more data to the model card (metrics from the models should be there), but I think that it works in the current state, we can always make an upgrade 😃. |
…en calling generate_model_card from the trainer
I agree |
Hi @davidberenstein1957 do you know about the errors on the unit tests? They seem unrelated, I don't know if I missed something |
@plaguss, they are unrelated and we have been having them for a while without a clear solution besides re-running them. |
Description
This PR adds the option to generate a model card from the
ArgillaTrainer
when calling thesave
method.Closes #3634
Type of change
(Please delete options that are not relevant. Remember to title the PR according to the type of change)
How Has This Been Tested
(Please describe the tests that you ran to verify your changes. And ideally, reference
tests
)tests/integration/client/feedback/integrations/huggingface/test_model_card.py
Checklist
CHANGELOG.md
file (See https://keepachangelog.com/)