> ## Documentation Index
> Fetch the complete documentation index at: https://pasteguard.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PII Detection

> Personal data detection via a deterministic checksum layer plus multilingual GLiNER NER

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](https://github.com/urchade/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/`](https://github.com/sgasser/pasteguard/tree/main/detector)).

## Supported Entities

| Entity          | Examples                                                            |
| --------------- | ------------------------------------------------------------------- |
| `PERSON`        | Dr. Sarah Chen, John Smith                                          |
| `LOCATION`      | New York, München, Milano                                           |
| `EMAIL_ADDRESS` | [sarah.chen@hospital.org](mailto:sarah.chen@hospital.org)           |
| `PHONE_NUMBER`  | +49 171 1234567                                                     |
| `IBAN_CODE`     | DE89 3704 0044 0532 0130 00                                         |
| `CREDIT_CARD`   | 4111 1111 1111 1111                                                 |
| `IP_ADDRESS`    | 192.168.1.1                                                         |
| `VAT_CODE`      | EU 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`:

```yaml theme={null}
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
```
