v0.3.1: Now scanning for the stuff one shouldn't be leaking
v0.3.1 : Now scanning for the stuff you shouldn't be leaking
Detection is great, but what about the data inside the prompt? This release adds three new modules to help with exactly that.
What's new
PII Detection : PIIScanner uses the PasteProof PII Detector (ModernBERT, F1 0.97) to find 27 entity types in text: emails, SSNs, credit cards, API keys, HIPAA fields, GDPR identifiers, and more. Scan, redact, or report : same tuple-style returns as the rest of the package.
Toxicity Detection : ToxicityDetector classifies text as toxic or non-toxic using citizenlab's multilingual DistilBERT (F1 0.94, 10 languages). Returns (is_toxic, score), mirrors detect_injection() exactly.
Regex Scanner : RegexScanner is pure stdlib. Ships with defaults for email, phone, SSN, credit card, IP, API key, and JWT patterns. Fully customizable: add, remove, or replace patterns at construction or runtime. No model downloads, no heavy dependencies, instant results.
Good to know
- All three modules follow the same API conventions as
PromptInjectionDetectorandPromptSanitizer, consistent return types, report methods, threshold tuning. - PII and toxicity models use
transformersandtorch, which are already required dependencies. No new install footprint. - The PII model (ModernBERT) needs
transformers >= 4.48.0. Everything else works on the existing minimum. - None of this replaces a proper security review. These are detection layers, not guarantees. Attackers who know the stack can work around public models and regex patterns.
Other changes
- Updated docs, notebook, and README with usage examples for all three modules.
- Model repos linked in feature descriptions for transparency.
Full docs: pytector.readthedocs.io