Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#3,591 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@ShivamSharma43 đang làm issue này rồi.

Từ ngày 27/10/2026.

  • #3592 của @ShivamSharma43 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
data

Hướng nghiên cứu

Đọc garak_dataset.py và vlsu_multimodal_dataset.py, sau đó so sánh bước xác thực max_examples của chúng với bản sửa lỗi loader ComicJailbreak được tham chiếu trong #3589. Kiểm tra xem mỗi loader có từ chối giá trị bằng không và giá trị âm khi khởi tạo hay không; hoàn thành khi cả hai đều tạo ra ValueError đã nêu và các giới hạn dương hợp lệ vẫn hoạt động.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug

The Garak loaders (_GarakRemoteDataset in pyrit/datasets/seed_datasets/remote/garak_dataset.py and every subclass, such as the package hallucination, system prompt and audio datasets) and _VLSUMultimodalDataset (vlsu_multimodal_dataset.py) accept any integer for max_examples. They compare against the cap only after appending, so a cap below 1 never stops the first item:

  • _GarakNpmDataset(max_examples=0) and max_examples=-1 each load 1 seed.
  • _VLSUMultimodalDataset(max_examples=0) loads the first matching example's text and image pair: len(prompts) >= 0 * 2 is only checked after the pair is added.

This is the same pattern as max_examples in the ComicJailbreak loader (#3589).

Steps/Code to Reproduce
import asyncio
from unittest.mock import AsyncMock, patch

from pyrit.datasets.seed_datasets.remote.garak_package_hallucination_dataset import _GarakNpmDataset
from pyrit.datasets.seed_datasets.remote.vlsu_multimodal_dataset import _VLSUMultimodalDataset
from pyrit.setup.initialization import IN_MEMORY, initialize_pyrit_async

ROWS = [{"text": f"pkg{i}", "package_first_seen": "2010-01-01"} for i in range(3)]


async def main():
    await initialize_pyrit_async(memory_db_type=IN_MEMORY)
    for max_examples in (0, -1):
        try:
            loader = _GarakNpmDataset(max_examples=max_examples)
            with patch.object(loader, "_fetch_from_huggingface_async", new=AsyncMock(return_value=ROWS)):
                dataset = await loader.fetch_dataset_async()
            print(f"garak npm max_examples={max_examples}: {len(dataset.seeds)} seeds")
        except ValueError as e:
            print(f"garak npm max_examples={max_examples}: ValueError: {e}")
        try:
            _VLSUMultimodalDataset(max_examples=max_examples)
            print(f"ml_vlsu max_examples={max_examples}: accepted")
        except ValueError as e:
            print(f"ml_vlsu max_examples={max_examples}: ValueError: {e}")


asyncio.run(main())
Expected Results

A cap below 1 is rejected when the loader is created, as the ComicJailbreak fix for #3589 does:

garak npm max_examples=0: ValueError: max_examples must be at least 1 or None, got 0
ml_vlsu max_examples=0: ValueError: max_examples must be at least 1 or None, got 0
garak npm max_examples=-1: ValueError: max_examples must be at least 1 or None, got -1
ml_vlsu max_examples=-1: ValueError: max_examples must be at least 1 or None, got -1
Actual Results
garak npm max_examples=0: 1 seeds
ml_vlsu max_examples=0: accepted
garak npm max_examples=-1: 1 seeds
ml_vlsu max_examples=-1: accepted
Screenshots

N/A

Versions
  • OS: Windows 11
  • Python version: 3.11.9
  • PyRIT version: installed from main (6224d531) in editable mode
Ngôn ngữ chính
Python
Star
4.7k
Fork
980
Merge trung bình
2 ngày 9 giờ
Pull request đã merge (30 ngày)
422

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của microsoft/PyRIT

Tất cả issue của microsoft/PyRIT

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.