-
Notifications
You must be signed in to change notification settings - Fork 39
Huggingface integration #137
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
Conversation
Save model at the end of each iteration Co-authored-by: David de la Iglesia Castro <daviddelaiglesiacastro@gmail.com>
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.
Thanks for the contribution @pacifikus ! It looks great.
Could you:
- Open a P.R. in https://github.com/iterative/dvc.org adding HuggingFace to the list of https://dvc.org/doc/dvclive/user-guide/ml-frameworks . You should be able to use some of the other pages as reference
dvclive/huggingface.py
Outdated
| super().__init__() | ||
| self.model_file = model_file | ||
|
|
||
| def on_evaluate( |
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 reason why the Callbacks that are part of HuggingFace use on_log instead of on_evaluate:
https://huggingface.co/transformers/_modules/transformers/integrations.html#CometCallback
This callback does look simpler than those other implementations, but I'm just curious about that
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.
Thank you for your comment!
PR in dvc.org: iterative/dvc.org#2718
Yes, there is a reason why the Callbacks that are part of HuggingFace use on_log instead of on_evaluate. As you can see in https://huggingface.co/transformers/main_classes/callback.html#trainercallback, metrics are only available in the on_evaluate event. Thus, we can get the loss values both at the train and eval from on_log, but eval metrics only from on_evaluate.
The on_evaluate event has its disadvantage: we cannot get the training loss during this event, only the evaluation loss.
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.
Thanks for the explanation. Would it make sense to extend DvcLiveCallback to use both on_log (for train and eval losses) and on_evaluate (for eval metrics) ?
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.
Yes, I think it's a good idea. I did it
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 think that the huggingface docs might be a little misleading. I just debug the test locally and it seems that the same values available as metrics inside on_evaluate are previously being passed as logs to on_log.
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.
Yes, you're right, it's strange, but metrics logs are also written in on_log event. Thank you for your comment!
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.
Hmm, now for different operating systems, different len(first(logs.values())) values in the test are obtained
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.
Well that is strange, I will debug locally the macOS test case which is the one failing
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.
Still don't understand what the bug was. If I have to guess, it might be related with first behaving differently in MacOS. Anyway I made the test more explicit and it now passes 🎉
Codecov Report
@@ Coverage Diff @@
## master #137 +/- ##
==========================================
+ Coverage 90.00% 90.43% +0.43%
==========================================
Files 12 13 +1
Lines 310 324 +14
==========================================
+ Hits 279 293 +14
Misses 31 31
Continue to review full report at Codecov.
|
Co-authored-by: David de la Iglesia Castro <daviddelaiglesiacastro@gmail.com>
Closes #83