Ritual PII MiniLM
Personal Data and Sensitive Information Detector in Texts
2 min readupdated
The Ritual PII MiniLM model is a specialized token classifier built to detect personal data, secrets, and confidential information in prose, JSON structures, and source code. Based on the microsoft/Multilingual-MiniLM-L12-H384 architecture (12 layers, 384 hidden state size, 0.12 billion parameters) and fine-tuned on crp4222/privaite-pii-minilm, the model outputs annotations for 15 different entity types, including names, addresses, financial data, passwords, and API keys. It comes with a dynamic INT8 ONNX graph for fast CPU inference, making it a valuable tool for developers and security specialists conducting automated text audits.
Key features
- Recognizes 15 entity types, including personal data, financial information, and secrets.
- Optimized for CPU execution using a dynamic INT8 ONNX graph.
- Built on a lightweight multilingual MiniLM architecture with a size of just 0.12 billion parameters.
- Demonstrates improved precision and recall metrics compared to the parent model.
What you can do
- Integrate the detector into text processing pipelines to automatically find and mask PII data.
- Check source code and JSON documents for accidentally exposed passwords and API keys.
- Use the tool to filter datasets before training other language models.
Example
from transformers import AutoTokenizer, AutoModelForTokenClassification
model_id = "Ritual-Net/ritual-pii-minilm"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForTokenClassification.from_pretrained(model_id)
encoded = tokenizer(text, return_tensors="pt", truncation=True)
logits = model(**encoded).logits
Read more
DetailsMetrics: On the test set, the F1-score reached 0.9023 compared to 0.8789 for the parent version.
Hardware: The compact size and ONNX graph with a fixed batch size of 1 are designed for efficient CPU inference.
Limitations: The maximum sequence length is capped at 256 tokens, so long documents are processed using sliding windows.
Training: Fine-tuning took 2 epochs with smooth graph optimization via ONNX Runtime.










Comments