Skip to content

fix: pass the scorer's rng when highlighting the default intruder - #198

Merged
SrGonao merged 1 commit into
EleutherAI:mainfrom
albertlieyingadrian:fix/intruder-seed
Nov 26, 2026
Merged

SrGonao merged 1 commit into
EleutherAI:mainfrom
albertlieyingadrian:fix/intruder-seed

Conversation

@albertlieyingadrian

@albertlieyingadrian albertlieyingadrian commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

IntruderScorer(seed=...) builds self.rng and _prepare_and_batch uses it for sampling examples and choosing the intruder position. The one exception is the type="default" intruder: its _prepare_text call does not pass rng, so its random highlights fall back to the global random module.

Two scorers built with seed=42 therefore build different batches whenever anything else has touched random in between. In a CPU repro with synthetic data (no model calls), seeding the global random with 1 and then 2 before building each scorer gave different intruder text in 6 of 6 batches. In the new test below, the first intruder came out as ABCD<<E>>FGHIJKLMNOP in one run and A<<B>>CDEFGHIJKLMNOP in the other.

Change

Pass rng=self.rng to that _prepare_text call, as the other random choices in _prepare_and_batch already do. The existing test's fake_prepare_text stub gains an rng=None parameter to accept it.

Checks

  • New test test_intruder_default_batches_are_reproducible_with_seed in tests/test_scorers/test_intruder_example_embedding.py (CPU, synthetic data, no model calls). It fails on main (the intruder's highlight differs between the two runs) 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: #197 fixes how many highlights the same intruder gets, a few lines above. The two PRs merge cleanly in either order.

IntruderScorer(type="default") picked the intruder's random highlights
with the global random module, because its _prepare_text call did not
pass rng=self.rng. Two scorers built with the same seed could build
different batches. Pass the scorer's rng, as the rest of
_prepare_and_batch already does.
@CLAassistant

CLAassistant commented Nov 23, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@albertlieyingadrian

Copy link
Copy Markdown
Contributor Author

@SrGonao when you have a moment, could you take a look? In short: Pass the scorer's rng when highlighting the default intruder. Happy to change anything.

@SrGonao
SrGonao merged commit c78f49b into EleutherAI:main Nov 26, 2026
3 checks passed
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.

3 participants