vectorsense's picture
Publish PiiScan
e39cfed verified
|
Raw History Blame Contribute Delete
4.27 kB

Sample training documents

This directory is the authoring area for PiiScan training and retraining examples. It contains one JSONL file for every required v1 canonical entity type in plan.md.

The committed rows are synthetic format examples only. They demonstrate the schema and are not a sufficient training set or a gold benchmark. Do not add real PII or PHI to this repository.

File organization

  • A file is named after its primary canonical type, for example email_address.jsonl.
  • Every non-empty line is one JSON object and one independently processable document.
  • Each file should contain positive examples for its primary type and realistic hard negatives.
  • If a document contains other PII, annotate every entity even when it belongs to another file.
  • Put multilingual examples in the same type file and identify them with BCP 47 language and ISO 3166-1 alpha-2 country values.
  • Keep final validation and blind test records outside this folder under access control.

Required row shape

{
  "id": "globally-unique-record-id",
  "taxonomy_version": "1.0.0",
  "text": "alex.morgan@example.test is the account email.",
  "language": "en",
  "country": "US",
  "domain": "support",
  "entities": [
    {
      "start": 0,
      "end": 24,
      "type": "EMAIL_ADDRESS",
      "subtype": "work"
    }
  ],
  "source": "synthetic-sample",
  "synthetic": true,
  "review_status": "unreviewed",
  "split": "train"
}

subtype may be null. Extra provenance fields are allowed, including source_revision, template_id, subject_group, license_id, annotator_ids, and adjudication_status.

Span rules

  • start is zero-based and inclusive.
  • end is zero-based and exclusive.
  • Offsets address the exact, unmodified value in text.
  • text[start:end] must equal the entity text intended for training.
  • Annotate repeated values separately.
  • Do not include labels such as email: or surrounding punctuation in a value span.
  • Annotate the smallest complete semantic span, subject to the taxonomy guidance in plan.md.

Positive and negative examples

A positive row has at least one entity. A hard-negative row has an empty entities array and should look plausibly confusable with the target type. Aim for 30-40% hard negatives in generated training data, but control the final ratio during dataset assembly rather than duplicating rows here.

Several committed identifiers intentionally use reserved, illustrative, or checksum-invalid values. They are suitable for demonstrating contextual annotation but not for testing a checksum validator. Validator-positive suites must use standards-approved test values or controlled ephemeral generation and must never introduce a real person's identifier.

Adding data safely

  1. Create synthetic or explicitly approved source text.
  2. Assign a globally unique, non-identifying id.
  3. Annotate all spans against the original text.
  4. Set accurate provenance and review status. Never mark generated examples as human gold.
  5. Keep one generated identity and template family in only one train/validation/test split.
  6. Run the validator before dataset assembly:
python sample-training-docs/validate.py

The validator checks the manifest, file/type mapping, JSON syntax, unique IDs, required fields, and the original-text span invariant. The future scripts/build_dataset.py will perform deeper license, near-duplicate, split-leakage, and minimum-coverage checks.

Retraining contract

Training does not consume this directory directly. Every training or retraining run must first build and validate the canonical dataset:

python sample-training-data/validate.py
python scripts/build_training_data.py
python scripts/validate_training_data.py

The builder copies valid authored rows without changing text, entities, offsets, or splits; it adds only missing source-revision provenance. It then normalizes enabled downloaded sources through configs/training-data-mappings.json. The independent validator rejects unknown entity types, invalid spans, duplicate IDs, cross-split exact-text leakage, stale mapping/schema fingerprints, and manifest count differences. Model training must read only prepared-training-data.