Code callbacks and optional console output suppression while training#160
Open
Meorge wants to merge 6 commits intominimaxir:masterfrom
Open
Code callbacks and optional console output suppression while training#160Meorge wants to merge 6 commits intominimaxir:masterfrom
Meorge wants to merge 6 commits intominimaxir:masterfrom
Conversation
Currently supports callbacks for when training begins and ends, when a batch ends, and when sample text is generated.
The print_generated argument in aitextgen.train() allows the user to prevent the text from being printed to the console
The print_saved argument in aitextgen.train() allows the user to prevent "X steps reached: saving model" messages from being printed to the console
Callback is called whenever the model is saved
Author
|
Using these features, this evening I started implementing a GUI frontend for aitextgen using PyQt5. Still obviously very barebones but I'm happy how quickly I was able to get it to work :) Screen.Recording.2021-10-27.at.9.20.32.PM.mov |
Owner
|
I saw the tweets about this UI. Because I'm working on migrating to the official Hugging Face trainer in the |
Author
|
Thanks, I'm happy to hear it! 😄 That's a good point regarding the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm hoping to work on a GUI frontend app that will make using aitextgen more accessible, but I realized that to do that it would need to be able to interface more closely with aitextgen itself. To be able to accomplish this, I've started working on adding support for custom callbacks/hooks in aitextgen. This pull request adds some basic support for callbacks/hooks while training with
train(), as well as options for suppressing some of the default console output.Custom callbacks
The user can pass a dictionary into the
train()function as the argumentcallbackswith lambdas or functions corresponding to the following keys:on_train_start(): called when training beginson_train_end(): called when training endson_batch_end(current_steps: int, total_steps: int, current_loss: int, avg_loss: int): called when a batch is completed, and passes the current and total steps along with the current and average loss to the functionon_sample_text_generated(texts: List[str]): called when sample texts are generated, and passes the List of sample texts to the functionon_model_saved(current_steps: int, total_steps: int, output_dir: str): called when the model is saved during training, and passes the current and total steps along with the output directory to the functionSuppressing console output
If set to
False, theprint_generatedandprint_savedarguments fortrain()will prevent generated text and "saving model" messages from being displayed in the console, respectively.Example script
I modified the Hello World Tutorial from the aitextgen website to test this functionality:
Once it got past setup, the output was: