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

Add training.before_update callback #11739

Merged

Conversation

shadeMe
Copy link
Contributor

@shadeMe shadeMe commented Nov 2, 2022

Description

This callback can be used to implement training paradigms like gradual (un)freezing of components (e.g: the Transformer) after a certain number of training steps to mitigate catastrophic forgetting during fine-tuning.

Types of change

New feature

Checklist

  • I confirm that I have the right to submit this contribution under the project's MIT license.
  • I ran the tests, and all new and existing tests passed.
  • My changes don't require a change to the documentation, or if they do, I've added all required information.

This callback can be used to implement training paradigms like gradual (un)freezing of components (e.g: the Transformer) after a certain number of training steps to mitigate catastrophic forgetting during fine-tuning.
@shadeMe shadeMe requested a review from danieldk November 2, 2022 17:01
spacy/schemas.py Outdated Show resolved Hide resolved
@shadeMe shadeMe added feat / pipeline Feature: Processing pipeline and components feat / training Feature: Training utils, Example, Corpus and converters labels Nov 2, 2022
@shadeMe shadeMe marked this pull request as draft November 2, 2022 17:34
Copy link
Contributor

@danieldk danieldk left a comment

Choose a reason for hiding this comment

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

Did you find out if there is an easy way to test this?

spacy/training/loop.py Outdated Show resolved Hide resolved
@shadeMe
Copy link
Contributor Author

shadeMe commented Nov 9, 2022

Did you find out if there is an easy way to test this?

Nothing short of bundling a small, toy corpus file and invoking the train and init_nlp functions like I do in the gradual transformer unfreezing PR.

@adrianeboyd adrianeboyd added the v3.5 Related to v3.5 label Nov 11, 2022
@adrianeboyd
Copy link
Contributor

Can you add some minimal tests for this? It doesn't look like there are any training-specific callback tests yet, but there are similar tests for the [nlp] callbacks.

@adrianeboyd
Copy link
Contributor

I think you should be able to test this with train_while_improving without a separate .spacy file? (I'm pretty sure the tests are going to fail because it's not automatically included in the package, and we'd want to be careful in general about adding a lot of extra data to the test suite.)

@shadeMe
Copy link
Contributor Author

shadeMe commented Nov 18, 2022

Ah, didn't realize the extra data wouldn't be included anyway. I'll try out your suggestion.

@adrianeboyd
Copy link
Contributor

It's not that we can't add extra data with some additional settings, and it might make sense to have one toy .spacy file that's shared between different tests.

As I've mentioned a few times, the extra CLI tests in the CI should probably be moved into a proper test suite that's separate from the package tests and we can have the CI run both, and that would be an easier place for longer/larger tests.

Co-authored-by: Adriane Boyd <adrianeboyd@gmail.com>
@adrianeboyd adrianeboyd merged commit 5ea14af into explosion:master Nov 23, 2022
@shadeMe shadeMe deleted the feature/new-training-step-callback branch November 23, 2022 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat / pipeline Feature: Processing pipeline and components feat / training Feature: Training utils, Example, Corpus and converters v3.5 Related to v3.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants