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

adding tensorboard loss tracking for training and evaluation #1532

Closed
wants to merge 22 commits into from

Conversation

Mogady
Copy link

@Mogady Mogady commented Apr 25, 2022

I saw multiple discussions on adding loss tracking and tensor-board integration, however no pull requests have been made in that direction. 1021, 510, 336 and recently I needed that also.

I added a loss tracking module for both training and evaluation.

For evaluation:
since the code allow for custom evaluators, a LossEvaluator class is added which allow for calculating the loss and writing to TFboard logs beside the CSV file.

For training:

  • I had to change in the .fit() signature but not much, just adding a parameter tensorboard_params: Dict[str, object] = {'log': True, 'steps': 1000, 'loss': True, 'lr': False, 'grad_hist': False, 'grad_stats': False} for controlling it.
  • I used the steps parameter as a flag for when to log the training loss.

I understand this is not general enough, and i tried to not change the code signature that much, but hopefully it can serve as a reference or a basis for a better integration in the next versions.

@Mogady Mogady changed the title Adding tensorboard loss tracking for training and evaluation adding tensorboard loss tracking for training and evaluation Apr 25, 2022
@mi1ebsco
Copy link

Seems there are lots of whitespace differences that makes this PR difficult to review. Perhaps remove the whitespace changes you made and this might expedite the review process?

@Mogady
Copy link
Author

Mogady commented Jun 22, 2022

Seems there are lots of whitespace differences that makes this PR difficult to review. Perhaps remove the whitespace changes you made and this might expedite the review process?

Yes, sorry about that, it should be more clear now

@nreimers
Copy link
Member

Thanks for this PR.

There is a PR #1606 that adds a generic way to track loss that is also compatible with e.g. W&B. My plan is to add this generic framework first and then have classes / callbacks that can be used to track with tensorboard / W&B etc.

@Mogady
Copy link
Author

Mogady commented Jun 23, 2022

Thanks for this PR.

There is a PR #1606 that adds a generic way to track loss that is also compatible with e.g. W&B. My plan is to add this generic framework first and then have classes / callbacks that can be used to track with tensorboard / W&B etc.

Great, W&B is definitely better and easier, I couldn't use it because of the license, but if you are giving us access to the values to design any custom dashboard then it would be perfect.

@Mogady Mogady closed this Jun 23, 2022
SwamiKannan added a commit to SwamiKannan/llama_index that referenced this pull request Mar 2, 2024
Contains an inherited class from SentenceTransformer called TBSentenceTransformer that allows llamaindex's SentenceTransformersFinetuneEngine to track and record loss while finetuning using tensorboard.
Credit to this PR: UKPLab/sentence-transformers#1532 , by Ahmed Magdy https://github.com/Mogady
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants