Skip to content

fix: give the default intruder as many highlights as the activating examples show - #197

Open
albertlieyingadrian wants to merge 1 commit into
EleutherAI:mainfrom
albertlieyingadrian:fix/intruder-highlight-count
Open

albertlieyingadrian wants to merge 1 commit into
EleutherAI:mainfrom
albertlieyingadrian:fix/intruder-highlight-count

Conversation

@albertlieyingadrian

@albertlieyingadrian albertlieyingadrian commented Nov 23, 2026 •

Copy link
Copy Markdown

Problem

In IntruderScorer(type="default"), the intruder gets n_incorrect random 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:

num_active_tokens += (example.activations > 0).sum().item()

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:

main:   ['1', '3*', '1', '1']  ['3*', '1', '1', '1']  ['1', '2*', '1', '1']  ['1', '1', '4*', '1']
branch: ['1', '1*', '1', '1']  ['1*', '1', '1', '1']  ['1', '1*', '1', '1']  ['1', '1', '1*', '1']

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_text uses to render the activating examples. No other behaviour changes; type="internal" is untouched.

Checks

  • New test test_intruder_highlights_as_many_tokens_as_activating_examples in tests/test_scorers/test_intruder_example_embedding.py (CPU, synthetic data, no model calls). It fails on main (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 check and black --check pass on the changed files.

Related: #198 fixes a separate seeding issue on the next few lines (the same _prepare_text call does not get rng=self.rng). The two PRs merge cleanly in either order.

…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.
@CLAassistant

CLAassistant commented Nov 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@albertlieyingadrian

Copy link
Copy Markdown
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants