Repository navigation
fix: give the default intruder as many highlights as the activating examples show - #197
Open
albertlieyingadrian wants to merge 1 commit into
Open
albertlieyingadrian wants to merge 1 commit into
albertlieyingadrian wants to merge 1 commit into
Conversation
…xamples show IntruderScorer(type="default") set the number of random highlights on the intruder from every token with activation > 0, while the activating examples only highlight tokens at or above 0.3 * max. Count the tokens that activation_highlight_indices(example, 0.3) returns instead, so the intruder can't be spotted by its number of highlighted tokens.
Author
|
@SrGonao when you have a moment, could you take a look? In short: Give the default intruder as many highlights as the activating examples show. Happy to change anything. |
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.
Problem
In
IntruderScorer(type="default"), the intruder getsn_incorrectrandom highlights, set to the average number of active tokens in the activating examples it is shown with. That average counts every token with activation > 0:But the activating examples themselves are rendered with
_prepare_text(..., threshold=0.3), which highlights only tokens at or above 0.3 x max. When a latent has weak activations below that cutoff (common for SAE latents), the intruder carries more highlighted tokens than any activating example next to it, so the odd one out can be found by counting highlights rather than by reading the explanation.A CPU repro with synthetic activations (one peak at 10.0 plus a few weak 1.0 activations per window, 4 examples per batch) gives these
<<...>>span counts per batch, with*marking the intruder:I have not measured how much this inflates intruder scores with a real model; the change only removes the counting shortcut.
Change
Count
len(activation_highlight_indices(example, 0.3)), the same rule_prepare_textuses to render the activating examples. No other behaviour changes;type="internal"is untouched.Checks
test_intruder_highlights_as_many_tokens_as_activating_examplesintests/test_scorers/test_intruder_example_embedding.py(CPU, synthetic data, no model calls). It fails onmain(assert [1, 1, 4, 1] == [1, 1, 1, 1]) and passes on this branch.pytest tests --ignore=tests/client_test.py(that file needs vllm): 349 passed.ruff checkandblack --checkpass on the changed files.Related: #198 fixes a separate seeding issue on the next few lines (the same
_prepare_textcall does not getrng=self.rng). The two PRs merge cleanly in either order.