You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
MAINT: Standardize system prompts on prepended_conversation (#2040)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Roman Lutz <romanlutz13@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: doc/code/executor/3_attack_configuration.py
+33-5Lines changed: 33 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@
21
21
# |---|---|
22
22
# | `objective` | What you are trying to get the **objective target** (the system under test) to do. Drives scoring and multi-turn adversarial prompts. |
23
23
# | `memory_labels` | A `dict[str, str]` tagged onto every prompt/response, so you can filter this run later in memory. |
24
-
# | `prepended_conversation` | A list of `Message`s to seed the conversation before the attack's own turns (system prompt, prior history). |
24
+
# | `prepended_conversation` | A list of `Message`s to seed the conversation before the attack's own turns. This is also where the objective target's **system prompt** goes — `Message.from_system_prompt(...)` builds one (see below). |
25
25
# | `next_message` | The exact next message to send, instead of letting the attack derive it from the objective. Useful for multimodal or pre-built seeds. |
26
26
#
27
27
# Construction-time configuration objects — **adversarial**, **scoring**, and **converter** — are
Copy file name to clipboardExpand all lines: doc/code/targets/11_message_normalizer.ipynb
+11-2Lines changed: 11 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -178,7 +178,13 @@
178
178
"source": [
179
179
"## GenericSystemSquashNormalizer\n",
180
180
"\n",
181
-
"Some models don't support system messages. The `GenericSystemSquashNormalizer` merges the system message into the first user message using a standardized instruction format.\n",
181
+
"Some models don't support system messages. The `GenericSystemSquashNormalizer` combines consecutive\n",
182
+
"system messages in their original order and merges them into the user message immediately following\n",
183
+
"them. If no user immediately follows, it converts the system messages to a user message in their\n",
184
+
"original position.\n",
185
+
"\n",
186
+
"For example, `system: Policy`, `system: Persona`, `user: Question` becomes one user message containing\n",
187
+
"the Policy and Persona instructions followed by the Question.\n",
182
188
"\n",
183
189
"The format is:\n",
184
190
"```\n",
@@ -359,7 +365,7 @@
359
365
"The `TokenizerTemplateNormalizer` supports different strategies for handling system messages:\n",
360
366
"\n",
361
367
"- **`keep`**: Pass system messages as-is (default)\n",
362
-
"- **`squash`**: Merge system into first user message using `GenericSystemSquashNormalizer`\n",
368
+
"- **`squash`**: Merge system messages into the following user message using `GenericSystemSquashNormalizer`\n",
363
369
"- **`ignore`**: Drop system messages entirely\n",
364
370
"- **`developer`**: Change system role to developer role (for newer OpenAI models)"
Copy file name to clipboardExpand all lines: doc/code/targets/11_message_normalizer.py
+9-4Lines changed: 9 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
# extension: .py
6
6
# format_name: percent
7
7
# format_version: '1.3'
8
-
# jupytext_version: 1.19.0
8
+
# jupytext_version: 1.19.4
9
9
# ---
10
10
11
11
# %% [markdown]
@@ -82,7 +82,13 @@
82
82
# %% [markdown]
83
83
# ## GenericSystemSquashNormalizer
84
84
#
85
-
# Some models don't support system messages. The `GenericSystemSquashNormalizer` merges the system message into the first user message using a standardized instruction format.
85
+
# Some models don't support system messages. The `GenericSystemSquashNormalizer` combines consecutive
86
+
# system messages in their original order and merges them into the user message immediately following
87
+
# them. If no user immediately follows, it converts the system messages to a user message in their
88
+
# original position.
89
+
#
90
+
# For example, `system: Policy`, `system: Persona`, `user: Question` becomes one user message containing
91
+
# the Policy and Persona instructions followed by the Question.
86
92
#
87
93
# The format is:
88
94
# ```
@@ -171,7 +177,7 @@
171
177
# The `TokenizerTemplateNormalizer` supports different strategies for handling system messages:
172
178
#
173
179
# - **`keep`**: Pass system messages as-is (default)
174
-
# - **`squash`**: Merge system into first user message using `GenericSystemSquashNormalizer`
180
+
# - **`squash`**: Merge system messages into the following user message using `GenericSystemSquashNormalizer`
175
181
# - **`ignore`**: Drop system messages entirely
176
182
# - **`developer`**: Change system role to developer role (for newer OpenAI models)
177
183
@@ -203,7 +209,6 @@
203
209
# You can create custom normalizers by extending the base classes.
0 commit comments