-
Notifications
You must be signed in to change notification settings - Fork 416
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
Implement own BERT score #473
Conversation
* Update docs * Remove old parts of code * Update and write tests * Clean the code
for more information, see https://pre-commit.ci
Codecov Report
@@ Coverage Diff @@
## master #473 +/- ##
======================================
- Coverage 96% 95% -1%
======================================
Files 130 130
Lines 4357 4585 +228
======================================
+ Hits 4174 4365 +191
- Misses 183 220 +37 |
* Fix IDF rescalins * Add new tests for IDF * Add explicit dtypes when used torch.cat to make this work with older PT versions
for more information, see https://pre-commit.ci
* Add a support for the DDP mode and add the corresponding test * Add a suport for verbose using tqdm loader * Add some missing docs * Update CHANGELOG.md
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
* Add support for the use's own model * Add the corresponding example
for more information, see https://pre-commit.ci
@Borda There's an error with DDP on Windows (please see an exception below). I'm not familiar with Windows, i.e. is this something Windows-specific?
|
hehe I do not think that DDP is properly working on Windows... @awaelchli? |
torch.distributed has support for windows from PyTorch 1.8 |
@awaelchli @Borda Thanks a lot, I'll add a condition there :) |
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.
Fun metric, thanks for the hard work!
The is one last particular config/test failing... mind have a look? |
Yeah, it seems to be an OOM issue during the DDP test. I'll try a smaller model for testing. |
Head branch was pushed to by a user without write access
@Borda looks like a smaller model solves the issue :) |
@stancld seems now taking way more time for all the latest configurations... so it is failing on timeout |
@Borda it seems like some processes must hang out when running multiprocessing on MacOS outside the |
I see, lets address this issue in another PR :] |
* Start adding own BERTScore implementation * Prepare the basic backbone for own BERTScore * Make working BERTScore with all_layers=True + init bert_score in torchmetrics * Fix cuda device placing * Use IDF only if asked * Add data collators * Remove old parts of code * Fix IDF rescaling and add new tests + fix type * Add new tests for IDF * Add explicit dtypes when used torch.cat to make this work with older PT versions * Adjust code to work with the DDP plus some changes * Add a support for the DDP mode and add the corresponding test * Add a suport for verbose using tqdm loader * Fix a bug with tokenizer and add hash_code * Fix transformers import * Add support for the user's own model * Add the corresponding example * Fix error raised by default tokenizer * Add support for the rescale with baseline * Clean some code + add some docstirngs * Run bert-ddp tests only if torch.distributed.is_available() * Use smaller model, 'albert-base-v2', for testing because of OOM issues * Set join=False for mp_spawn in the ddp_test Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 7b09381) # Conflicts: # torchmetrics/text/bert.py # torchmetrics/utilities/imports.py
* Start adding own BERTScore implementation * Prepare the basic backbone for own BERTScore * Make working BERTScore with all_layers=True + init bert_score in torchmetrics * Fix cuda device placing * Use IDF only if asked * Add data collators * Remove old parts of code * Fix IDF rescaling and add new tests + fix type * Add new tests for IDF * Add explicit dtypes when used torch.cat to make this work with older PT versions * Adjust code to work with the DDP plus some changes * Add a support for the DDP mode and add the corresponding test * Add a suport for verbose using tqdm loader * Fix a bug with tokenizer and add hash_code * Fix transformers import * Add support for the user's own model * Add the corresponding example * Fix error raised by default tokenizer * Add support for the rescale with baseline * Clean some code + add some docstirngs * Run bert-ddp tests only if torch.distributed.is_available() * Use smaller model, 'albert-base-v2', for testing because of OOM issues * Set join=False for mp_spawn in the ddp_test Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Jirka Borovec <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> (cherry picked from commit 7b09381)
Before submitting
What does this PR do?
This PR implements the
torchmetrics
' own BERTScore's and aims to remove the dependency on the originalbert-score
package (see https://github.com/Tiiiger/bert_score). Also, it aims to leave thetransformers
package as an optional one.Fixes #432 resolves #472
Current state:: All important features should be implemented. Though it is a lot of code so I expect some changes are to be required after reviews :)
PR review
Anyone in the community is free to review the PR once the tests have passed. Thank you for all the feedback in advance O:)
Did you have fun?
Make sure you had fun coding 🙃