Downloads · 30 days
9
2% of all-time downloads
hemanthsaimanne/pii-text-masking
pii-text-masking is a text generation model from hemanthsaimanne. Use it when you need the model to write or continue text. The card lists the license as gemma.
This model is a fine-tuned, privacy-focused variant of Google's Gemma 3 1B Instruction Tuned model. It has been specifically trained using Supervised Fine-Tuning (SFT) to identify, redact, and mask Personally Identifi…
Downloads · 30 days
9
2% of all-time downloads
All-time downloads
519
Public
Parameters
1000M
2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2 GB · 98%
From the Hugging Face model README
This model is a fine-tuned, privacy-focused variant of Google's Gemma 3 1B Instruction Tuned model. It has been specifically trained using Supervised Fine-Tuning (SFT) to identify, redact, and mask Personally Identifiable Information (PII) within unstructured text data.
The model replaces sensitive elements such as Names, Email Addresses, Phone Numbers, Social Security Numbers (SSN), Credit Card details, and IP Addresses with unified entity placeholders (e.g., [NAME], [EMAIL]), ensuring robust compliance with GDPR, HIPAA, and CCPA standards while maintaining the natural linguistic structure of the original document.
This model is configured for causal text generation. To achieve the best PII extraction and masking results, wrap your text in a clear instruction format matching the original Gemma 3 chat template format:
<|im_start|>user
Mask all the PII entities in the following text: "My name is Hemanth and you can reach me at [email protected] or call +919123456789."<|im_end|>
<|im_start|>assistant
My name is [NAME] and you can reach me at [EMAIL] or call [PHONE].<|im_end|>
You can easily run this model using the Hugging Face transformers library (version >= 4.50.0 is required for Gemma 3 architecture):
import torch
from transformers import pipeline
# Initialize the pipeline
pipe = pipeline(
"text-generation",
model="hemanthsaimanne/pii-text-masking",
torch_dtype=torch.bfloat16,
device_map="auto"
)
# Structure your prompt
messages = [
{"role": "user", "content": "Mask all PII (names, emails, phones, etc.) in this text: Contact hemanth at [email protected]."}
]
# Generate masked text
outputs = pipe(messages, max_new_tokens=256)
print(outputs[0]["generated_text"])
# Expected Output: "Contact [NAME] at [EMAIL]."
The model was fine-tuned using the Hugging Face TRL SFTTrainer pipeline under the following parameter adjustments:
bf16)The model was trained on https://www.kaggle.com/datasets/mikedoes/open-pii-masking-500k-ai4privacy
While the model is highly robust, users should review edge-case extractions manually where data formatting is highly non-standard (e.g., heavily misspelled names or disjointed phone numbers). It should be treated as an assistive compliance utility rather than a perfect legal guarantee for total data anonymization.
The model was evaluated on a held-out test dataset containing dense PII extraction scenarios. It achieves near-perfect structural matching and entity alignment, demonstrating high reliability for enterprise data anonymization workflows.
| Metric | Score | Description |
|---|---|---|
| ROUGE-1 | 0.9859 | Unigram overlap; measures single-token entity accuracy. |
| ROUGE-2 | 0.9789 | Bigram overlap; measures multi-word phrase and entity continuity. |
| ROUGE-L | 0.9851 | Longest Common Subsequence; evaluates structural syntax matching. |
| ROUGE-Lsum | 0.9852 | Summary-level structural match across multi-sentence text. |