Skip to content

feat(scan): stream or subsample datasets; avoid duplicate HarmBench loads - #2680

Open
davidberenstein1957 wants to merge 1 commit into
mainfrom
feat/scan-frugal-dataset-loading
Open

feat(scan): stream or subsample datasets; avoid duplicate HarmBench loads#2680
davidberenstein1957 wants to merge 1 commit into
mainfrom
feat/scan-frugal-dataset-loading

Conversation

@davidberenstein1957

Copy link
Copy Markdown
Member

Closes #2669

Summary

  • Add internal iter_jsonl and reservoir_sample helpers for streaming JSONL and uniform subsampling without full materialization.
  • Refactor dataset generators to sample while streaming; subsample during load instead of read-all-then-rng.choice.
  • Activate a suite-scoped dataset cache in generate_suite so HarmBench (and other shared corpora) are parsed once and reused across generators such as plain HF and GCG.
  • Public ScenarioGenerator.generate_scenario(...) signatures are unchanged.

Test plan

  • make format
  • make test-unit PACKAGE=giskard-scan (166 passed)
  • 500-line JSONL fixture with max_scenarios=20 returns 20 scenarios via reservoir sampling
  • HarmBench plain + GCG generators share one iter_jsonl parse when cache is active

Stream JSONL datasets with reservoir sampling instead of loading full
corpora before subsampling, and share parsed HarmBench records across
generators within a suite via a process-scoped cache.

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

Development

Successfully merging this pull request may close these issues.

feat(scan): stream or subsample datasets; avoid duplicate HarmBench loads

1 participant