Fix bug which causes score method to ignore BERTScorer object's batch_size attribute#191
Open
gpetho wants to merge 2 commits into
Open
Fix bug which causes score method to ignore BERTScorer object's batch_size attribute#191gpetho wants to merge 2 commits into
score method to ignore BERTScorer object's batch_size attribute#191gpetho wants to merge 2 commits into
Conversation
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.
There is a bug in the
score()method's code: Abatch_sizeattribute can be specified for theBERTScorerobject, but this setting is ignored by thescore()method currently. In fact this attribute of theBERTScorerobject has no effect at all.The proposed fix is that if a
batch_sizeargument is not specified explicitly for thescore()method, then the value of theBERTScorerobject'sbatch_sizeattribute is used for calculating the embeddings.Another possibility would be to remove the
batch_sizeattribute and, along with it, thebatch_sizeparameter of theBERTScorerclass and its initializer method respectively, just like it was apparently done forverboseandreturn_hashearlier (I fixed the docstrings and removed these outdated parameters), but this would modify the interface of the class and thus break backward compatibility, so I'd rather not do that. I believe it's better to fix the bug instead.Note: This bug is no joke. I just lost some 3 or 4 hours of time because of it, trying to understand why BERTScore keeps running out of GPU RAM despite my having set batch size to 1, before it occurred to me that I should check if there's maybe some bug in the code.