99import zipfile
1010from enum import Enum
1111from pathlib import Path
12- from typing import TYPE_CHECKING , Literal
12+ from typing import TYPE_CHECKING , ClassVar , Literal
1313
1414from typing_extensions import override
1515
@@ -51,18 +51,6 @@ class FigStepVariant(Enum):
5151 FIGSTEP_PRO = "figstep_pro"
5252
5353
54- _DESCRIPTION = (
55- "Multimodal jailbreak prompt from the FigStep SafeBench benchmark. The image "
56- "encodes the harmful instruction as typography and the text prompt asks the "
57- "model to 'fill in the empty items' of the numbered list. The original harmful "
58- "question is preserved as the group objective."
59- )
60-
61- # Subfolder prefix used inside data/images/FigStep-Pro/sub-figures.zip:
62- # e.g. "image_0_splits/image_0_split_0.png".
63- _FIGSTEP_PRO_SPLIT_PATTERN = re .compile (r"^image_(?P<idx>\d+)_splits/image_\1_split_(?P<n>\d+)\.png$" )
64-
65-
6654class _FigStepDataset (_RemoteDatasetLoader ):
6755 """
6856 Loader for the FigStep typographic-image jailbreak benchmark (SafeBench).
@@ -100,7 +88,20 @@ class _FigStepDataset(_RemoteDatasetLoader):
10088 Repository: https://github.com/ThuCCSLab/FigStep
10189 """
10290
103- _AUTHORS : tuple [str , ...] = (
91+ _DESCRIPTION : ClassVar [str ] = (
92+ "Multimodal jailbreak prompt from the FigStep SafeBench benchmark. The image "
93+ "encodes the harmful instruction as typography and the text prompt asks the "
94+ "model to 'fill in the empty items' of the numbered list. The original harmful "
95+ "question is preserved as the group objective."
96+ )
97+
98+ # Subfolder prefix used inside data/images/FigStep-Pro/sub-figures.zip:
99+ # e.g. "image_0_splits/image_0_split_0.png".
100+ _FIGSTEP_PRO_SPLIT_PATTERN : ClassVar [re .Pattern [str ]] = re .compile (
101+ r"^image_(?P<idx>\d+)_splits/image_\1_split_(?P<n>\d+)\.png$"
102+ )
103+
104+ _AUTHORS : ClassVar [tuple [str , ...]] = (
104105 "Yichen Gong" ,
105106 "Delong Ran" ,
106107 "Jinyuan Liu" ,
@@ -111,7 +112,7 @@ class _FigStepDataset(_RemoteDatasetLoader):
111112 "Xiaoyun Wang" ,
112113 )
113114
114- _GROUPS : tuple [str , ...] = ("Tsinghua University" ,)
115+ _GROUPS : ClassVar [ tuple [str , ...] ] = ("Tsinghua University" ,)
115116
116117 COMMIT_SHA : str = "0861b17b3d67887c06ee3534ec65b3012f9becb7"
117118 RAW_BASE_URL : str = f"https://raw.githubusercontent.com/ThuCCSLab/FigStep/{ COMMIT_SHA } /"
@@ -330,7 +331,7 @@ async def _build_figstep_group_async(self, *, row: dict[str, str]) -> list["Seed
330331 name = f"FigStep Objective - { category_id } _{ task_id } " ,
331332 dataset_name = self .dataset_name ,
332333 harm_categories = [row ["category_name" ]],
333- description = _DESCRIPTION ,
334+ description = self . _DESCRIPTION ,
334335 authors = list (self ._AUTHORS ),
335336 groups = list (self ._GROUPS ),
336337 source = self .PAPER_URL ,
@@ -343,7 +344,7 @@ async def _build_figstep_group_async(self, *, row: dict[str, str]) -> list["Seed
343344 name = f"FigStep Image - { category_id } _{ task_id } " ,
344345 dataset_name = self .dataset_name ,
345346 harm_categories = [row ["category_name" ]],
346- description = _DESCRIPTION ,
347+ description = self . _DESCRIPTION ,
347348 authors = list (self ._AUTHORS ),
348349 groups = list (self ._GROUPS ),
349350 source = self .PAPER_URL ,
@@ -358,7 +359,7 @@ async def _build_figstep_group_async(self, *, row: dict[str, str]) -> list["Seed
358359 name = f"FigStep Text - { category_id } _{ task_id } " ,
359360 dataset_name = self .dataset_name ,
360361 harm_categories = [row ["category_name" ]],
361- description = _DESCRIPTION ,
362+ description = self . _DESCRIPTION ,
362363 authors = list (self ._AUTHORS ),
363364 groups = list (self ._GROUPS ),
364365 source = self .PAPER_URL ,
@@ -419,7 +420,7 @@ async def _build_figstep_pro_group_async(
419420 name = f"FigStep-Pro Objective - { category_id } _{ task_id } " ,
420421 dataset_name = self .dataset_name ,
421422 harm_categories = [row ["category_name" ]],
422- description = _DESCRIPTION ,
423+ description = self . _DESCRIPTION ,
423424 authors = list (self ._AUTHORS ),
424425 groups = list (self ._GROUPS ),
425426 source = self .PAPER_URL ,
@@ -435,7 +436,7 @@ async def _build_figstep_pro_group_async(
435436 name = f"FigStep-Pro Image - { category_id } _{ task_id } _split_{ split_idx } " ,
436437 dataset_name = self .dataset_name ,
437438 harm_categories = [row ["category_name" ]],
438- description = _DESCRIPTION ,
439+ description = self . _DESCRIPTION ,
439440 authors = list (self ._AUTHORS ),
440441 groups = list (self ._GROUPS ),
441442 source = self .PAPER_URL ,
@@ -453,7 +454,7 @@ async def _build_figstep_pro_group_async(
453454 name = f"FigStep-Pro Text - { category_id } _{ task_id } " ,
454455 dataset_name = self .dataset_name ,
455456 harm_categories = [row ["category_name" ]],
456- description = _DESCRIPTION ,
457+ description = self . _DESCRIPTION ,
457458 authors = list (self ._AUTHORS ),
458459 groups = list (self ._GROUPS ),
459460 source = self .PAPER_URL ,
@@ -626,7 +627,7 @@ async def _fetch_figstep_pro_sub_images_async(
626627
627628 indexed_paths : list [tuple [int , str ]] = []
628629 for entry in splits_dir .iterdir ():
629- match = _FIGSTEP_PRO_SPLIT_PATTERN .match (f"image_{ row_idx } _splits/{ entry .name } " )
630+ match = self . _FIGSTEP_PRO_SPLIT_PATTERN .match (f"image_{ row_idx } _splits/{ entry .name } " )
630631 if not match :
631632 continue
632633 indexed_paths .append ((int (match .group ("n" )), str (entry )))
0 commit comments