Spaces:
Running
Running
johnsonhung906
commited on
Commit
·
6792367
1
Parent(s):
7bef68d
update style and toggle demos
Browse files- demo.html +94 -78
- demo_results/normal_5.png +0 -0
- index.html +221 -222
demo.html
CHANGED
@@ -3,111 +3,127 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
-
<title>Image Gallery</title>
|
7 |
<style>
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
13 |
}
|
14 |
|
15 |
.image-gallery {
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
}
|
21 |
|
22 |
.image-gallery img {
|
23 |
-
width:
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Add shadow to images */
|
28 |
-
display: none; /* Initially hide all images */
|
29 |
}
|
30 |
|
31 |
-
.
|
32 |
-
|
33 |
-
margin-top: 20px;
|
34 |
}
|
35 |
|
36 |
-
.
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
background-color: #dc3545; /* Red for Attack Data */
|
48 |
}
|
49 |
|
50 |
-
.
|
51 |
-
|
52 |
-
margin: 5px;
|
53 |
-
border: none;
|
54 |
-
color: white;
|
55 |
-
cursor: pointer;
|
56 |
-
border-radius: 5px;
|
57 |
-
font-size: 1em; /* Increased font size */
|
58 |
-
transition: background-color 0.3s, transform 0.3s; /* Smooth transitions */
|
59 |
}
|
60 |
|
61 |
-
.
|
62 |
-
|
63 |
}
|
64 |
|
65 |
-
.
|
66 |
-
|
67 |
}
|
68 |
|
69 |
-
.
|
70 |
-
|
|
|
|
|
71 |
}
|
72 |
</style>
|
73 |
</head>
|
74 |
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
<script>
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
//
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
//
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
-
|
108 |
-
// Initial display settings
|
109 |
-
document.getElementById('normalImage1').style.display = 'block'; // Show first normal image
|
110 |
-
document.getElementById('attackImage1').style.display = 'block'; // Show first attack image
|
111 |
</script>
|
112 |
</body>
|
113 |
</html>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Image Gallery Navigation</title>
|
7 |
<style>
|
8 |
+
.image-gallery-container {
|
9 |
+
position: relative;
|
10 |
+
display: flex;
|
11 |
+
justify-content: center;
|
12 |
+
align-items: center;
|
13 |
+
margin: 20px auto;
|
14 |
}
|
15 |
|
16 |
.image-gallery {
|
17 |
+
width: 800px; /* Increased width */
|
18 |
+
max-height: 600px; /* Increased height */
|
19 |
+
overflow: hidden;
|
20 |
+
position: relative;
|
21 |
}
|
22 |
|
23 |
.image-gallery img {
|
24 |
+
width: 100%;
|
25 |
+
height: auto;
|
26 |
+
border-radius: 10px;
|
27 |
+
display: none;
|
|
|
|
|
28 |
}
|
29 |
|
30 |
+
.image-gallery img.active {
|
31 |
+
display: block;
|
|
|
32 |
}
|
33 |
|
34 |
+
.arrow {
|
35 |
+
cursor: pointer;
|
36 |
+
position: absolute;
|
37 |
+
top: 50%;
|
38 |
+
transform: translateY(-50%);
|
39 |
+
font-size: 2.5em;
|
40 |
+
color: #444; /* Darker color */
|
41 |
+
padding: 5px 15px;
|
42 |
+
transition: color 0.3s;
|
43 |
+
user-select: none;
|
44 |
+
transform: scaleX(0.7);
|
|
|
45 |
}
|
46 |
|
47 |
+
.arrow:hover {
|
48 |
+
color: #007bff; /* Color on hover */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
|
51 |
+
.left-arrow {
|
52 |
+
left: 20px; /* Adjusted position */
|
53 |
}
|
54 |
|
55 |
+
.right-arrow {
|
56 |
+
right: 20px; /* Adjusted position */
|
57 |
}
|
58 |
|
59 |
+
.group-title {
|
60 |
+
font-weight: bold;
|
61 |
+
margin-top: 30px;
|
62 |
+
font-size: 1.2em;
|
63 |
}
|
64 |
</style>
|
65 |
</head>
|
66 |
<body>
|
67 |
+
<div class="image-gallery-container normal-gallery">
|
68 |
+
<span class="arrow left-arrow" onclick="navigateImages('normal', -1)"><</span>
|
69 |
+
<div class="image-gallery">
|
70 |
+
<img id="normalImage1" src="./demo_results/normal_1.png" class="active" alt="Normal Image 1">
|
71 |
+
<img id="normalImage2" src="./demo_results/normal_2.png" alt="Normal Image 2">
|
72 |
+
<img id="normalImage3" src="./demo_results/normal_3.png" alt="Normal Image 3">
|
73 |
+
<img id="normalImage4" src="./demo_results/normal_4.png" alt="Normal Image 4">
|
74 |
+
</div>
|
75 |
+
<span class="arrow right-arrow" onclick="navigateImages('normal', 1)">></span>
|
76 |
+
</div>
|
77 |
|
78 |
+
<div class="image-gallery-container attack-gallery">
|
79 |
+
<span class="arrow left-arrow" onclick="navigateImages('attack', -1)"><</span>
|
80 |
+
<div class="image-gallery">
|
81 |
+
<img id="attackImage1" src="./demo_results/attack_1.png" class="active" alt="Attack Image 1">
|
82 |
+
<img id="attackImage2" src="./demo_results/attack_2.png" alt="Attack Image 2">
|
83 |
+
<img id="attackImage3" src="./demo_results/attack_3.png" alt="Attack Image 3">
|
84 |
+
<img id="attackImage4" src="./demo_results/attack_4.png" alt="Attack Image 4">
|
85 |
+
</div>
|
86 |
+
<span class="arrow right-arrow" onclick="navigateImages('attack', 1)">></span>
|
87 |
+
</div>
|
88 |
|
89 |
<script>
|
90 |
+
let normalIndex = 0;
|
91 |
+
let attackIndex = 0;
|
92 |
+
|
93 |
+
function navigateImages(type, direction) {
|
94 |
+
let images;
|
95 |
+
let currentIndex;
|
96 |
+
|
97 |
+
// Determine which set of images to target and the current index
|
98 |
+
if (type === 'normal') {
|
99 |
+
images = document.querySelectorAll('.normal-gallery .image-gallery img');
|
100 |
+
currentIndex = normalIndex;
|
101 |
+
} else if (type === 'attack') {
|
102 |
+
images = document.querySelectorAll('.attack-gallery .image-gallery img');
|
103 |
+
currentIndex = attackIndex;
|
104 |
+
}
|
105 |
+
|
106 |
+
// Check if images were found to avoid accessing undefined elements
|
107 |
+
if (images && images.length > 0) {
|
108 |
+
// Hide current image
|
109 |
+
images[currentIndex].classList.remove('active');
|
110 |
+
|
111 |
+
// Calculate new index (modulo ensures cycling)
|
112 |
+
currentIndex = (currentIndex + direction + images.length) % images.length;
|
113 |
+
|
114 |
+
// Show new image
|
115 |
+
images[currentIndex].classList.add('active');
|
116 |
+
|
117 |
+
// Update index tracker
|
118 |
+
if (type === 'normal') {
|
119 |
+
normalIndex = currentIndex;
|
120 |
+
} else if (type === 'attack') {
|
121 |
+
attackIndex = currentIndex;
|
122 |
+
}
|
123 |
+
} else {
|
124 |
+
console.error("No images found for type:", type);
|
125 |
+
}
|
126 |
}
|
|
|
|
|
|
|
|
|
127 |
</script>
|
128 |
</body>
|
129 |
</html>
|
demo_results/normal_5.png
ADDED
index.html
CHANGED
@@ -3,27 +3,28 @@
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
|
6 |
-
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
7 |
-
<title>Attention Tracker | Attention Tracker: Detecting Prompt Injection Attacks in LLMs </title>
|
8 |
-
<meta property="og:title" content="Gradient Cuff" />
|
9 |
-
<meta property="og:locale" content="en_US" />
|
10 |
-
<meta name="description" content="Detecting Prompt Injection Attacks in LLMs using attention" />
|
11 |
-
<meta property="og:description" content="Detecting Prompt Injection Attacks in LLMs using attention" />
|
12 |
-
<script type="application/ld+json">
|
13 |
-
{"@context":"https://schema.org","@type":"WebSite","description":"Detecting Jailbreak Attacks on Large Language Models by Exploring Refusal Loss Landscapes","headline":"Gradient Cuff","name":"Gradient Cuff","url":"https://huggingface.co/spaces/gregH/Gradient Cuff"}</script>
|
14 |
-
<!-- End Jekyll SEO tag -->
|
15 |
-
|
16 |
-
<link rel="preconnect" href="https://fonts.gstatic.com">
|
17 |
<link rel="preload" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap" as="style" type="text/css" crossorigin>
|
18 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
19 |
<meta name="theme-color" content="#157878">
|
20 |
-
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
21 |
|
22 |
<link rel="stylesheet" href="assets/css/bootstrap/bootstrap.min.css?v=90447f115a006bc45b738d9592069468b20e2551">
|
23 |
<link rel="stylesheet" href="assets/css/style.css?v=90447f115a006bc45b738d9592069468b20e2551">
|
24 |
<!-- start custom head snippets, customize with your own _includes/head-custom.html file -->
|
25 |
<link rel="stylesheet" href="assets/css/custom_style.css?v=90447f115a006bc45b738d9592069468b20e2551">
|
26 |
-
|
|
|
27 |
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
|
28 |
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
29 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
|
@@ -31,126 +32,132 @@
|
|
31 |
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
|
32 |
<link rel="stylesheet" href="/resources/demos/style.css">
|
33 |
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
|
34 |
-
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
<script>
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
//
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
//
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
-
|
66 |
-
// Initial display settings
|
67 |
-
document.getElementById('normalImage1').style.display = 'block'; // Show first normal image
|
68 |
-
document.getElementById('attackImage1').style.display = 'block'; // Show first attack image
|
69 |
</script>
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
<!-- for mathjax support -->
|
75 |
-
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
|
76 |
-
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
77 |
-
<!-- end custom head snippets -->
|
78 |
<style>
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
85 |
|
86 |
.image-gallery {
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
|
|
|
|
91 |
}
|
92 |
|
93 |
.image-gallery img {
|
94 |
-
width: 100%;
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Add shadow to images */
|
99 |
-
display: none; /* Initially hide all images */
|
100 |
}
|
101 |
|
102 |
-
.
|
103 |
-
|
104 |
-
margin-top: 20px;
|
105 |
}
|
106 |
|
107 |
-
.
|
108 |
-
|
109 |
-
|
110 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
}
|
112 |
|
113 |
-
.
|
114 |
-
|
115 |
}
|
116 |
|
117 |
-
.
|
118 |
-
|
119 |
}
|
120 |
|
121 |
-
.
|
122 |
-
|
123 |
-
margin: 5px;
|
124 |
-
border: none;
|
125 |
-
color: white;
|
126 |
-
cursor: pointer;
|
127 |
-
border-radius: 5px;
|
128 |
-
font-size: 1em; /* Increased font size */
|
129 |
-
transition: background-color 0.3s, transform 0.3s; /* Smooth transitions */
|
130 |
}
|
131 |
|
132 |
-
.
|
133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
-
|
136 |
-
.
|
137 |
-
|
138 |
}
|
139 |
|
140 |
-
.
|
141 |
-
|
142 |
}
|
143 |
</style>
|
144 |
|
145 |
</head>
|
146 |
<body>
|
147 |
-
<a id="skip-to-content" href="#content">Skip to the content.</a>
|
148 |
-
|
149 |
<header class="page-header" role="banner">
|
150 |
<h1 class="project-name">Attention Tracker</h1>
|
151 |
<h2 class="project-tagline">Attention Tracker: Detecting Prompt Injection Attacks in LLMs</h2>
|
152 |
<h2 class="project-tagline"><a href="https://arxiv.org/abs/xxx" style="color: white;" target="_blank" rel="noopener noreferrer">https://arxiv.org/abs/xx.xx</a></h2>
|
153 |
-
<!-- <h2 class="project-tagline"><a href="https://huggingface.co/spaces/pinyuchen/attention-tracker-Jailbreak-Detector" style="color: white;" target="_blank" rel="noopener noreferrer">Live Demo</a></h2> -->
|
154 |
<div style="text-align: center; font-size: large;">
|
155 |
<div>
|
156 |
<a href="https://khhung906.github.io/" style="color: white;" target="_blank" rel="noopener noreferrer">
|
@@ -179,135 +186,127 @@
|
|
179 |
<sup>1</sup>National Taiwan University <sup>2</sup>IBM Research
|
180 |
</div>
|
181 |
</header>
|
182 |
-
|
183 |
<main id="content" class="main-content" role="main">
|
184 |
<h2 id="abstract">Abstract</h2>
|
185 |
|
186 |
-
<p>Large Language Models (LLMs) have revolutionized various domains but remain vulnerable to prompt injection attacks, where malicious inputs manipulate the model into ignoring original instructions and executing designated action. In this paper, we investigate
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
</p>
|
195 |
-
|
196 |
-
<h2 id="what-is-jailbreak">What is Prompt Injection Attack?</h2>
|
197 |
-
<p>A Prompt Injection Attack is a technique used to manipulate language models (like GPT-3 or similar AI systems) by injecting malicious or deceptive prompts into the input data, causing the model to behave in unexpected or undesired ways. This attack exploits the way language models interpret and respond to instructions, tricking them into providing information or performing actions that were not originally intended.</p>
|
198 |
-
|
199 |
-
|
200 |
-
<h2 id="refusal-loss">Distraction Effect</h2>
|
201 |
-
|
202 |
-
<p>
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
</p>
|
207 |
-
|
208 |
-
<div class="container">
|
209 |
-
<div><img id="attn-map-img" src="./figures/attn_map.png" /></div>
|
210 |
-
</div>
|
211 |
-
|
212 |
-
<p>
|
213 |
-
|
214 |
-
|
215 |
-
</p>
|
216 |
-
|
217 |
-
|
218 |
-
</div>
|
219 |
-
|
220 |
-
<h2 id="proposed-approach-attention-tracker">Proposed Approach: Attention Tracker</h2>
|
221 |
-
<p> With the discover of distraction effect, we propose <strong>Attention Tracker</strong>,
|
222 |
-
|
223 |
-
</p>
|
224 |
-
|
225 |
-
<div class="container"><img id="attention-tracker-header" src="./figures/main.png" /></div>
|
226 |
-
|
227 |
-
<p></p>
|
228 |
-
<p>
|
229 |
-
|
230 |
-
</p>
|
231 |
-
<p>
|
232 |
-
|
233 |
-
</p>
|
234 |
-
<p>
|
235 |
-
|
236 |
-
</p>
|
237 |
-
|
238 |
-
<p>
|
239 |
-
We provide more details about the running flow of Attention Tracker in the paper.
|
240 |
-
</p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
|
242 |
-
|
243 |
-
|
244 |
-
<
|
245 |
-
<
|
246 |
-
|
247 |
-
|
248 |
-
<
|
249 |
-
<
|
250 |
-
|
251 |
-
|
252 |
-
</
|
253 |
-
|
254 |
-
|
255 |
-
<p>
|
256 |
-
|
257 |
-
</p>
|
258 |
-
|
259 |
-
<
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
</div>
|
273 |
-
|
274 |
-
<div class="button-container">
|
275 |
-
<div class="group-title">Attack Data</div>
|
276 |
-
<button class="attack-button" onclick="showAttackImage('attackImage1')">Attack 1</button>
|
277 |
-
<button class="attack-button" onclick="showAttackImage('attackImage2')">Attack 2</button>
|
278 |
-
<button class="attack-button" onclick="showAttackImage('attackImage3')">Attack 3</button>
|
279 |
-
<button class="attack-button" onclick="showAttackImage('attackImage4')">Attack 4</button>
|
280 |
-
</div>
|
281 |
-
|
282 |
-
<div class="image-gallery">
|
283 |
-
<img id="attackImage1" src="./demo_results/attack_1.png" alt="Attack Image 1">
|
284 |
-
<img id="attackImage2" src="./demo_results/attack_2.png" alt="Attack Image 2">
|
285 |
-
<img id="attackImage3" src="./demo_results/attack_3.png" alt="Attack Image 3">
|
286 |
-
<img id="attackImage4" src="./demo_results/attack_4.png" alt="Attack Image 4">
|
287 |
-
</div>
|
288 |
-
|
289 |
-
<h2 id="inquiries"> Inquiries on Attention Tracker</h2>
|
290 |
-
<p> Please contact <a href="Mailto:khhung906@gmail.com">Kuo-Han Hung</a>
|
291 |
-
and <a href="Mailto:pin-yu.chen@ibm.com">Pin-Yu Chen</a>
|
292 |
-
</p>
|
293 |
-
<h2 id="citations">Citations</h2>
|
294 |
-
<p>If you find Attention Tracker helpful and useful for your research, please cite our main paper as follows:</p>
|
295 |
-
|
296 |
-
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
|
297 |
-
<!-- @misc{hu2024gradient,
|
298 |
-
title={Gradient Cuff: Detecting Jailbreak Attacks on Large Language Models by Exploring Refusal Loss Landscapes},
|
299 |
-
author={Xiaomeng Hu and Pin-Yu Chen and Tsung-Yi Ho},
|
300 |
-
year={2024},
|
301 |
-
eprint={2403.00867},
|
302 |
-
archivePrefix={arXiv},
|
303 |
-
primaryClass={cs.CR} }-->
|
304 |
-
|
305 |
-
</code></pre></div></div>
|
306 |
-
|
307 |
|
308 |
<footer class="site-footer">
|
309 |
|
310 |
-
|
311 |
|
312 |
</footer>
|
313 |
</main>
|
|
|
3 |
<head>
|
4 |
<meta charset="UTF-8">
|
5 |
|
6 |
+
<!-- Begin Jekyll SEO tag v2.8.0 -->
|
7 |
+
<title>Attention Tracker | Attention Tracker: Detecting Prompt Injection Attacks in LLMs </title>
|
8 |
+
<meta property="og:title" content="Gradient Cuff" />
|
9 |
+
<meta property="og:locale" content="en_US" />
|
10 |
+
<meta name="description" content="Detecting Prompt Injection Attacks in LLMs using attention" />
|
11 |
+
<meta property="og:description" content="Detecting Prompt Injection Attacks in LLMs using attention" />
|
12 |
+
<script type="application/ld+json">
|
13 |
+
{"@context":"https://schema.org","@type":"WebSite","description":"Detecting Jailbreak Attacks on Large Language Models by Exploring Refusal Loss Landscapes","headline":"Gradient Cuff","name":"Gradient Cuff","url":"https://huggingface.co/spaces/gregH/Gradient Cuff"}</script>
|
14 |
+
<!-- End Jekyll SEO tag -->
|
15 |
+
|
16 |
+
<!-- <link rel="preconnect" href="https://fonts.gstatic.com">
|
17 |
<link rel="preload" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700&display=swap" as="style" type="text/css" crossorigin>
|
18 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
19 |
<meta name="theme-color" content="#157878">
|
20 |
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> -->
|
21 |
|
22 |
<link rel="stylesheet" href="assets/css/bootstrap/bootstrap.min.css?v=90447f115a006bc45b738d9592069468b20e2551">
|
23 |
<link rel="stylesheet" href="assets/css/style.css?v=90447f115a006bc45b738d9592069468b20e2551">
|
24 |
<!-- start custom head snippets, customize with your own _includes/head-custom.html file -->
|
25 |
<link rel="stylesheet" href="assets/css/custom_style.css?v=90447f115a006bc45b738d9592069468b20e2551">
|
26 |
+
|
27 |
+
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
28 |
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
|
29 |
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
|
30 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.js"></script>
|
|
|
32 |
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.2/themes/base/jquery-ui.css">
|
33 |
<link rel="stylesheet" href="/resources/demos/style.css">
|
34 |
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
|
35 |
+
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script> -->
|
36 |
+
|
37 |
+
<!-- for mathjax support -->
|
38 |
+
<script src="https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?features=es6"></script>
|
39 |
+
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
40 |
+
<!-- end custom head snippets -->
|
41 |
+
|
42 |
<script>
|
43 |
+
let normalIndex = 0;
|
44 |
+
let attackIndex = 0;
|
45 |
+
|
46 |
+
function navigateImages(type, direction) {
|
47 |
+
let images;
|
48 |
+
let currentIndex;
|
49 |
+
|
50 |
+
// Determine which set of images to target and the current index
|
51 |
+
if (type === 'normal') {
|
52 |
+
images = document.querySelectorAll('.normal-gallery .image-gallery img');
|
53 |
+
currentIndex = normalIndex;
|
54 |
+
} else if (type === 'attack') {
|
55 |
+
images = document.querySelectorAll('.attack-gallery .image-gallery img');
|
56 |
+
currentIndex = attackIndex;
|
57 |
+
}
|
58 |
+
|
59 |
+
// Check if images were found to avoid accessing undefined elements
|
60 |
+
if (images && images.length > 0) {
|
61 |
+
// Hide current image
|
62 |
+
images[currentIndex].classList.remove('active');
|
63 |
+
|
64 |
+
// Calculate new index (modulo ensures cycling)
|
65 |
+
currentIndex = (currentIndex + direction + images.length) % images.length;
|
66 |
+
|
67 |
+
// Show new image
|
68 |
+
images[currentIndex].classList.add('active');
|
69 |
+
|
70 |
+
// Update index tracker
|
71 |
+
if (type === 'normal') {
|
72 |
+
normalIndex = currentIndex;
|
73 |
+
} else if (type === 'attack') {
|
74 |
+
attackIndex = currentIndex;
|
75 |
+
}
|
76 |
+
} else {
|
77 |
+
console.error("No images found for type:", type);
|
78 |
+
}
|
79 |
}
|
|
|
|
|
|
|
|
|
80 |
</script>
|
81 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
<style>
|
83 |
+
.image-gallery-container {
|
84 |
+
position: relative;
|
85 |
+
display: flex;
|
86 |
+
justify-content: center;
|
87 |
+
align-items: center;
|
88 |
+
margin: 20px auto;
|
89 |
+
}
|
90 |
|
91 |
.image-gallery {
|
92 |
+
width: 80%; /* Increased width */
|
93 |
+
max-height: 600px; /* Increased height */
|
94 |
+
overflow: hidden;
|
95 |
+
position: relative;
|
96 |
+
margin-left: 50px;
|
97 |
+
margin-right: 50px;
|
98 |
}
|
99 |
|
100 |
.image-gallery img {
|
101 |
+
width: 100%;
|
102 |
+
height: auto;
|
103 |
+
border-radius: 10px;
|
104 |
+
display: none;
|
|
|
|
|
105 |
}
|
106 |
|
107 |
+
.image-gallery img.active {
|
108 |
+
display: block;
|
|
|
109 |
}
|
110 |
|
111 |
+
.arrow {
|
112 |
+
cursor: pointer;
|
113 |
+
position: absolute;
|
114 |
+
top: 50%;
|
115 |
+
transform: translateY(-50%);
|
116 |
+
font-size: 2.5em;
|
117 |
+
color: #444; /* Darker color */
|
118 |
+
padding: 5px 15px;
|
119 |
+
transition: color 0.3s;
|
120 |
+
user-select: none;
|
121 |
+
transform: scaleX(0.7);
|
122 |
}
|
123 |
|
124 |
+
.arrow:hover {
|
125 |
+
color: #007bff; /* Color on hover */
|
126 |
}
|
127 |
|
128 |
+
.left-arrow {
|
129 |
+
left: 20px; /* Adjusted position */
|
130 |
}
|
131 |
|
132 |
+
.right-arrow {
|
133 |
+
right: 20px; /* Adjusted position */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
}
|
135 |
|
136 |
+
.group-title {
|
137 |
+
font-size: large;
|
138 |
+
font-weight: bold;
|
139 |
+
margin-top: 30px;
|
140 |
+
font-size: 1.2em;
|
141 |
+
text-align: center; /* Center the text */
|
142 |
+
display: block; /* Ensure it behaves as a block element */
|
143 |
+
margin-bottom: 10px; /* Add some space below the title */
|
144 |
}
|
145 |
+
|
146 |
+
.green {
|
147 |
+
color: green; /* Set text color to green */
|
148 |
}
|
149 |
|
150 |
+
.red {
|
151 |
+
color: red; /* Set text color to green */
|
152 |
}
|
153 |
</style>
|
154 |
|
155 |
</head>
|
156 |
<body>
|
|
|
|
|
157 |
<header class="page-header" role="banner">
|
158 |
<h1 class="project-name">Attention Tracker</h1>
|
159 |
<h2 class="project-tagline">Attention Tracker: Detecting Prompt Injection Attacks in LLMs</h2>
|
160 |
<h2 class="project-tagline"><a href="https://arxiv.org/abs/xxx" style="color: white;" target="_blank" rel="noopener noreferrer">https://arxiv.org/abs/xx.xx</a></h2>
|
|
|
161 |
<div style="text-align: center; font-size: large;">
|
162 |
<div>
|
163 |
<a href="https://khhung906.github.io/" style="color: white;" target="_blank" rel="noopener noreferrer">
|
|
|
186 |
<sup>1</sup>National Taiwan University <sup>2</sup>IBM Research
|
187 |
</div>
|
188 |
</header>
|
|
|
189 |
<main id="content" class="main-content" role="main">
|
190 |
<h2 id="abstract">Abstract</h2>
|
191 |
|
192 |
+
<p>Large Language Models (LLMs) have revolutionized various domains but remain vulnerable to prompt injection attacks, where malicious inputs manipulate the model into ignoring original instructions and executing designated action. In this paper, we investigate
|
193 |
+
the underlying mechanisms of these attacks by analyzing the attention patterns within LLMs.
|
194 |
+
We introduce the concept of the <strong>distraction effect</strong>, where specific attention heads, termed
|
195 |
+
important heads, shift focus from the original instruction to the injected instruction. Building on this discovery, we propose <strong>Attention
|
196 |
+
Tracker</strong>, a training-free detection method that tracks attention patterns on instruction to detect
|
197 |
+
prompt injection attacks without the need for additional LLM inference. Our method generalizes effectively across diverse models, datasets,
|
198 |
+
and attack types, showing an AUROC improvement of up to 10.0% over existing methods, and performs well even on small LLMs. We
|
199 |
+
demonstrate the robustness of our approach through extensive evaluations and provide insights into safeguarding LLM-integrated systems from prompt injection vulnerabilities.
|
200 |
+
</p>
|
201 |
+
|
202 |
+
<h2 id="what-is-jailbreak">What is Prompt Injection Attack?</h2>
|
203 |
+
<p>A Prompt Injection Attack is a technique used to manipulate language models (like GPT-3 or similar AI systems) by injecting malicious or deceptive prompts into the input data, causing the model to behave in unexpected or undesired ways. This attack exploits the way language models interpret and respond to instructions, tricking them into providing information or performing actions that were not originally intended.</p>
|
204 |
+
|
205 |
+
|
206 |
+
<h2 id="refusal-loss">Distraction Effect</h2>
|
207 |
+
|
208 |
+
<p>
|
209 |
+
In this section, we analyze the reasons behind the success of prompt injection attacks on LLMs. Specifically, we aim to understand
|
210 |
+
<strong>what mechanism within LLMs causes them to "ignore" the original instruction and follow the injected instruction instead</strong>.
|
211 |
+
To explore this, we examine the attention patterns of the last token in the input prompts, as it has the most direct influence on the LLMs' output.
|
212 |
+
</p>
|
213 |
+
|
214 |
+
<div class="container">
|
215 |
+
<div><img id="attn-map-img" src="./figures/attn_map.png" /></div>
|
216 |
+
</div>
|
217 |
+
|
218 |
+
<p>
|
219 |
+
In the figure (a), we visualize the attention maps of the last token in the input prompt for normal and attack data. We observe that the attention maps for normal data are much darker than those for attacked data, particularly in the middle and earlier layers of the LLM. This indicates that the last token's attention to the instruction is significantly higher for normal data than for attack data in specific attention heads. When inputting attacked data, the attention shifts away from the original instruction towards the attack data, which we refer to as the <strong>distraction effect</strong>.
|
220 |
+
Additionally, in the figure (b), we find that the attention focus shifts from the original instruction to the injected instruction in the attack data. This suggests that the separator string helps the attacker shift attention to the injected instruction, causing the LLM to perform the injected task instead of the target task.
|
221 |
+
</p>
|
222 |
+
|
223 |
+
|
224 |
+
</div>
|
225 |
+
|
226 |
+
<h2 id="proposed-approach-attention-tracker">Proposed Approach: Attention Tracker</h2>
|
227 |
+
<p> With the discover of distraction effect, we propose <strong>Attention Tracker</strong>,
|
228 |
+
a prompt injection detection method based on tracking the attention pattern on instruction. Our detection procedure is shown below:
|
229 |
+
</p>
|
230 |
+
|
231 |
+
<div class="container"><img id="attention-tracker-header" src="./figures/main.png" /></div>
|
232 |
+
|
233 |
+
<p></p>
|
234 |
+
<p>
|
235 |
+
Attention Tracker can be summarized into two phases:
|
236 |
+
</p>
|
237 |
+
<p>
|
238 |
+
<strong>(Phase 1) Finding Important Heads:</strong> In the first step, we identify specific attention head that that exhibit the distraction effect, which we termed the important heads. To find the important heads, we use a set of LLM-generated sentences with the ignore attack as the dataset.
|
239 |
+
</p>
|
240 |
+
<p>
|
241 |
+
<strong>(Phase 2) Prompt Injection Detection with Important Heads:</strong> In the second step, we feed the testing quries into the target LLM and aggregate the attention directed towards the instruction in the important heads. With this aggregated score which we call the <strong>focus score</strong>, we can effectively detect prompt injection attacks.
|
242 |
+
</p>
|
243 |
+
|
244 |
+
<p>
|
245 |
+
We provide more details about the running flow of Attention Tracker in the paper.
|
246 |
+
</p>
|
247 |
+
|
248 |
+
<h2 id="result-attention-tracker">Experiment Result</h2>
|
249 |
+
<p>
|
250 |
+
In this section, we evaluate Attention Tracker against various baselines with the AUROC score on two prompt injection detection benchmarks: Open-Prompt-Injection and deepset prompt injection dataset:
|
251 |
+
</p>
|
252 |
+
<div class="container"><img id="attention-tracker-header" src="./figures/result.png" /></div>
|
253 |
+
<p/>
|
254 |
+
<p>
|
255 |
+
As shown in the table, Attention Tracker consistently outperforms existing baselines, with an AUROC improvement of up to 3.1% on the Open-Prompt-Injection benchmark and 10.0% on the deepset prompt injection dataset. Among training-free methods, it achieves even greater gains, with an average AUROC improvement of 31.3% and 20.9% across the two datasets, respectively. Unlike LLM-based methods that rely on larger models for stability, Attention Tracker delivers robust and effective performance even with smaller LLMs, underscoring its suitability for real-world applications.
|
256 |
+
</p>
|
257 |
+
<h2 id="demonstration">Demo</h2>
|
258 |
+
|
259 |
+
<p>
|
260 |
+
We evaluated the effectiveness of the Attention Tracker by visualizing the distribution of attention aggregation for key heads across different data types (normal data vs. attack data) in the Open-Prompt-Injection dataset. Additionally, we calculated the focus score for these data samples. A higher focus score indicates a lower likelihood of prompt injection attacks. The tested model is Qwen-2 1.8b.
|
261 |
+
</p>
|
262 |
+
<div class="group-title green">Normal Data</div>
|
263 |
+
|
264 |
+
<div class="image-gallery-container normal-gallery">
|
265 |
+
<span class="arrow left-arrow" onclick="navigateImages('normal', -1)"><</span>
|
266 |
+
<div class="image-gallery">
|
267 |
+
<img id="normalImage1" src="./demo_results/normal_1.png" class="active" alt="Normal Image 1">
|
268 |
+
<img id="normalImage2" src="./demo_results/normal_2.png" alt="Normal Image 2">
|
269 |
+
<img id="normalImage3" src="./demo_results/normal_3.png" alt="Normal Image 3">
|
270 |
+
<img id="normalImage4" src="./demo_results/normal_4.png" alt="Normal Image 4">
|
271 |
+
<img id="normalImage4" src="./demo_results/normal_5.png" alt="Normal Image 5">
|
272 |
+
</div>
|
273 |
+
<span class="arrow right-arrow" onclick="navigateImages('normal', 1)">></span>
|
274 |
+
</div>
|
275 |
|
276 |
+
<div class="group-title red">Attack Data</div>
|
277 |
+
<div class="image-gallery-container attack-gallery">
|
278 |
+
<span class="arrow left-arrow" onclick="navigateImages('attack', -1)"><</span>
|
279 |
+
<div class="image-gallery">
|
280 |
+
<img id="attackImage1" src="./demo_results/attack_1.png" class="active" alt="Attack Image 1">
|
281 |
+
<img id="attackImage2" src="./demo_results/attack_2.png" alt="Attack Image 2">
|
282 |
+
<img id="attackImage3" src="./demo_results/attack_3.png" alt="Attack Image 3">
|
283 |
+
<img id="attackImage4" src="./demo_results/attack_4.png" alt="Attack Image 4">
|
284 |
+
</div>
|
285 |
+
<span class="arrow right-arrow" onclick="navigateImages('attack', 1)">></span>
|
286 |
+
</div>
|
287 |
+
|
288 |
+
<h2 id="inquiries"> Inquiries on Attention Tracker</h2>
|
289 |
+
<p> Please contact <a href="Mailto:khhung906@gmail.com">Kuo-Han Hung</a>
|
290 |
+
and <a href="Mailto:pin-yu.chen@ibm.com">Pin-Yu Chen</a>
|
291 |
+
</p>
|
292 |
+
|
293 |
+
<h2 id="citations">Citations</h2>
|
294 |
+
<p>If you find Attention Tracker helpful and useful for your research, please cite our main paper as follows:</p>
|
295 |
+
|
296 |
+
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>
|
297 |
+
<!-- @misc{hu2024gradient,
|
298 |
+
title={Gradient Cuff: Detecting Jailbreak Attacks on Large Language Models by Exploring Refusal Loss Landscapes},
|
299 |
+
author={Xiaomeng Hu and Pin-Yu Chen and Tsung-Yi Ho},
|
300 |
+
year={2024},
|
301 |
+
eprint={2403.00867},
|
302 |
+
archivePrefix={arXiv},
|
303 |
+
primaryClass={cs.CR} }-->
|
304 |
+
</code></pre></div>
|
305 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
|
307 |
<footer class="site-footer">
|
308 |
|
309 |
+
<span class="site-footer-owner">This website is maintained by <a href="https://khhung906.github.io/">Kuo-Han Hung</a></a>.</span>
|
310 |
|
311 |
</footer>
|
312 |
</main>
|