Repository navigation
fix: skip excluded tokens in the zero-ablation baseline - #773
Open
flyingdoubleG wants to merge 1 commit into
Open
flyingdoubleG wants to merge 1 commit into
flyingdoubleG wants to merge 1 commit into
Conversation
Since decoderesearch#754 the SAE replacement keeps the original activations at excluded tokens (BOS/EOS/PAD by default), but the zero-ablation baseline still zeroed every position. ce_loss_score and kl_div_score therefore compared an SAE that leaves BOS alone with an ablation that also destroys BOS, which inflates the ablation loss and the scores. Zero only the positions the SAE replaces, for the residual, all-head and single-head hooks.
This branch has not been deployed
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.
Description
Follow-up to #754. That PR made the SAE replacement in
get_recons_losskeep the original activations at excluded tokens (BOS/EOS/PAD, whichrun_evalsexcludes by default), and noted that the zero-ablation reference kept its existing behaviour. That reference still zeroes every position, including BOS, so the two runs thatce_loss_scoreandkl_div_scorecompare no longer touch the same positions:CE_saecomes from a run where BOS is left alone, whileCE_ablationcomes from a run where BOS (usually the attention sink) is also zeroed. The ablation loss is inflated, so both scores come out higher than they should.On GPT-2 small with
gpt2-small-res-jb(4 short prompts, BOS excluded, everything else default):blocks.4.hook_resid_preblocks.8.hook_resid_preAt layer 4 the unexplained part of the CE loss (1 − score) is under-reported by about 40% (1.4% vs 2.4%).
The fix zeroes only the positions the SAE replaces, using the same mask, for the residual, all-head (
hook_z) and single-head hooks. When nothing is excluded, the behaviour is unchanged.Type of change
Checklist:
test_zero_ablation_preserves_excluded_tokens_and_other_heads(3 cases, mirroring the #754 test) checks that the ablation run changes exactly the positions the replacement run changes. All 3 fail onmainand pass with the fix;tests/test_evals.pypasses in full (95 tests).ruff format --checkandruff checkpass on the changed files.You have tested formatting, typing and tests
make check-cito check format and linting. (you can runmake formatto format code if needed.)