TonyYun's picture
card: document the non_literal_value flag
04e6eb1 verified
|
Raw
History Blame Contribute Delete
10.3 kB
---
pretty_name: PII Shield Benchmark
license: cc-by-4.0
task_categories:
- token-classification
language:
- bg
- cs
- da
- de
- el
- en
- es
- et
- fi
- fr
- ga
- hr
- hu
- it
- lt
- lv
- mt
- nl
- pl
- pt
- ro
- sk
- sl
- sr
- sv
tags:
- pii
- privacy
- ner
- gdpr
- pii-detection
size_categories:
- 1M<n<10M
configs:
- config_name: openpii-1m
default: true
data_files:
- split: train
path: openpii-1m/part-*.parquet
- config_name: nemotron-pii
data_files:
- split: train
path: nemotron-pii/part-*.parquet
- config_name: gretel-pii-en-v1
data_files:
- split: train
path: gretel-pii-en-v1/part-*.parquet
- config_name: privy
data_files:
- split: train
path: privy/part-*.parquet
- config_name: mapa-sentences
data_files:
- split: train
path: mapa-sentences/part-*.parquet
- config_name: mapa-testdocs
data_files:
- split: train
path: mapa-testdocs/part-*.parquet
---
# PII Shield Benchmark
Five public PII-detection datasets rewritten into one record shape, so models can be
trained and evaluated across all of them without writing five parsers. 2,301,892 records
carrying 13,343,257 labeled spans in 25 European languages.
Nothing here is new data. Every text and every annotation comes from one of the five
source datasets below; this repository only harmonizes the containers: one schema, one
label taxonomy, one file format (Parquet, zstd). The original labels ride along on every
span, so any harmonization decision can be reversed.
## Record shape
Every config yields records with the same fields:
```json
{
"uid": "nemotron-pii/train/000042",
"source": "nemotron-pii",
"native_split": "train",
"language": "en",
"text": "... the raw document text ...",
"spans": [
{
"entity": "PHONE_NUMBER",
"sub": "fax",
"start": 118,
"end": 132,
"text": "+977 1 4582 3941",
"native_label": "fax_number",
"flags": []
}
],
"meta": { "domain": "healthcare", "locale": "us" }
}
```
- `start` / `end` are Unicode code points into `text`, end-exclusive. The invariant
`text[start:end] == span.text` holds for every span in the dataset and is verified at
build time.
- `entity` is one of 47 shared entity types (list below). `sub` optionally carries a finer
role (for example `given` vs `family` under `PERSON_NAME`), and `native_label` is always
the source dataset's own label.
- `native_split` is the source's original split name (train/validation/test/dev/all),
preserved as data. All records of a config are published under a single `train` split;
carve your own subsets from `native_split` or `uid`.
- `meta` passes source-specific extras through (domain, locale, document type, template
id, and so on); its fields differ per config.
- `flags` marks known data-quality caveats, explained below. An empty list means none.
## Sources
| config | source dataset | license | contents |
|---|---|---|---|
| `openpii-1m` | [ai4privacy/pii-masking-openpii-1m](https://huggingface.co/datasets/ai4privacy/pii-masking-openpii-1m) | CC-BY-4.0 | 1,428,143 synthetic records, 23 languages, 10,328,208 spans |
| `nemotron-pii` | [nvidia/Nemotron-PII](https://huggingface.co/datasets/nvidia/Nemotron-PII) | CC-BY-4.0 | 200,000 synthetic business documents, English, 1,675,796 spans |
| `gretel-pii-en-v1` | [gretelai/gretel-pii-masking-en-v1](https://huggingface.co/datasets/gretelai/gretel-pii-masking-en-v1) | Apache-2.0 | 60,000 synthetic documents, English, 254,706 spans |
| `privy` | [piimb/privy](https://huggingface.co/datasets/piimb/privy) | MIT | 602,869 synthetic protocol payloads (large config), English, 1,069,918 spans |
| `mapa-sentences` | [piimb/mapa-eur-lex-pii](https://huggingface.co/datasets/piimb/mapa-eur-lex-pii) | CC-BY-4.0 | 10,838 sentences from EUR-LEX court judgments, 21 languages, 6,142 spans |
| `mapa-testdocs` | [piimb/mapa-eur-lex-pii](https://huggingface.co/datasets/piimb/mapa-eur-lex-pii) | CC-BY-4.0 | 42 full EUR-LEX judgments with a finer 13-label taxonomy, 8,487 spans |
The two mapa configs are the only human-written text in the pool; everything else is
synthetic. mapa ships two incompatible taxonomies at two granularities, which is why it
becomes two configs. 7,564 of the mapa sentences contain no PII at all and are kept as
negatives for false-positive measurement.
## How it was derived
1. **Structural examination.** Each source stores annotations differently: character
spans in JSON lines, python-repr strings inside Parquet, surface strings without any
positions, sentence-level and document-level offsets. Each got a dedicated converter.
2. **Label unification.** The five sources define 163 distinct labels between them. Each
was mapped, with per-label evidence from sampled values, onto 47 shared entity types.
Merges never destroy information: the finer distinction moves into `sub` (for example
`fax_number` becomes `PHONE_NUMBER` with `sub: "fax"`) and `native_label` keeps the
original. Three privy classes were dropped as non-PII payload: `O` (2,512,258 spans of
filler), `FINANCIAL` (a mixed bag of currency codes and routing-shaped numbers) and
`CURRENCY` (zero spans).
3. **Verification before build.** Every record of every source file was scanned: every
label known, every offset inside bounds, every stored surface equal to the text slice.
The scan established, among other things, that all sources use code-point offsets and
that every gretel surface occurs exactly once in its text.
4. **Conversion with loud failure.** The build refuses to continue on an unknown label or
an unexplained text mismatch, and the finished output is read back and checked against
span counts pinned from the verification scan, so a converter bug cannot pass silently.
What was deliberately not carried over: the sources' masked-text renditions and
token-level BIO/BILOU layers (both regenerable from the spans), and privy's small config
(the same generator as its large config, re-sampled with abbreviated label names).
## The 47 entity types
| group | entities |
|---|---|
| person | `PERSON_NAME` `HONORIFIC` `USERNAME` `GENDER` `AGE` `OCCUPATION` `EDUCATION_LEVEL` `EMPLOYMENT_STATUS` |
| contact and location | `EMAIL_ADDRESS` `PHONE_NUMBER` `URL` `STREET_ADDRESS` `CITY` `REGION` `COUNTRY` `POSTAL_CODE` `COORDINATES` `LOCATION` |
| time | `DATE_TIME` |
| government identifiers | `NATIONAL_ID` `TAX_ID` `PASSPORT_NUMBER` `DRIVER_LICENSE_NUMBER` `CERTIFICATE_LICENSE_NUMBER` |
| financial | `PAYMENT_CARD_NUMBER` `CVV` `PIN` `BANK_ACCOUNT_NUMBER` `IBAN` `BANK_ROUTING_NUMBER` `SWIFT_BIC` `MONEY_AMOUNT` |
| network, device, vehicle | `IP_ADDRESS` `MAC_ADDRESS` `DEVICE_ID` `VIN` `LICENSE_PLATE` |
| credentials | `PASSWORD` `API_KEY` `HTTP_COOKIE` |
| health and special category | `HEALTH_ID` `BLOOD_TYPE` `BIOMETRIC_REF` `SPECIAL_CATEGORY` |
| organization and other | `ORGANIZATION` `INTERNAL_ID` `LANGUAGE` |
`LOCATION` is the coarse geographic class (privy's `LOCATION`, mapa's country-level
`ADDRESS`); the six fine location entities can be rolled up into it for coarse scoring.
## Flags
Flags are quality annotations added during conversion; no source dataset carries such a
field. They let an evaluation include or exclude known dirt instead of silently absorbing
it. Counts over the whole dataset:
| flag | spans | meaning |
|---|---|---|
| `synthesized_offset` | 254,706 | gretel stores no positions; offsets were computed by exact substring search. Verified unambiguous: every surface occurs exactly once in its text. |
| `noisy_source_label` | 84,835 | every privy `TITLE` span. The label is systematically polluted: 60.3% genuine honorifics, 19.9% sex or gender terms, 19.9% occupations. |
| `boundary_whitespace` | 30,633 | the span begins or ends with whitespace in the source annotation; relevant for strict-boundary scoring. |
| `value_case_mismatch` | 12,965 | nemotron's stored span text differed from the document in letter case only; the document slice wins. |
| `format_invalid` | 3,795 | nemotron SWIFT/BIC values violating ISO 9362 lengths, and vehicle identifiers that are not valid 17-character VINs. |
| `vague_value` | 2,265 | nemotron `time` spans containing no digits ("office hours"). |
| `non_literal_value` | 563 | nemotron `email` spans containing no `@` — the generator annotated references ("via email", "the provided email address"), form placeholders ("[Email Address]"), usernames, and one phone number as email addresses. Provably not literal addresses; exclude for detector scoring. |
| `annotation_bug` | 65 | nemotron vehicle-identifier spans whose text is the literal string `license_plate`. |
| `offset_ambiguous` | 0 | reserved: would mark a synthesized offset whose surface occurs more than once. Never fires on this data. |
## Known limitations
- All IBANs in the dataset (16,897 spans, all from privy) are GB-prefixed. There are no
EU-format IBAN positives.
- The synthetic sources inherit their generators' quirks; the flags above mark the ones
found so far, without any claim of completeness.
- Rule-of-thumb quality differs by source: mapa is human-annotated real text, everything
else is template- or LLM-generated.
## Usage
```python
from datasets import load_dataset
ds = load_dataset("TonyYun/pii-shield-benchmark", "openpii-1m", split="train")
r = ds[0]
for s in r["spans"]:
print(s["entity"], repr(r["text"][s["start"]:s["end"]]))
```
Each config directory also contains a `sample.jsonl` with 100 stride-sampled records for
quick inspection without loading anything, and `manifest.json` at the repository root
records per-source input/output counts, drops and flag histograms for the build.
## Licensing and attribution
The compilation is published under CC-BY-4.0. Individual configs remain governed by their
source licenses listed above; the mapa text originates from EUR-LEX and is reused under
the European Commission's reuse policy (Decision 2011/833/EU). Please cite the original
datasets when you use the corresponding configs: ai4privacy, NVIDIA, Gretel, the privy
generator authors, and the MAPA project.