-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify_dataset.py
More file actions
37 lines (31 loc) · 1.16 KB
/
Copy pathverify_dataset.py
File metadata and controls
37 lines (31 loc) · 1.16 KB
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
29
30
31
32
33
34
35
36
37
import os
os.environ["HF_HUB_OFFLINE"] = "0"
os.environ["HF_DATASETS_OFFLINE"] = "0"
os.environ["REQUESTS_CA_BUNDLE"] = ""
os.environ["CURL_CA_BUNDLE"] = ""
import requests, urllib3
urllib3.disable_warnings()
orig = requests.Session.request
def patched(self, method, url, **kwargs):
kwargs["verify"] = False
return orig(self, method, url, **kwargs)
requests.Session.request = patched
from datasets import load_dataset
TOKEN = os.environ.get("HF_TOKEN", "")
ds = load_dataset("Shomi28/prompt-injection-dataset", token=TOKEN)
print("LIVE DATASET — Shomi28/prompt-injection-dataset")
print("=" * 55)
for split in ds:
inj = sum(1 for x in ds[split] if x["label"] == 1)
safe = sum(1 for x in ds[split] if x["label"] == 0)
print(f" {split:12s}: {len(ds[split]):>5,} rows | safe={safe:<4} injection={inj}")
print()
print("Sample — injection:")
sample_inj = next(x for x in ds["train"] if x["label"] == 1)
print(f" {sample_inj['text']}")
print()
print("Sample — safe:")
sample_safe = next(x for x in ds["train"] if x["label"] == 0)
print(f" {sample_safe['text']}")
print()
print("Dataset URL: https://huggingface.co/datasets/Shomi28/prompt-injection-dataset")