Skip to main content

privyscope-en — English language pack for the privyscope PII engine

Project description

privyscope-en

English PII detection & masking engine — part of the privyscope series. Detects and masks person names, phone numbers, national IDs, emails, addresses, financial info, private dates, and credentials in English text.

⚠️ privyscope is a redaction aid, not an anonymization or compliance guarantee. See Limitations.

Install

pip install privyscope-en

60-second quickstart

Python

from privyscope_en import Privyscope

engine = Privyscope.from_pretrained()                 # downloads ONNX weights on first run
result = engine.redact("John Smith's number is 555-123-4567")

result.masked_text        # "<PER>'s number is <PHONE>"
result.detected_spans     # [DetectedSpan(label="PER", start=0, end=10, ...), ...]
result.summary            # {"span_count": 2, "by_label": {"PER": 1, "PHONE": 1}, ...}

CLI

privyscope redact "John Smith's number is 555-123-4567"
cat notes.txt | privyscope redact --operating-point high_recall

Documentation

Full guides live in docs/ — organised by what you want to do:

I want to… Guide
Run it from the terminal CLI Reference
Call it from Python Python API Reference
Understand the JSON output Output Schemas
Score it on my labelled data Evaluation & Output Modes
Trade precision vs recall Operating Points
Run it offline / air-gapped Offline Usage
Fine-tune on my own data Fine-tuning

Entities

PER · PHONE · ID_NUM · EMAIL · LOC · BANK · DATE · SECRET. Regex patterns live in privyscope/regex_rules.yaml (user-extensible, no code change); EN-specific extended entities in privyscope/entity_config.yaml.

How it works

A two-stage hybrid pipeline (SRS §3.4), results merged via Union:

  1. Regex filter — structurally obvious PII (phone, email, IDs, cards, secrets).
  2. ONNX NER — a BIOES token classifier with a constrained Viterbi decoder for contextual PII (names, addresses, private dates).

Inference is ONNX Runtime only — no PyTorch at runtime. Recall-first, with runtime operating-point tuning (no retraining). PyTorch is needed only to fine-tune.

Model & performance

  • Architectureroberta-base encoder → BIOES token-classification head → constrained Viterbi decoder.

  • Runtime artifact — INT8-quantized ONNX, ~120 MB (under the ≤ 150 MB budget), max sequence length 256. Weights download from Hugging Face Hub on first use, with a SHA-256 checksum.txt for integrity verification.

  • Accuracy — entity-level strict micro-F1 = 0.997 on a held-out validation set (2,000 sentences, disjoint from training; typed/strict scoring over the full regex + NER pipeline). Per-entity strict F1:

    PER LOC DATE ID_NUM BANK PHONE SECRET
    1.00 1.00 1.00 0.99 0.99 0.98 1.00
    (I think it is overfit...)

    (EMAIL is matched deterministically by the regex stage; the sample contained no EMAIL instances.) The set is disjoint from training, so the score reflects generalization rather than memorization — out-of-distribution text (unusual names or contexts) will score lower. Reproduce with privyscope eval --lang en your_val.jsonl; see Evaluation & Output Modes.

Limitations

  • Not an anonymization/compliance guarantee; use as one layer of privacy-by-design.
  • Known failure modes: under-detection of uncommon/regional names; over-redaction of public entities in ambiguous contexts; fragmented spans in heavily mixed-format text; missed SECRET for novel credential formats.
  • Extra human review recommended for medical/legal/financial/government workflows.

License

Apache-2.0. Weights are distributed on Hugging Face Hub under Apache-2.0 with a checksum.txt (SHA-256) for integrity verification. Contributions welcome — see CONTRIBUTING.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

privyscope_en-0.1.2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

privyscope_en-0.1.2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file privyscope_en-0.1.2.tar.gz.

File metadata

  • Download URL: privyscope_en-0.1.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for privyscope_en-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f563bc39e9327bbdade82bd0be9679d232154dd74c2345c8d7e892fe1bab789d
MD5 4a945ccdec3348a777639865c5de5723
BLAKE2b-256 34466aa2c47f60cd7c77f95b1a4b9b67aed20c4b58ee97a8200db8e2eb6be81e

See more details on using hashes here.

File details

Details for the file privyscope_en-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: privyscope_en-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for privyscope_en-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f3f4a401bd9a604821836694a54c4fb652bc1dac0d81a77469711955aaf2c243
MD5 9fe71352d0074263cab9c39e14c922fd
BLAKE2b-256 e4d0f79155b0d8d2b5f0989f71681b6ecb18e280718e02a23945dc2f83700f44

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page