File size: 571 Bytes
729b0f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
import time

from modules import Detector

start_time = time.time()

with open("/home/shang/aihack/aihack/data/malicious_data.json", "r") as file:
    malicious_data = json.load(file)
full = []
for row in malicious_data:
    prompt = row["example_jailbreak_input"]
    full.append(prompt)

detector = Detector(binary=True)
outputs = detector.forward(full)

correct = 0
for output in outputs:
    correct += output


print(correct / len(outputs))
print(correct, len(outputs))

end_time = time.time()
print(f"Total time taken: {end_time - start_time} seconds")