feat: self-contrast for rows without augmentation - #53
Merged
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.
Summary
transformedisNone), use self-contrast — copy the original code into thetransformedfield so the model sees two views of the same code with different MLM masks. This creates "easy" contrastive pairs that act as implicit curriculum learning alongside the harder invariant-contrast pairs.self_contrast(defaulttrue) toPretrainConfigand both CLI subcommands (run --no-self-contrast,pretrain --no-self-contrast) to allow disabling the behavior.supcon/andgrouped/YAML configs updated to use the full dataset (data/csn.jsonl) withself_contrast: true.doc/self-contrast.mdwith analysis of why self-contrast is feasible and beneficial (MLM masking as augmentation, implicit curriculum, data efficiency, SupCon compatibility).Motivation
Transformation operators can fail on certain code samples (e.g., no for-loops to convert, no local variables to rename). Previously these rows were silently dropped, wasting a large fraction of the dataset. Self-contrast retains every row by leveraging independent MLM masking as a natural data augmentation — analogous to SimCSE's dropout-as-augmentation strategy.
Changes
modeling/pretrain.pydataset.filterwithdataset.mapthat fillsNone→ original code (whenself_contrast=True)modeling/config.pyself_contrast: bool = TruetoPretrainConfigmodeling/cli.py--self-contrast / --no-self-contrastto bothrunandpretrainsubcommandsexperiments/**/*.yamldata/csn.jsonl, addself_contrast: truedoc/self-contrast.mdTest plan
self_contrast: true(default) and verify no rows are dropped--no-self-contrastand verify rows without augmentation are filtered out