Skip to main content

Privacy-preserving PII redaction for AI pipelines. Real data never leaves your machine.

Project description

VeilPhantom

Privacy-preserving PII redaction for AI pipelines. Real data never leaves your machine.

from veil_phantom import VeilClient

veil = VeilClient()
result = veil.redact("John Smith sent $5M to john@acme.com")

result.sanitized   # "[PERSON_1] sent [AMOUNT_1] to [EMAIL_1]"
result.rehydrate(ai_response)  # restore originals in AI output

Install

pip install veil-phantom

What it detects

12 entity types with a 25-label BIO scheme:

Type Examples
PERSON Names (Western, African, Asian, South African)
ORG Companies, institutions, financial firms
EMAIL Standard and spoken format ("john at example dot com")
PHONE International, SA, spoken digit sequences
MONEY USD, ZAR, verbal ("twelve point five million dollars")
DATE Formats, relative, spoken ordinals
ADDRESS Street addresses, locations, URLs/domains
GOVID SSN, SA ID, passport, driver's license
BANKACCT Account numbers, IBAN
CARD Credit/debit card numbers
IPADDR IPv4 addresses
CASE Legal case numbers

How it works

7-layer detection pipeline, each layer catching what others miss:

Input text
  → Layer 0: Shade V7 NER (PhoneticDeBERTa, 22M params, dual-pass inference)
  → Layer 1: Compound org gazetteers + financial institutions
  → Layer 1.5: Pre-regex critical patterns (IBAN, spoken email)
  → Layer 2: NLP entity detection with POS validation
  → Layer 3: Regex patterns (18 types) + URL/domain filtering
  → Layer 5: Contextual sensitivity (roles, situations, temporal)
  → Tokens: [PERSON_1], [ORG_1], [AMOUNT_1]
  → Send to LLM (PII never leaves your machine)
  → Rehydrate AI response with original values

Powered by Shade V7

Shade V7 (default): PhoneticDeBERTa with Double Metaphone embeddings, 22M params, 97.12% F1, <50ms inference. Dual-pass inference (phonetic + zero-phonetic) picks the best result. Segment rescue for long transcripts. Auto-downloaded from HuggingFace Hub on first use.

Shade V5 (fallback): DeBERTa-v3-xsmall, 22M params, 97.6% F1 in-distribution, 97.3% OOD. Used automatically if V7 model is not present.

Full pipeline (all 7 layers): 100% detection on 24 real meetings (399 entities, 0 leaked).

Model Parameters F1 Score Notes
Shade V7 22M 97.12% Default, on-device, <50ms, phonetic embeddings
Shade V5 22M 97.6% / 97.3% OOD Fallback
GLiNER 209M 98.0% Cloud API required
Kaggle 1st 1.5B 97.0% Ensemble, slow

Configuration

from veil_phantom import VeilClient, VeilConfig

# All layers (default)
veil = VeilClient()

# Regex + contextual only (no model download needed)
veil = VeilClient(config=VeilConfig.regex_only())

# Maximum privacy (lower thresholds)
veil = VeilClient(config=VeilConfig.max_privacy())

# Custom whitelist
veil = VeilClient(config=VeilConfig(
    additional_whitelist={"MYCOMPANY", "MYBRAND"},
    additional_compound_orgs={"My Corp Ltd"},
))

LLM Integration

# Token-direct mode (recommended)
result = veil.redact(transcript)
ai_response = your_llm(result.sanitized)  # LLM sees [PERSON_1], [ORG_1]
final = result.rehydrate(ai_response)     # restore original values

# OpenAI wrapper
from veil_phantom.integrations.openai import veil_chat
response = veil_chat(client, messages, veil=veil)

# LangChain
from veil_phantom.integrations.langchain import VeilRunnable
chain = VeilRunnable(veil) | your_chain

Training Data

Shade V7 was trained on 862,000 examples generated from 72 million words:

  • Entity-swap augmentation: 8,606 base → 855,046 examples (100x expansion)
  • Parakeet ASR corruption for speech-realistic noise
  • Contrastive hard negatives for false positive reduction
  • Double Metaphone phonetic embeddings for cross-cultural name robustness
  • Trained on GTX 1050 Ti (accessible compute)

License

Apache 2.0

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

veil_phantom-1.0.2.tar.gz (304.7 kB view details)

Uploaded Source

Built Distribution

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

veil_phantom-1.0.2-py3-none-any.whl (53.7 kB view details)

Uploaded Python 3

File details

Details for the file veil_phantom-1.0.2.tar.gz.

File metadata

  • Download URL: veil_phantom-1.0.2.tar.gz
  • Upload date:
  • Size: 304.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for veil_phantom-1.0.2.tar.gz
Algorithm Hash digest
SHA256 5cc4b815bcae63066ebccc3931f5edd4a0c4d891bf2e8494f8475857b51abf0d
MD5 4f3990584a3d9632d8050c71bdc06c75
BLAKE2b-256 00c451de5384cb5c9ce6e7d1e989a6c006e876ff3e75e41f25f31a90f89cd234

See more details on using hashes here.

File details

Details for the file veil_phantom-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: veil_phantom-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 53.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for veil_phantom-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e011d28c0a982e3f32f508590b4070f516b2f383454e47eab6664c6d47618cd
MD5 e7fe9a79d1bcb3c583b995725331b8e4
BLAKE2b-256 f1ab23d131c37c105c8dc9d970edbe126c582abb64361425aaa5eadbadbf4587

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