Renjun An
Use real cases from each model's training corpus
132d576
Raw History Blame Contribute Delete
1.44 kB
"""Cases taken from each model's own training corpus, loaded from cases.json.
Every case is an attack, and every one is a real record rather than something
written for the demo: the anomaly sessions come from the agent_trust split of
`AnShi-HW/tool-call-anomaly-data`, the intent records from tool-intent-align's
training corpora, and the output-filter rows from minspan's training split.
Each case keeps its source and record id in `cases.json`, and the button label
is the attack class that corpus assigns it, so the labels stay short and read
as one set.
`scripts/extract_cases.py` regenerates the file.
"""
from __future__ import annotations
import json
from pathlib import Path
CASES = json.loads(Path(__file__).with_name("cases.json").read_text(encoding="utf-8"))
def pretty(value):
return json.dumps(value, ensure_ascii=False, indent=2)
def labels(task):
return [(case["label"], "risk") for case in CASES[task]]
INTENT_CASES = CASES["intent"]
OUTPUT_CASES = CASES["output_filter"]
ANOMALY_CASES = CASES["anomaly"]
INTENT_LABELS = labels("intent")
OUTPUT_LABELS = labels("output_filter")
ANOMALY_LABELS = labels("anomaly")
INTENT_EXAMPLES = [
[pretty(case["context"]), pretty(case["tool"]), pretty(case["call"])] for case in INTENT_CASES
]
OUTPUT_EXAMPLES = [[case["instruction"], case["data"]] for case in OUTPUT_CASES]
ANOMALY_EXAMPLES = [[case["task"], pretty(case["tool_calls"])] for case in ANOMALY_CASES]