Skip to content

FIX Reject max_examples below 1 in the Garak and ML-VLSU loaders - #3592

Open
Shivam Sharma (ShivamSharma43) wants to merge 2 commits into
microsoft:mainfrom
ShivamSharma43:fix/dataset-max-examples-at-least-one
Open

Shivam Sharma (ShivamSharma43) wants to merge 2 commits into
microsoft:mainfrom
ShivamSharma43:fix/dataset-max-examples-at-least-one

Conversation

@ShivamSharma43

Copy link
Copy Markdown
Contributor

Description

Fixes #3591.

The Garak loaders (_GarakRemoteDataset and all its subclasses) and _VLSUMultimodalDataset checked max_examples only after adding an item, so max_examples=0 or a negative value still loaded the first item: one seed for the Garak datasets, and one text and image pair for ML-VLSU.

Changes:

  • _GarakRemoteDataset.__init__ and _VLSUMultimodalDataset.__init__ raise ValueError when max_examples is below 1, with the same message as the ComicJailbreak fix in FIX Count only rendered goals toward ComicJailbreak max_examples #3590. 0 cannot work, because an empty SeedDataset is invalid. The Garak subclasses don't override __init__, so they all get the check. The docstrings list the new error.

Tests and Documentation

  • tests/unit/datasets/test_garak_package_hallucination_dataset.py and tests/unit/datasets/test_vlsu_multimodal_dataset.py: max_examples of 0 and -1 are rejected. These 4 tests fail on main; the existing max_examples tests are unchanged.
  • Ran the reproduction from BUG: Garak and ML-VLSU loaders still load one example when max_examples is 0 or negative #3591: all four cases now raise.
  • pytest tests/unit/datasets: 5227 passed.
  • ruff check, ruff format and ty check pass on the changed files.
  • No documentation changes beyond the docstrings.

🤖 Generated with Claude Code

Both loaders checked the cap only after adding an item, so max_examples=0
or a negative value still loaded one seed (Garak) or one text and image
pair (ML-VLSU). Raise ValueError in __init__ instead, as the ComicJailbreak
loader does.

Fixes microsoft#3591

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 13:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The loaders now reject zero and negative limits at construction. Positive limits and None retain their existing behavior, with regression cases for the invalid values.

No blocking issues found by code inspection. Tests were not run for this review. AI-assisted review (GitHub Copilot).

This branch has not been deployed

No deployments
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.

BUG: Garak and ML-VLSU loaders still load one example when max_examples is 0 or negative

3 participants