[BUG] Fix MaskedDataset y_masked initialization from wrong tensor#304
Closed
officialasishkumar wants to merge 1 commit into
Closed
[BUG] Fix MaskedDataset y_masked initialization from wrong tensor#304officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
MaskedDataset.__getitem__ was initializing y_masked by cloning x instead of y. This meant the target tensor for masked language modeling was derived from the input rather than the actual target sequence. Added tests for MaskedDataset.__getitem__ to prevent regression. Fixes gc-os-ai#302 Signed-off-by: Asish Kumar <officialasishkumar@gmail.com>
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.
Reference Issues/PRs
Fixes #302
What does this implement/fix? Explain your changes.
MaskedDataset.__getitem__was initializingy_maskedby cloningxinstead ofy. This meant the target tensor for masked language modeling was derived from the input rather than the actual target sequence, corrupting training targets.The fix changes line 154 in
pyaptamer/datasets/dataclasses/_masked.pyfromy_masked = x.clone().detach()toy_masked = y.clone().detach().What should a reviewer concentrate their feedback on?
_masked.pyis correcttest_masked_dataset.pyfor completenessDid you add any tests for the change?
Yes. Added
pyaptamer/datasets/tests/test_masked_dataset.pywith four tests:test_len— verifies__len__returns the correct counttest_mismatched_lengths_raises— verifiesValueErroron mismatched x/ytest_getitem_returns_four_tensors— verifies return shape and typestest_getitem_y_masked_derived_from_y— regression test ensuringy_maskedvalues come fromy, notxAny other comments?
None.
PR checklist