|
41 | 41 | "id": "1", |
42 | 42 | "metadata": {}, |
43 | 43 | "outputs": [ |
44 | | - { |
45 | | - "name": "stderr", |
46 | | - "output_type": "stream", |
47 | | - "text": [ |
48 | | - "./git/copilot-worktrees/PyRIT/romanlutz-cautious-meme/.venv/Lib/site-packages/confusables/__init__.py:46: SyntaxWarning: \"\\*\" is an invalid escape sequence. Such sequences will not work in the future. Did you mean \"\\\\*\"? A raw string is also an option.\n", |
49 | | - " space_regex = \"[\\*_~|`\\-\\.]*\" if include_character_padding else ''\n" |
50 | | - ] |
51 | | - }, |
52 | 44 | { |
53 | 45 | "name": "stdout", |
54 | 46 | "output_type": "stream", |
|
69 | 61 | "name": "stdout", |
70 | 62 | "output_type": "stream", |
71 | 63 | "text": [ |
72 | | - "Running model: Qwen/Qwen2-0.5B-Instruct\n" |
| 64 | + "Running model: HuggingFaceTB/SmolLM2-135M-Instruct\n" |
73 | 65 | ] |
74 | 66 | }, |
75 | 67 | { |
76 | 68 | "data": { |
77 | 69 | "application/vnd.jupyter.widget-view+json": { |
78 | | - "model_id": "2cb1ed2b5d6c4fa98456d1c217564010", |
| 70 | + "model_id": "5ccc9dc2fe35480bbe25f5b8fd6bd50a", |
79 | 71 | "version_major": 2, |
80 | 72 | "version_minor": 0 |
81 | 73 | }, |
|
89 | 81 | { |
90 | 82 | "data": { |
91 | 83 | "application/vnd.jupyter.widget-view+json": { |
92 | | - "model_id": "76523dac8fe04b87921ad444853385c3", |
| 84 | + "model_id": "3fc4b0633f704408aa0ca3a28d38bc1e", |
93 | 85 | "version_major": 2, |
94 | 86 | "version_minor": 0 |
95 | 87 | }, |
96 | 88 | "text/plain": [ |
97 | | - "Fetching 10 files: 0%| | 0/10 [00:00<?, ?it/s]" |
| 89 | + "Fetching 25 files: 0%| | 0/25 [00:00<?, ?it/s]" |
98 | 90 | ] |
99 | 91 | }, |
100 | 92 | "metadata": {}, |
|
103 | 95 | { |
104 | 96 | "data": { |
105 | 97 | "application/vnd.jupyter.widget-view+json": { |
106 | | - "model_id": "650a316e795b4e84abdc46b06bc79cc1", |
| 98 | + "model_id": "73eb775a3c3a419fbc79d3f3ce7d96ef", |
107 | 99 | "version_major": 2, |
108 | 100 | "version_minor": 0 |
109 | 101 | }, |
110 | 102 | "text/plain": [ |
111 | | - "Loading weights: 0%| | 0/290 [00:00<?, ?it/s]" |
| 103 | + "Loading weights: 0%| | 0/272 [00:00<?, ?it/s]" |
112 | 104 | ] |
113 | 105 | }, |
114 | 106 | "metadata": {}, |
|
118 | 110 | "name": "stdout", |
119 | 111 | "output_type": "stream", |
120 | 112 | "text": [ |
121 | | - "Average response time for Qwen/Qwen2-0.5B-Instruct: 7.43 seconds\n", |
| 113 | + "Average response time for HuggingFaceTB/SmolLM2-135M-Instruct: 2.59 seconds\n", |
122 | 114 | "\n", |
123 | 115 | "\n", |
124 | 116 | "\u001b[33m════════════════════════════════════════════════════════════════════════════════════════════════════\u001b[0m\n", |
|
130 | 122 | "\u001b[1m 📋 Basic Information\u001b[0m\n", |
131 | 123 | "\u001b[36m • Objective: What is 3*3? Give me the solution.\u001b[0m\n", |
132 | 124 | "\u001b[36m • Attack Type: PromptSendingAttack\u001b[0m\n", |
133 | | - "\u001b[36m • Conversation ID: 3e01b421-e41b-4c47-a51b-ea192f7cdb24\u001b[0m\n", |
| 125 | + "\u001b[36m • Conversation ID: 84048a6c-960d-483d-b54d-b19d8e0e3eb1\u001b[0m\n", |
134 | 126 | "\n", |
135 | 127 | "\u001b[1m ⚡ Execution Metrics\u001b[0m\n", |
136 | 128 | "\u001b[32m • Turns Executed: 1\u001b[0m\n", |
137 | | - "\u001b[32m • Execution Time: 12.20s\u001b[0m\n", |
| 129 | + "\u001b[32m • Execution Time: 4.61s\u001b[0m\n", |
138 | 130 | "\n", |
139 | 131 | "\u001b[1m 🎯 Outcome\u001b[0m\n", |
140 | 132 | "\u001b[33m • Status: ❓ UNDETERMINED\u001b[0m\n", |
|
151 | 143 | "\u001b[33m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n", |
152 | 144 | "\u001b[1m\u001b[33m🔸 ASSISTANT\u001b[0m\n", |
153 | 145 | "\u001b[33m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n", |
154 | | - "\u001b[33m The answer to \"What is 3 * 3?\" is 9.\u001b[0m\n", |
155 | | - "\u001b[33m \u001b[0m\n", |
156 | | - "\u001b[33m This is because the product of two numbers, where the first number (\u001b[0m\n", |
| 146 | + "\u001b[33m 3*3 = 9\u001b[0m\n", |
157 | 147 | "\n", |
158 | 148 | "\u001b[34m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n", |
159 | 149 | "\n", |
160 | 150 | "\u001b[2m\u001b[37m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n", |
161 | | - "\u001b[2m\u001b[37m Report generated at: 2026-07-16 05:18:39 UTC \u001b[0m\n", |
| 151 | + "\u001b[2m\u001b[37m Report generated at: 2026-07-13 23:25:00 UTC \u001b[0m\n", |
162 | 152 | "\n", |
163 | 153 | "\u001b[33m════════════════════════════════════════════════════════════════════════════════════════════════════\u001b[0m\n", |
164 | 154 | "\u001b[1m\u001b[33m ❓ ATTACK RESULT: UNDETERMINED ❓ \u001b[0m\n", |
|
169 | 159 | "\u001b[1m 📋 Basic Information\u001b[0m\n", |
170 | 160 | "\u001b[36m • Objective: What is 4*4? Give me the solution.\u001b[0m\n", |
171 | 161 | "\u001b[36m • Attack Type: PromptSendingAttack\u001b[0m\n", |
172 | | - "\u001b[36m • Conversation ID: 76b845b6-0e72-4a80-a793-09652c4d7405\u001b[0m\n", |
| 162 | + "\u001b[36m • Conversation ID: bc388b83-e4d3-441b-80f1-dc8d433bc314\u001b[0m\n", |
173 | 163 | "\n", |
174 | 164 | "\u001b[1m ⚡ Execution Metrics\u001b[0m\n", |
175 | 165 | "\u001b[32m • Turns Executed: 1\u001b[0m\n", |
176 | | - "\u001b[32m • Execution Time: 2.63s\u001b[0m\n", |
| 166 | + "\u001b[32m • Execution Time: 557ms\u001b[0m\n", |
177 | 167 | "\n", |
178 | 168 | "\u001b[1m 🎯 Outcome\u001b[0m\n", |
179 | 169 | "\u001b[33m • Status: ❓ UNDETERMINED\u001b[0m\n", |
|
190 | 180 | "\u001b[33m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n", |
191 | 181 | "\u001b[1m\u001b[33m🔸 ASSISTANT\u001b[0m\n", |
192 | 182 | "\u001b[33m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n", |
193 | | - "\u001b[33m The result of multiplying 4 by itself four times is:\u001b[0m\n", |
194 | | - "\u001b[33m 256.\u001b[0m\n", |
195 | | - "\u001b[33m \u001b[0m\n", |
196 | | - "\u001b[33m Here's why:\u001b[0m\n", |
197 | | - "\u001b[33m First, we multiply 4 and\u001b[0m\n", |
| 183 | + "\u001b[33m 4*4 = 16.\u001b[0m\n", |
198 | 184 | "\n", |
199 | 185 | "\u001b[34m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n", |
200 | 186 | "\n", |
201 | 187 | "\u001b[2m\u001b[37m────────────────────────────────────────────────────────────────────────────────────────────────────\u001b[0m\n", |
202 | | - "\u001b[2m\u001b[37m Report generated at: 2026-07-16 05:18:39 UTC \u001b[0m\n", |
203 | | - "Qwen/Qwen2-0.5B-Instruct: 7.43 seconds\n" |
| 188 | + "\u001b[2m\u001b[37m Report generated at: 2026-07-13 23:25:00 UTC \u001b[0m\n", |
| 189 | + "HuggingFaceTB/SmolLM2-135M-Instruct: 2.59 seconds\n" |
204 | 190 | ] |
205 | 191 | } |
206 | 192 | ], |
|
218 | 204 | "await initialize_pyrit_async(memory_db_type=IN_MEMORY) # type: ignore\n", |
219 | 205 | "\n", |
220 | 206 | "# models to test\n", |
221 | | - "model_id = \"Qwen/Qwen2-0.5B-Instruct\"\n", |
| 207 | + "model_id = \"HuggingFaceTB/SmolLM2-135M-Instruct\"\n", |
222 | 208 | "\n", |
223 | 209 | "# List of prompts to send\n", |
224 | 210 | "prompt_list = [\"What is 3*3? Give me the solution.\", \"What is 4*4? Give me the solution.\"]\n", |
|
228 | 214 | "\n", |
229 | 215 | "print(f\"Running model: {model_id}\")\n", |
230 | 216 | "\n", |
231 | | - "try:\n", |
232 | | - " # Initialize HuggingFaceChatTarget with the current model\n", |
233 | | - " target = HuggingFaceChatTarget(model_id=model_id, use_cuda=False, tensor_format=\"pt\", max_new_tokens=30)\n", |
234 | | - "\n", |
235 | | - " # Initialize the attack\n", |
236 | | - " attack = PromptSendingAttack(objective_target=target)\n", |
| 217 | + "# Initialize HuggingFaceChatTarget with the current model\n", |
| 218 | + "target = HuggingFaceChatTarget(model_id=model_id, use_cuda=False, tensor_format=\"pt\", max_new_tokens=30)\n", |
237 | 219 | "\n", |
238 | | - " # Record start time\n", |
239 | | - " start_time = time.time()\n", |
| 220 | + "# Initialize the attack\n", |
| 221 | + "attack = PromptSendingAttack(objective_target=target)\n", |
240 | 222 | "\n", |
241 | | - " # Send prompts asynchronously\n", |
242 | | - " responses = await AttackExecutor().execute_attack_async( # type: ignore\n", |
243 | | - " attack=attack,\n", |
244 | | - " objectives=prompt_list,\n", |
245 | | - " )\n", |
| 223 | + "# Record start time\n", |
| 224 | + "start_time = time.time()\n", |
246 | 225 | "\n", |
247 | | - " # Record end time\n", |
248 | | - " end_time = time.time()\n", |
| 226 | + "# Send prompts asynchronously\n", |
| 227 | + "responses = await AttackExecutor().execute_attack_async( # type: ignore\n", |
| 228 | + " attack=attack,\n", |
| 229 | + " objectives=prompt_list,\n", |
| 230 | + ")\n", |
249 | 231 | "\n", |
250 | | - " # Calculate total and average response time\n", |
251 | | - " total_time = end_time - start_time\n", |
252 | | - " avg_time = total_time / len(prompt_list)\n", |
253 | | - " model_times[model_id] = avg_time\n", |
| 232 | + "# Record end time\n", |
| 233 | + "end_time = time.time()\n", |
254 | 234 | "\n", |
255 | | - " print(f\"Average response time for {model_id}: {avg_time:.2f} seconds\\n\")\n", |
| 235 | + "# Calculate total and average response time\n", |
| 236 | + "total_time = end_time - start_time\n", |
| 237 | + "avg_time = total_time / len(prompt_list)\n", |
| 238 | + "model_times[model_id] = avg_time\n", |
256 | 239 | "\n", |
257 | | - " # Print the conversations\n", |
258 | | - " for result in responses:\n", |
259 | | - " await output_attack_async(result)\n", |
| 240 | + "print(f\"Average response time for {model_id}: {avg_time:.2f} seconds\\n\")\n", |
260 | 241 | "\n", |
261 | | - "except Exception as e:\n", |
262 | | - " print(f\"An error occurred with model {model_id}: {e}\\n\")\n", |
263 | | - " model_times[model_id] = None\n", |
| 242 | + "# Print the conversations\n", |
| 243 | + "for result in responses:\n", |
| 244 | + " await output_attack_async(result)\n", |
264 | 245 | "\n", |
265 | 246 | "# Print the model average time\n", |
266 | | - "if model_times[model_id] is not None:\n", |
267 | | - " print(f\"{model_id}: {model_times[model_id]:.2f} seconds\")\n", |
268 | | - "else:\n", |
269 | | - " print(f\"{model_id}: Error occurred, no average time calculated.\")" |
| 247 | + "print(f\"{model_id}: {model_times[model_id]:.2f} seconds\")" |
270 | 248 | ] |
271 | 249 | } |
272 | 250 | ], |
273 | 251 | "metadata": { |
274 | 252 | "jupytext": { |
275 | | - "cell_metadata_filter": "-all" |
| 253 | + "cell_metadata_filter": "-all", |
| 254 | + "main_language": "python" |
276 | 255 | }, |
277 | 256 | "language_info": { |
278 | 257 | "codemirror_mode": { |
|
284 | 263 | "name": "python", |
285 | 264 | "nbconvert_exporter": "python", |
286 | 265 | "pygments_lexer": "ipython3", |
287 | | - "version": "3.14.4" |
| 266 | + "version": "3.12.12" |
288 | 267 | } |
289 | 268 | }, |
290 | 269 | "nbformat": 4, |
|
0 commit comments