guidedbench 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- guidedbench-0.1.0/LICENSE +201 -0
- guidedbench-0.1.0/MANIFEST.in +2 -0
- guidedbench-0.1.0/PKG-INFO +258 -0
- guidedbench-0.1.0/README.md +214 -0
- guidedbench-0.1.0/pyproject.toml +63 -0
- guidedbench-0.1.0/setup.cfg +4 -0
- guidedbench-0.1.0/src/guidedbench/__init__.py +27 -0
- guidedbench-0.1.0/src/guidedbench/_version.py +2 -0
- guidedbench-0.1.0/src/guidedbench/cli.py +423 -0
- guidedbench-0.1.0/src/guidedbench/dataset.py +172 -0
- guidedbench-0.1.0/src/guidedbench/evaluator.py +29 -0
- guidedbench-0.1.0/src/guidedbench/judges/__init__.py +13 -0
- guidedbench-0.1.0/src/guidedbench/judges/anthropic.py +56 -0
- guidedbench-0.1.0/src/guidedbench/judges/base.py +15 -0
- guidedbench-0.1.0/src/guidedbench/judges/openai.py +108 -0
- guidedbench-0.1.0/src/guidedbench/judges/transformers.py +69 -0
- guidedbench-0.1.0/src/guidedbench/models.py +103 -0
- guidedbench-0.1.0/src/guidedbench/parsing.py +69 -0
- guidedbench-0.1.0/src/guidedbench/prompt.py +42 -0
- guidedbench-0.1.0/src/guidedbench.egg-info/PKG-INFO +258 -0
- guidedbench-0.1.0/src/guidedbench.egg-info/SOURCES.txt +23 -0
- guidedbench-0.1.0/src/guidedbench.egg-info/dependency_links.txt +1 -0
- guidedbench-0.1.0/src/guidedbench.egg-info/entry_points.txt +2 -0
- guidedbench-0.1.0/src/guidedbench.egg-info/requires.txt +23 -0
- guidedbench-0.1.0/src/guidedbench.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 The GuidedBench Authors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: guidedbench
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Guideline-grounded evaluation for LLM jailbreak methods
|
|
5
|
+
Author: Xunguang Wang, Zongjie Li, Daoyuan Wu, Shuai Wang
|
|
6
|
+
Author-email: Ruixuan Huang <rhuangbi@connect.ust.hk>
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
Project-URL: Homepage, https://sproutnan.github.io/GuidedBench/
|
|
9
|
+
Project-URL: Repository, https://github.com/SproutNan/GuidedBench
|
|
10
|
+
Project-URL: Paper, https://openreview.net/forum?id=ZVg8y3ibyM
|
|
11
|
+
Project-URL: Issues, https://github.com/SproutNan/GuidedBench/issues
|
|
12
|
+
Keywords: llm,jailbreak,benchmark,ai-safety,evaluation
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: huggingface_hub>=0.27
|
|
26
|
+
Provides-Extra: openai
|
|
27
|
+
Requires-Dist: openai>=1.66.0; extra == "openai"
|
|
28
|
+
Provides-Extra: anthropic
|
|
29
|
+
Requires-Dist: anthropic>=0.40; extra == "anthropic"
|
|
30
|
+
Provides-Extra: local
|
|
31
|
+
Requires-Dist: accelerate>=0.26; extra == "local"
|
|
32
|
+
Requires-Dist: torch>=2.1; extra == "local"
|
|
33
|
+
Requires-Dist: transformers>=4.56.0; extra == "local"
|
|
34
|
+
Provides-Extra: all
|
|
35
|
+
Requires-Dist: accelerate>=0.26; extra == "all"
|
|
36
|
+
Requires-Dist: anthropic>=0.40; extra == "all"
|
|
37
|
+
Requires-Dist: openai>=1.66.0; extra == "all"
|
|
38
|
+
Requires-Dist: torch>=2.1; extra == "all"
|
|
39
|
+
Requires-Dist: transformers>=4.56.0; extra == "all"
|
|
40
|
+
Provides-Extra: dev
|
|
41
|
+
Requires-Dist: build>=1.2; extra == "dev"
|
|
42
|
+
Requires-Dist: twine>=5; extra == "dev"
|
|
43
|
+
Dynamic: license-file
|
|
44
|
+
|
|
45
|
+
<div align="center">
|
|
46
|
+
|
|
47
|
+
# GuidedBench
|
|
48
|
+
|
|
49
|
+
**Guideline-grounded evaluation for LLM jailbreak methods**
|
|
50
|
+
|
|
51
|
+
[Paper](https://openreview.net/forum?id=ZVg8y3ibyM) ·
|
|
52
|
+
[Project page](https://sproutnan.github.io/GuidedBench/) ·
|
|
53
|
+
[Dataset](https://huggingface.co/datasets/HRXUST/GuidedBench)
|
|
54
|
+
|
|
55
|
+
</div>
|
|
56
|
+
|
|
57
|
+
GuidedBench evaluates whether a victim-model response fulfills the specific
|
|
58
|
+
harmful objective in a question. Every case includes verified, case-specific
|
|
59
|
+
entity and action guidelines, turning a holistic harmfulness judgment into a
|
|
60
|
+
set of explicit content checks.
|
|
61
|
+
|
|
62
|
+
The benchmark contains 200 English cases across 20 topics: a 180-case core set
|
|
63
|
+
and a 20-case, vendor-policy-dependent additional set. GuidedBench was accepted
|
|
64
|
+
as a poster at ICLR 2026.
|
|
65
|
+
|
|
66
|
+
## Installation
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
pip install guidedbench
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Install the current GitHub version directly when needed:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install "guidedbench @ git+https://github.com/SproutNan/GuidedBench.git"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Install only the judge backend you need:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
pip install "guidedbench[openai]" # OpenAI and OpenAI-compatible APIs
|
|
82
|
+
pip install "guidedbench[anthropic]" # Claude Messages API
|
|
83
|
+
pip install "guidedbench[local]" # Local Hugging Face Transformers model
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Two-step workflow
|
|
87
|
+
|
|
88
|
+
GuidedBench separates jailbreak generation from evaluation. Your jailbreak
|
|
89
|
+
runner produces victim-model responses in Step 1; GuidedEval scores those saved
|
|
90
|
+
responses in Step 2. GuidedBench does not require a particular attack framework
|
|
91
|
+
or victim-model provider.
|
|
92
|
+
|
|
93
|
+
### Step 1: Run your jailbreak method on GuidedBench
|
|
94
|
+
|
|
95
|
+
First request access on the
|
|
96
|
+
[GuidedBench dataset page](https://huggingface.co/datasets/HRXUST/GuidedBench),
|
|
97
|
+
then authenticate once:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
hf auth login
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Load the core cases and pass each `question` through your existing jailbreak
|
|
104
|
+
method and victim-model client:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
import json
|
|
108
|
+
from collections.abc import Callable
|
|
109
|
+
|
|
110
|
+
from guidedbench import load_cases
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def generate_responses(
|
|
114
|
+
jailbreak_method: Callable[[str], str],
|
|
115
|
+
query_victim: Callable[[str], str],
|
|
116
|
+
) -> None:
|
|
117
|
+
with open("generations.jsonl", "w", encoding="utf-8") as output:
|
|
118
|
+
for case in load_cases(subset="core"):
|
|
119
|
+
attack_prompt = jailbreak_method(case.question)
|
|
120
|
+
response = query_victim(attack_prompt)
|
|
121
|
+
record = {
|
|
122
|
+
"id": case.id,
|
|
123
|
+
"response": response,
|
|
124
|
+
"method": "method-name",
|
|
125
|
+
"victim_model": "victim-model-id",
|
|
126
|
+
"metadata": {"attack_prompt": attack_prompt},
|
|
127
|
+
}
|
|
128
|
+
output.write(json.dumps(record, ensure_ascii=False) + "\n")
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# Supply the two callables from your existing jailbreak runner:
|
|
132
|
+
# generate_responses(my_jailbreak_method, my_victim_client.generate)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
The output of Step 1 is `generations.jsonl`, with one victim response per line:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{"id":"guidedbench-000","response":"...","method":"method-name","victim_model":"victim-model-id","metadata":{"attack_prompt":"..."}}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Every row must contain `response` plus one stable case identifier: `id`, `index`,
|
|
142
|
+
or the exact `question`. `method`, `victim_model`, and `metadata` are optional
|
|
143
|
+
and are copied into the final score records.
|
|
144
|
+
|
|
145
|
+
If your jailbreak runner consumes JSONL rather than Python objects, export the
|
|
146
|
+
pinned benchmark release first:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
guidedbench export cases.jsonl --subset core
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
No database is required. GuidedBench downloads the JSONL files from a pinned
|
|
153
|
+
Hugging Face commit on first use and then reuses the standard local Hub cache.
|
|
154
|
+
Neither this GitHub repository nor the Python wheel contains the benchmark
|
|
155
|
+
records. In CI, `HF_TOKEN` can provide access without an interactive login.
|
|
156
|
+
|
|
157
|
+
### Step 2: Score the generated responses with GuidedEval
|
|
158
|
+
|
|
159
|
+
GuidedEval is exposed through the `guidedbench evaluate` command and the
|
|
160
|
+
`GuidedBenchEvaluator` Python class. The most portable option is an
|
|
161
|
+
OpenAI-compatible judge endpoint, whether it is remote or served locally by
|
|
162
|
+
vLLM, SGLang, LM Studio, Ollama, llama.cpp, or another compatible server:
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
export JUDGE_API_KEY="not-needed"
|
|
166
|
+
|
|
167
|
+
guidedbench evaluate generations.jsonl \
|
|
168
|
+
--provider openai-compatible \
|
|
169
|
+
--model your-judge-model \
|
|
170
|
+
--base-url http://localhost:8000/v1 \
|
|
171
|
+
--api-key-env JUDGE_API_KEY \
|
|
172
|
+
--workers 8 \
|
|
173
|
+
--output scores.jsonl
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
The compatible backend uses `POST /chat/completions` by default. Add
|
|
177
|
+
`--api-style responses` when the endpoint implements the Responses API.
|
|
178
|
+
|
|
179
|
+
Native OpenAI and Anthropic judges are also available:
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
export OPENAI_API_KEY="..."
|
|
183
|
+
guidedbench evaluate generations.jsonl \
|
|
184
|
+
--provider openai \
|
|
185
|
+
--model YOUR_OPENAI_MODEL \
|
|
186
|
+
--api-key-env OPENAI_API_KEY \
|
|
187
|
+
--output scores.jsonl
|
|
188
|
+
|
|
189
|
+
export ANTHROPIC_API_KEY="..."
|
|
190
|
+
guidedbench evaluate generations.jsonl \
|
|
191
|
+
--provider anthropic \
|
|
192
|
+
--model YOUR_CLAUDE_MODEL \
|
|
193
|
+
--api-key-env ANTHROPIC_API_KEY \
|
|
194
|
+
--output scores.jsonl
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
Or load an open-source judge directly with Transformers:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
guidedbench evaluate generations.jsonl \
|
|
201
|
+
--provider transformers \
|
|
202
|
+
--model Qwen/Qwen3-4B-Instruct-2507 \
|
|
203
|
+
--workers 1 \
|
|
204
|
+
--output scores.jsonl
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
The Transformers backend uses the model's chat template and deterministic
|
|
208
|
+
generation (`do_sample=False`). Serving the same model through vLLM or SGLang
|
|
209
|
+
and using `openai-compatible` is usually faster for concurrent evaluation.
|
|
210
|
+
|
|
211
|
+
Each line in `scores.jsonl` contains the GuidedEval score from 0 to 1, every
|
|
212
|
+
guideline-level decision, the judge name, the raw judge output, benchmark
|
|
213
|
+
version metadata, and the optional Step 1 metadata. The command also prints the
|
|
214
|
+
mean score after a successful run. Keep each jailbreak-method/victim-model pair
|
|
215
|
+
in a separate output file when reporting aggregate results.
|
|
216
|
+
|
|
217
|
+
Remote judge requests can run concurrently without sharing a result file. Each
|
|
218
|
+
completed evaluation is persisted as an independent atomic checkpoint inside
|
|
219
|
+
`scores.jsonl.parts/` before the final JSONL is gathered. If a run stops midway,
|
|
220
|
+
rerun the same command: completed checkpoints are reused and only missing or
|
|
221
|
+
failed evaluations are retried.
|
|
222
|
+
|
|
223
|
+
## Repository contents
|
|
224
|
+
|
|
225
|
+
- [Hugging Face Dataset](https://huggingface.co/datasets/HRXUST/GuidedBench):
|
|
226
|
+
canonical `core` and `additional` JSONL splits, access form, data card, and
|
|
227
|
+
dataset license.
|
|
228
|
+
- [`src/guidedbench/`](src/guidedbench/): installable evaluator and provider
|
|
229
|
+
integrations. It downloads a pinned dataset revision when records are needed.
|
|
230
|
+
|
|
231
|
+
## Reproducibility
|
|
232
|
+
|
|
233
|
+
Report at least the GuidedBench version, judge provider and exact model id,
|
|
234
|
+
generation parameters, evaluator failures/refusals, and whether scores cover
|
|
235
|
+
the core set, additional set, or both. Do not compare aggregate scores produced
|
|
236
|
+
with different benchmark versions without disclosing the difference.
|
|
237
|
+
|
|
238
|
+
## Safety and licensing
|
|
239
|
+
|
|
240
|
+
This repository is intended for controlled AI-safety research. The benchmark
|
|
241
|
+
contains descriptions of harmful objectives and examples. Do not use it to
|
|
242
|
+
facilitate real-world harm.
|
|
243
|
+
|
|
244
|
+
The software is licensed under Apache-2.0. The separately distributed
|
|
245
|
+
GuidedBench dataset is licensed under CC BY 4.0; see its
|
|
246
|
+
[dataset license](https://huggingface.co/datasets/HRXUST/GuidedBench/blob/main/LICENSE).
|
|
247
|
+
|
|
248
|
+
## Citation
|
|
249
|
+
|
|
250
|
+
```bibtex
|
|
251
|
+
@inproceedings{huang2026guidedbench,
|
|
252
|
+
title = {{GuidedBench}: Measuring and Mitigating the Evaluation Discrepancies of In-the-wild {LLM} Jailbreak Methods},
|
|
253
|
+
author = {Ruixuan Huang and Xunguang Wang and Zongjie Li and Daoyuan Wu and Shuai Wang},
|
|
254
|
+
booktitle = {International Conference on Learning Representations},
|
|
255
|
+
year = {2026},
|
|
256
|
+
url = {https://openreview.net/forum?id=ZVg8y3ibyM}
|
|
257
|
+
}
|
|
258
|
+
```
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# GuidedBench
|
|
4
|
+
|
|
5
|
+
**Guideline-grounded evaluation for LLM jailbreak methods**
|
|
6
|
+
|
|
7
|
+
[Paper](https://openreview.net/forum?id=ZVg8y3ibyM) ·
|
|
8
|
+
[Project page](https://sproutnan.github.io/GuidedBench/) ·
|
|
9
|
+
[Dataset](https://huggingface.co/datasets/HRXUST/GuidedBench)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
GuidedBench evaluates whether a victim-model response fulfills the specific
|
|
14
|
+
harmful objective in a question. Every case includes verified, case-specific
|
|
15
|
+
entity and action guidelines, turning a holistic harmfulness judgment into a
|
|
16
|
+
set of explicit content checks.
|
|
17
|
+
|
|
18
|
+
The benchmark contains 200 English cases across 20 topics: a 180-case core set
|
|
19
|
+
and a 20-case, vendor-policy-dependent additional set. GuidedBench was accepted
|
|
20
|
+
as a poster at ICLR 2026.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install guidedbench
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Install the current GitHub version directly when needed:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
pip install "guidedbench @ git+https://github.com/SproutNan/GuidedBench.git"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Install only the judge backend you need:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install "guidedbench[openai]" # OpenAI and OpenAI-compatible APIs
|
|
38
|
+
pip install "guidedbench[anthropic]" # Claude Messages API
|
|
39
|
+
pip install "guidedbench[local]" # Local Hugging Face Transformers model
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Two-step workflow
|
|
43
|
+
|
|
44
|
+
GuidedBench separates jailbreak generation from evaluation. Your jailbreak
|
|
45
|
+
runner produces victim-model responses in Step 1; GuidedEval scores those saved
|
|
46
|
+
responses in Step 2. GuidedBench does not require a particular attack framework
|
|
47
|
+
or victim-model provider.
|
|
48
|
+
|
|
49
|
+
### Step 1: Run your jailbreak method on GuidedBench
|
|
50
|
+
|
|
51
|
+
First request access on the
|
|
52
|
+
[GuidedBench dataset page](https://huggingface.co/datasets/HRXUST/GuidedBench),
|
|
53
|
+
then authenticate once:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
hf auth login
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Load the core cases and pass each `question` through your existing jailbreak
|
|
60
|
+
method and victim-model client:
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
import json
|
|
64
|
+
from collections.abc import Callable
|
|
65
|
+
|
|
66
|
+
from guidedbench import load_cases
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def generate_responses(
|
|
70
|
+
jailbreak_method: Callable[[str], str],
|
|
71
|
+
query_victim: Callable[[str], str],
|
|
72
|
+
) -> None:
|
|
73
|
+
with open("generations.jsonl", "w", encoding="utf-8") as output:
|
|
74
|
+
for case in load_cases(subset="core"):
|
|
75
|
+
attack_prompt = jailbreak_method(case.question)
|
|
76
|
+
response = query_victim(attack_prompt)
|
|
77
|
+
record = {
|
|
78
|
+
"id": case.id,
|
|
79
|
+
"response": response,
|
|
80
|
+
"method": "method-name",
|
|
81
|
+
"victim_model": "victim-model-id",
|
|
82
|
+
"metadata": {"attack_prompt": attack_prompt},
|
|
83
|
+
}
|
|
84
|
+
output.write(json.dumps(record, ensure_ascii=False) + "\n")
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# Supply the two callables from your existing jailbreak runner:
|
|
88
|
+
# generate_responses(my_jailbreak_method, my_victim_client.generate)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
The output of Step 1 is `generations.jsonl`, with one victim response per line:
|
|
92
|
+
|
|
93
|
+
```json
|
|
94
|
+
{"id":"guidedbench-000","response":"...","method":"method-name","victim_model":"victim-model-id","metadata":{"attack_prompt":"..."}}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Every row must contain `response` plus one stable case identifier: `id`, `index`,
|
|
98
|
+
or the exact `question`. `method`, `victim_model`, and `metadata` are optional
|
|
99
|
+
and are copied into the final score records.
|
|
100
|
+
|
|
101
|
+
If your jailbreak runner consumes JSONL rather than Python objects, export the
|
|
102
|
+
pinned benchmark release first:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
guidedbench export cases.jsonl --subset core
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
No database is required. GuidedBench downloads the JSONL files from a pinned
|
|
109
|
+
Hugging Face commit on first use and then reuses the standard local Hub cache.
|
|
110
|
+
Neither this GitHub repository nor the Python wheel contains the benchmark
|
|
111
|
+
records. In CI, `HF_TOKEN` can provide access without an interactive login.
|
|
112
|
+
|
|
113
|
+
### Step 2: Score the generated responses with GuidedEval
|
|
114
|
+
|
|
115
|
+
GuidedEval is exposed through the `guidedbench evaluate` command and the
|
|
116
|
+
`GuidedBenchEvaluator` Python class. The most portable option is an
|
|
117
|
+
OpenAI-compatible judge endpoint, whether it is remote or served locally by
|
|
118
|
+
vLLM, SGLang, LM Studio, Ollama, llama.cpp, or another compatible server:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
export JUDGE_API_KEY="not-needed"
|
|
122
|
+
|
|
123
|
+
guidedbench evaluate generations.jsonl \
|
|
124
|
+
--provider openai-compatible \
|
|
125
|
+
--model your-judge-model \
|
|
126
|
+
--base-url http://localhost:8000/v1 \
|
|
127
|
+
--api-key-env JUDGE_API_KEY \
|
|
128
|
+
--workers 8 \
|
|
129
|
+
--output scores.jsonl
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
The compatible backend uses `POST /chat/completions` by default. Add
|
|
133
|
+
`--api-style responses` when the endpoint implements the Responses API.
|
|
134
|
+
|
|
135
|
+
Native OpenAI and Anthropic judges are also available:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
export OPENAI_API_KEY="..."
|
|
139
|
+
guidedbench evaluate generations.jsonl \
|
|
140
|
+
--provider openai \
|
|
141
|
+
--model YOUR_OPENAI_MODEL \
|
|
142
|
+
--api-key-env OPENAI_API_KEY \
|
|
143
|
+
--output scores.jsonl
|
|
144
|
+
|
|
145
|
+
export ANTHROPIC_API_KEY="..."
|
|
146
|
+
guidedbench evaluate generations.jsonl \
|
|
147
|
+
--provider anthropic \
|
|
148
|
+
--model YOUR_CLAUDE_MODEL \
|
|
149
|
+
--api-key-env ANTHROPIC_API_KEY \
|
|
150
|
+
--output scores.jsonl
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Or load an open-source judge directly with Transformers:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
guidedbench evaluate generations.jsonl \
|
|
157
|
+
--provider transformers \
|
|
158
|
+
--model Qwen/Qwen3-4B-Instruct-2507 \
|
|
159
|
+
--workers 1 \
|
|
160
|
+
--output scores.jsonl
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The Transformers backend uses the model's chat template and deterministic
|
|
164
|
+
generation (`do_sample=False`). Serving the same model through vLLM or SGLang
|
|
165
|
+
and using `openai-compatible` is usually faster for concurrent evaluation.
|
|
166
|
+
|
|
167
|
+
Each line in `scores.jsonl` contains the GuidedEval score from 0 to 1, every
|
|
168
|
+
guideline-level decision, the judge name, the raw judge output, benchmark
|
|
169
|
+
version metadata, and the optional Step 1 metadata. The command also prints the
|
|
170
|
+
mean score after a successful run. Keep each jailbreak-method/victim-model pair
|
|
171
|
+
in a separate output file when reporting aggregate results.
|
|
172
|
+
|
|
173
|
+
Remote judge requests can run concurrently without sharing a result file. Each
|
|
174
|
+
completed evaluation is persisted as an independent atomic checkpoint inside
|
|
175
|
+
`scores.jsonl.parts/` before the final JSONL is gathered. If a run stops midway,
|
|
176
|
+
rerun the same command: completed checkpoints are reused and only missing or
|
|
177
|
+
failed evaluations are retried.
|
|
178
|
+
|
|
179
|
+
## Repository contents
|
|
180
|
+
|
|
181
|
+
- [Hugging Face Dataset](https://huggingface.co/datasets/HRXUST/GuidedBench):
|
|
182
|
+
canonical `core` and `additional` JSONL splits, access form, data card, and
|
|
183
|
+
dataset license.
|
|
184
|
+
- [`src/guidedbench/`](src/guidedbench/): installable evaluator and provider
|
|
185
|
+
integrations. It downloads a pinned dataset revision when records are needed.
|
|
186
|
+
|
|
187
|
+
## Reproducibility
|
|
188
|
+
|
|
189
|
+
Report at least the GuidedBench version, judge provider and exact model id,
|
|
190
|
+
generation parameters, evaluator failures/refusals, and whether scores cover
|
|
191
|
+
the core set, additional set, or both. Do not compare aggregate scores produced
|
|
192
|
+
with different benchmark versions without disclosing the difference.
|
|
193
|
+
|
|
194
|
+
## Safety and licensing
|
|
195
|
+
|
|
196
|
+
This repository is intended for controlled AI-safety research. The benchmark
|
|
197
|
+
contains descriptions of harmful objectives and examples. Do not use it to
|
|
198
|
+
facilitate real-world harm.
|
|
199
|
+
|
|
200
|
+
The software is licensed under Apache-2.0. The separately distributed
|
|
201
|
+
GuidedBench dataset is licensed under CC BY 4.0; see its
|
|
202
|
+
[dataset license](https://huggingface.co/datasets/HRXUST/GuidedBench/blob/main/LICENSE).
|
|
203
|
+
|
|
204
|
+
## Citation
|
|
205
|
+
|
|
206
|
+
```bibtex
|
|
207
|
+
@inproceedings{huang2026guidedbench,
|
|
208
|
+
title = {{GuidedBench}: Measuring and Mitigating the Evaluation Discrepancies of In-the-wild {LLM} Jailbreak Methods},
|
|
209
|
+
author = {Ruixuan Huang and Xunguang Wang and Zongjie Li and Daoyuan Wu and Shuai Wang},
|
|
210
|
+
booktitle = {International Conference on Learning Representations},
|
|
211
|
+
year = {2026},
|
|
212
|
+
url = {https://openreview.net/forum?id=ZVg8y3ibyM}
|
|
213
|
+
}
|
|
214
|
+
```
|