Skip to main content

Lightspeed Data Anonymizer

A PII and sensitive-data redaction library for Lightspeed assistants and the Lightspeed AI observability pipeline, maintained by the lightspeed-core team.

Derived from data-anonymizer. This project is seeded from data-anonymizer, built by Red Hat's UXE Data & AI Solutions team for the Ask Red Hat agent, and reused with the authors' permission. The lightspeed-core team maintains this fork and owns its tuning, testing, accuracy, and support for Lightspeed workloads. See NOTICE for attribution.

Introduction

Lightspeed Data Anonymizer is a standalone PII/sensitive-data redaction library for Red Hat AI use cases, implemented as a wrapper around the Presidio SDK.

PII entities that can be processed using data-anonymizer:

  • Email Address
  • Hostname
  • IP Address (IPv4, IPv6)
  • Location
  • Organization (off by default)
  • Person
  • Phone Number
  • URL

Organization names are exempt from anonymization and are left in the text. Detecting them also flags product and technology names such as OpenShift, RHEL and Sosreport, so enable it only if you need it:

anonymizer = PIIAnonymizer(organization=True, allow_list=["RHEL", "OpenShift"])

Locations written in all caps are detected by a second pass over a title cased copy of the text. What it costs depends on the text: roughly 2% on prose with no all caps words, 14% on a typical mixed sentence, and up to 80% on an address block, which is the case that needs it. Turn it off to trade that recall for latency:

anonymizer = PIIAnonymizer(case_normalization=False)

Upgrading from 0.2.0

organization now defaults to False, so organization names that 0.2.0 redacted are left in the text. This is deliberate, for the reason above, but it changes what leaves the library. Callers that relied on the old behaviour have to ask for it:

anonymizer = PIIAnonymizer(organization=True)

Choosing a model

Detection quality is set by the spaCy model behind it. Install en_core_web_lg as the default; en_core_web_trf detects substantially more locations and people, but depends on torch, which adds roughly 500 MB to an image:

Model Locations People Median latency Peak memory Extra dependency
en_core_web_lg (default) 7/23 0/4 ~13 ms ~0.9 GB none
en_core_web_trf 19/23 4/4 ~64 ms ~2.7 GB torch

Memory is usually the deciding factor rather than latency. Check that the environment has the headroom for the transformer before enabling it.

Detection of emails, hostnames, IP addresses and phone numbers is by regex and is identical on both models.

Install models with spaCy (they are not PyPI packages, so they are not pulled in automatically):

python -m spacy download en_core_web_lg      # default
python -m spacy download en_core_web_trf     # also: pip install torch

Both can be installed side by side, so an environment can switch between them without reinstalling. Select the model with the DATA_ANONYMIZER_SPACY_MODEL environment variable, so a deployment can switch without a code change in the calling service:

export DATA_ANONYMIZER_SPACY_MODEL=en_core_web_trf

The spacy_model argument overrides the environment variable:

anonymizer = PIIAnonymizer(spacy_model="en_core_web_trf")

Naming a model that is not installed raises on construction, so a misconfigured environment fails at startup rather than silently anonymizing less than it should.

To always redact specific terms, regardless of what the model detects, pass a deny list. Naming a term here enables its entity type even when that type is otherwise off:

anonymizer = PIIAnonymizer(deny_list={"ORGANIZATION": ["Acme Corp"], "LOCATION": ["Novo mesto"]})

Getting Started

  1. Install the library and a spaCy model.
pip install lightspeed-data-anonymizer
python -m spacy download en_core_web_lg

(From source instead: pip install "git+https://github.com/anik120/lightspeed-data-anonymizer.git".)

  1. Import the PIIAnonymizer
from lightspeed_data_anonymizer.anonymizer import PIIAnonymizer
  1. Instantiate and use the anonymizer.
anonymizer = PIIAnonymizer()

To anonymize a list of strings:
anonymized_list = anonymizer.anonymize_list([str1, str2, str3])

To anonymize a text/string:
anonymized_text = anonymizer.anonymize_text(text)

Metadata

Release files for lightspeed-data-anonymizer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lightspeed-data-anonymizer 0.1.0
File Size Uploaded Provenance
lightspeed_data_anonymizer-0.1.0.tar.gz 15.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for lightspeed-data-anonymizer 0.1.0
File Interpreter ABI Platform
lightspeed_data_anonymizer-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.9 kB

Release files / lightspeed_data_anonymizer-0.1.0.tar.gz

Download URL lightspeed_data_anonymizer-0.1.0.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
60bc6806ebfc45b8b27dc9ce672b576eaeee29ae2655f164ee8d0bd3a18555cc
BLAKE2b-256 checksum
How to use checksums
80daf182f0b76b1ec28176d64e5ea693cd0f8a62ff2133d0670acac040944558
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / lightspeed_data_anonymizer-0.1.0-py3-none-any.whl

Download URL lightspeed_data_anonymizer-0.1.0-py3-none-any.whl
Size 17.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d18d6e7ec41a29dca29359055207f2d5f71060be51758e92f9cae0c4d5c2cf1c
BLAKE2b-256 checksum
How to use checksums
f71503420021a61177e3a816549cdacd0eddc9fcdb4d2b590b90bd320971c4b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for lightspeed-data-anonymizer 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page