PII 30M MLX 4-bit v1.1

A compact model for local detection and redaction of personally identifiable information (PII), packaged for Apple Silicon with MLX.

Version 1.1 labels every span with what it is, so redacted text stays readable:

Hi, I am Alice Smith, a nurse in Oakland. Call me at (510) 555-0123.
Hi, I am [PERSON], a nurse in Oakland. Call me at [PHONE].

Designed for browser observations, form content, documents and application text. The model is English-focused, with additional multilingual coverage.

Labels

The model labels 21 classes. By default redact() replaces the first 14, which identify a person or grant access, and keeps the other 7, which are detected but usually harmless and make text easier to read. Pass your own set to change this.

Redacted by default Detected, kept by default
PERSON names DATE_TIME dates and times
EMAIL email addresses LOCATION cities, states, countries
PHONE phone and fax numbers ORGANIZATION companies and institutions
STREET_ADDRESS streets, house numbers, postal codes TITLE titles and honorifics
COORDINATE geographic coordinates URL web addresses
DATE_OF_BIRTH dates of birth DEMOGRAPHIC age, gender, nationality, language
GOV_ID government and license numbers OCCUPATION occupation, education, employment status
HEALTH_ID medical record and health plan numbers
FINANCIAL card, bank account and IBAN numbers
CREDENTIAL passwords, PINs, API keys, cookies
USERNAME user names
ACCOUNT_ID customer and employee IDs
NETWORK_ID IP and MAC addresses, device IDs
SENSITIVE_TRAIT religion, ethnicity, political views, sexuality, blood type

Pattern rules

Beside the model, pii_rules.py finds email addresses, payment card numbers (Luhn checksum), IBANs (country format and mod-97 checksum), IP addresses and US social security numbers. A rule match the model missed, or labeled only in part, takes the rule's label; a match the model labeled in full keeps the model's label. Rules are on by default; pass rules=False (or --no-rules) for the model alone.

Model details

  • Parameters: 28,523,051 (approximately 28.5 million, in the 30M class). Post-trained from gravitee-io/bert-small-pii-detection.
  • Quantization: affine 4-bit, group size 64, for the embedding and encoder weight matrices. The classifier, other tensors and activations remain float32.
  • Weight file size: approximately 18.0 MB; complete download approximately 19 MB.
  • Architecture: a four-layer BERT token classifier with a 512-token context window and BIO tags for each class (43 outputs). The included runtime handles longer text with overlapping windows.
  • Input: text, including plain text, JSON, HTML, XML and browser tool output.

Usage

On an Apple Silicon Mac with Python 3.10 or later:

python -m pip install huggingface-hub
hf download ConwayResearch/pii-30M-mlx-4bit-v1.1 --local-dir pii-model
cd pii-model
python -m pip install -r requirements.txt
python pii.py --text "Hi, I am Alice Smith. Call me at (510) 555-0123."

Keep the model loaded across requests:

from pii import PIIDetector

model = PIIDetector()
text = "Hi, I am Alice Smith, a nurse in Oakland. Call me at (510) 555-0123."

model.detect(text)                       # [{'start': 9, 'end': 20, 'label': 'PERSON'}, ...]
model.redact(text)                       # default set: "Hi, I am [PERSON], a nurse in Oakland. Call me at [PHONE]."
model.redact(text, labels=None)          # every label
model.redact(text, labels={"PERSON"}, replacement="***")

detect() returns start, end and label for each span. Offsets use Unicode characters with an exclusive end: text[start:end]. Inference runs locally after download.

License

CC BY-NC 4.0 (see LICENSE). You can use, share and adapt it for non-commercial purposes with credit to Underdog. Commercial use needs a separate license: write to license@conway.tech.

Upstream components keep their original licenses: the base model under Apache-2.0 (see LICENSE-APACHE), and the pattern rules, adapted from Microsoft Presidio, under MIT (see LICENSE-MIT).

Downloads last month
31
MLX
Hardware compatibility
Log In to add your hardware

Quantized

Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for LoyalAI/pii-30M-mlx-4bit-v1.1

Finetuned
(8)
this model
Quantizations
1 model