ConwayResearch/pii-30M-mlx-4bit-v1.0

🤗 Hugging Face 来源token-classificationapache-2.018 MBother✓ 1 个校验和29 天前更新
需要做种者 →

PII 30M MLX 4-bit v1.0

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

Designed for browser observations, form content, documents, and application text. The model is English-focused, with additional multilingual training. Applications can use the detected spans to decide which information to retain, replace, or handle locally.

Model details

  • Parameters: 28,502,531 (approximately 28.5 million, in the 30M class).
  • Quantization: affine 4-bit, group size 64, for eligible weight matrices. Other tensors and activations remain float32.
  • Weight file size: approximately 17.9 MB; complete download approximately 19 MB.
  • Architecture: a four-layer BERT token classifier with a 512-token context window. The included runtime handles longer text with overlapping windows.
  • Input: text, including plain text, JSON, HTML, XML, and browser tool output.
  • Output: PII spans with character offsets, or redacted text. Internal labels are O, B-PII, and I-PII.

Fine-tuned and converted to MLX by ConwayResearch. The merged weights, tokenizer, and Python inference runtime are included.

Usage

On an Apple Silicon Mac with Python 3.10 or later, download the repository and install its dependencies:

python -m pip install huggingface-hub
hf download ConwayResearch/pii-30M-mlx-4bit-v1.0 --local-dir pii-model
cd pii-model
python -m pip install -r requirements.txt
python pii.py --text "Contact Alice Smith at alice@example.com."

Use the Python API to keep the model loaded across requests:

from pii import PIIDetector

model = PIIDetector()
text = "Contact Alice Smith at alice@example.com."

print(model.detect(text))
print(model.redact(text))

detect() returns start, end, and label for each span. Offsets use Unicode characters, with an exclusive end: text[start:end]. redact() replaces detected spans with [PII] by default. Inference uses the included MLX runtime and runs locally after download.

License

Apache-2.0. See LICENSE.