Skip to main content
PasteGuard detects PII with a small open-source service that pairs a deterministic regex/checksum layer with a multilingual neural model. Detection is language-agnostic: the neural model finds names and places in mixed-language text — for example, an Italian name and city in a German letter — and structured identifiers (IBAN, credit card, email, IP) are matched by checksum, not by language.

How it works

  • Deterministic layer — regex candidates validated by checksum/format (python-stdnum, phonenumbers). Owns the structured identifiers; every match is validated, not guessed, and scores 1.0.
  • Neural layer — multilingual GLiNER NER for names and locations, in one pass over the text.
The detector speaks the /analyze HTTP contract, is configured through the detector_url setting, and runs as a separate service (see detector/).

Supported Entities

EntityExamples
PERSONDr. Sarah Chen, John Smith
LOCATIONNew York, München, Milano
EMAIL_ADDRESSsarah.chen@hospital.org
PHONE_NUMBER+49 171 1234567
IBAN_CODEDE89 3704 0044 0532 0130 00
CREDIT_CARD4111 1111 1111 1111
IP_ADDRESS192.168.1.1
VAT_CODEEU VAT number, e.g. DE136695976, IT00743110157, FR40303265045
Names and locations use the multilingual model. IBAN, credit card, email, and IP work internationally. Phone numbers are + international-only by default; set phone_regions for local formats. VAT_CODE requires a country prefix and is validated with python-stdnum.

Languages and phone regions

Detection is multilingual and language-agnostic. PasteGuard does not auto-detect language. National-format phone numbers need country rules. Configure phone_regions only for regions your traffic uses.

Confidence Scoring

Neural detections carry a confidence score (0.0–1.0); checksum-validated identifiers are always 1.0. The default request threshold is 0.7:
pii_detection:
  score_threshold: 0.7
Each neural label also has a calibrated floor (person, location) so high-precision labels and faint-but-important ones can coexist. Tune them per deployment via the DETECTOR_FLOOR_PERSON and DETECTOR_FLOOR_LOCATION environment variables on the detector.

Response Headers

When PII is detected:
X-PasteGuard-PII-Detected: true
X-PasteGuard-PII-Masked: true   # mask mode only