license: apache-2.0
language:
- vi
- en
task_categories: - text-classification
tags: - security
- prompt-injection
- guardrails
- input-sanitization
- pii-detection
- vietnamese
size_categories: - 1K<n<10K
pretty_name: SecAI Chat Input Sanitization (VI/EN)
configs: - config_name: default
data_files:- split: train
path: data/train.jsonl - split: test
path: data/test.jsonl
- split: train
SecAI — Chat Input Sanitization (VI/EN)
Dataset song ngữ Việt/Anh để huấn luyện input-sanitization guard cho chatbot An toàn thông tin:
gán nhãn câu người dùng để chặn prompt-injection & off-topic, cho câu bảo mật hợp lệ đi qua, và gắn cờ PII.
Nhãn
| Cột | Kiểu | Giá trị |
|---|---|---|
intent |
softmax | security | chitchat | offtopic |
injection |
sigmoid | 0/1 (prompt-injection / jailbreak) |
pii |
sigmoid | 0/1 (lộ secret / PII) |
injection/pii độc lập với intent.
Schema
{"text": "...", "intent": "security", "injection": 0, "pii": 0,
"lang": "vi", "split": "train", "group": "<skeleton-id>"}
Splits
- train 1005 · test 383 · tổng 1388 (vi 804 / en 584).
- intent: security 885 · offtopic 386 · chitchat 117 · injection=1: 194 · pii=1: 187.
- Chia split theo skeleton (
group), ~25% giữ riêng cho test; injection stratify theo từng kỹ thuật nên cả 9 kỹ thuật + costume VI/EN đều có mặt ở test → rò rỉ train↔test = 0 (đo generalization, không phải nhớ template).
Độ phủ
security (~40 loại lỗ hổng, tra cứu CVE/CWE, secure-coding borderline, dán code/log dài >200 ký tự) · injection (9 kỹ thuật: direct, roleplay, leak, base64/hex/ROT13, split, indirect, unicode/full-width, multi-turn, tool-leak, đội-lốt-security) · pii (key/JWT/CCCD/SĐT/email, đều tổng hợp) · offtopic + hard-negative (câu chứa từ khoá bảo mật nhưng không phải yêu cầu ATTT) · chitchat · biến thể không dấu/teencode + code-mix Việt–Anh.
Dùng
from datasets import load_dataset
ds = load_dataset("secai1999/secai-chat-sanitization")
Fit head trên embedding câu (thiết kế gốc: DuyTa/sec-embedding, 1024-d), L2-normalize, tinh chỉnh ngưỡng theo nhãn (ưu tiên injection Recall ≥ 0.95). Head tham chiếu là mixed (intent = MLP 1 lớp ẩn cho ranh giới chitchat/offtopic; injection/pii = logistic class-balanced), suy luận numpy-only. build_sanitize_dataset.py sinh lại dataset tất định (seed cố định).
KPI tham chiếu (test, leakage=0; head mixed = intent MLP + injection/pii logistic)
intent acc 0.987 · macro-F1 0.986 · MỌI lớp F1 ≥ 0.98: security 0.990 · chitchat 0.983 · offtopic 0.982 · injection 0.983 (R 1.0) · pii 0.994 (R 1.0). Overfit gap intent acc ~0.013. Xem metrics.json.
Hạn chế
Đoạn SQL/exploit dán inline đôi khi bị gắn cờ injection (ngưỡng đặt thấp để R=1.0). Ngưỡng injection/pii/offtopic cấu hình được lúc chạy để đổi cân bằng precision/recall.
An toàn
Mọi secret/PII là tổng hợp (giả). Mẫu injection là phòng thủ (nhãn dương để phát hiện & chặn), phỏng theo archetype red-team công khai.