PII Detection
Semantic Router provides built-in Personally Identifiable Information (PII) detection to protect sensitive data in user queries. The system uses fine-tuned BERT models to identify and handle various types of PII according to configurable policies.
Overview
The PII detection system:
- Identifies common PII types in user queries
- Enforces configurable PII policies per decision
- Blocks requests containing sensitive information based on signal rules
- Integrates with signal-driven decisions for fine-grained control
- Logs policy violations for monitoring
Supported PII Types
The system can detect the following PII types:
| PII Type | Description | Examples |
|---|---|---|
PERSON | Person names | "John Smith", "Mary Johnson" |
EMAIL_ADDRESS | Email addresses | "user@example.com" |
PHONE_NUMBER | Phone numbers | "+1-555-123-4567", "(555) 123-4567" |
US_SSN | US Social Security Numbers | "123-45-6789" |
STREET_ADDRESS | Physical addresses | "123 Main St, New York, NY" |
GPE | Geopolitical entities | Countries, states, cities |
ORGANIZATION | Organization names | "Microsoft", "OpenAI" |
CREDIT_CARD | Credit card numbers | "4111-1111-1111-1111" |
US_DRIVER_LICENSE | US Driver's License | "D123456789" |
IBAN_CODE | International Bank Account Number | "GB82 WEST 1234 5698 7654 32" |
IP_ADDRESS | IP addresses | "192.168.1.1", "2001:db8::1" |
DOMAIN_NAME | Domain/website names | "example.com", "google.com" |
DATE_TIME | Date/time information | "2024-01-15", "January 15th" |
AGE | Age information | "25 years old", "born in 1990" |
NRP | Nationality/Religious/Political groups | "American", "Christian", "Democrat" |
ZIP_CODE | ZIP/postal codes | "10001", "SW1A 1AA" |
Configuration
PII detection is now a first-class signal in the signal layer. You define named pii rules under signals.pii, then reference them in decisions using type: "pii".
Basic PII Detection
# router-config.yaml
# ── PII Classifier Model ──────────────────────────────────────────────────
classifier:
pii_model:
model_id: "models/mom-pii-classifier"
use_modernbert: false
threshold: 0.9
use_cpu: true
pii_mapping_path: "models/mom-pii-classifier/label_mapping.json"
# ── Signals ───────────────────────────────────────────────────────────────
signals:
pii:
- name: "pii_deny_all"
threshold: 0.9
description: "Block all PII types"
# ── Decisions ─────────────────────────────────────────────────────────────
decisions:
- name: "block_pii"
priority: 999
rules:
operator: "OR"
conditions:
- type: "pii"
name: "pii_deny_all"
plugins:
- type: "fast_response"
configuration:
message: "Request blocked: personal information detected. Please remove sensitive data and try again."