rizzoaiacademy/rizzo-pii-0.3B
rizzo-pii · 0.3B Local, reversible PII detection for Italian legal text Use frontier models without giving up your data. --- rizzo-pii-0.3B is a lightweight, CPU-friendly, Italian-first token-classification model (≈0.3B parameters, mmBERT(https://hu...
Featured achievements
The project's latest awards
#1 Repository of the month
#1 Repository of the month
#1 Repository of the month
rizzo-pii · 0.3B
Local, reversible PII detection for Italian legal text
Use frontier models without giving up your data.
rizzo-pii-0.3B is a lightweight, CPU-friendly, Italian-first token-classification model
(≈0.3B parameters, mmBERT / ModernBERT backbone)
that detects 22 categories of personal data — including the Italian legal identifiers
(codice fiscale, partita IVA, dati catastali) that no other open model covers — to
drive a fully reversible anonymization workflow:
your document → [FULLNAME_1], [IBAN_1], [CF_1] … + local dictionary → closed LLM API → reconstruction
The sensitive values never leave your machine. Only the placeholders go to the API; the local dictionary rebuilds the original from the model's answer. Built for law firms and GDPR compliance.
| 🇮🇹 Italian-first | trained multilingually (8 languages from Ai4Privacy) |
| 🧾 5 IT-legal tags | CF, PIVA, CATASTO, DOCID, PROVINCE — missing from every other PII model |
| 💻 Runs on CPU | ~0.5 GB RAM, no GPU, no API key |
| 🔁 Reversible | designed for anonymize → call LLM → de-anonymize |
| 📦 8192-token context | native (ModernBERT architecture) |
🚀 Quick start
from transformers import pipeline
nlp = pipeline(
"token-classification",
model="rizzoaiacademy/rizzo-pii-0.3B",
aggregation_strategy="simple", # merges B-/I- subwords into whole entities
)
text = ("Mi chiamo Mario Rossi, codice fiscale RSSMRA85M01H501Z, "
"IBAN IT60X0542811101000000123456, email mario.rossi@gmail.com.")
for ent in nlp(text):
print(f"{ent['entity_group']:<14} {ent['word']!r} ({ent['score']:.2f})")
# FULLNAME 'Mario Rossi' (1.00)
# CF 'RSSMRA85M01H501Z' (1.00)
# IBAN 'IT60X0542811101000000123456' (1.00)
# EMAIL 'mario.rossi@gmail.com' (1.00)
🔁 Reversible anonymization (the intended use)
def anonymize(text, ents):
"""Replace each entity with a numbered placeholder; keep a reversible dictionary."""
mapping, out, counters = {}, text, {}
for e in sorted(ents, key=lambda x: x["start"], reverse=True):
g = e["entity_group"]
counters[g] = counters.get(g, 0) + 1
tag = f"[{g}_{counters[g]}]"
mapping[tag] = text[e["start"]:e["end"]]
out = out[:e["start"]] + tag + out[e["end"]:]
return out, mapping
anon, table = anonymize(text, nlp(text))
# anon -> "Mi chiamo [FULLNAME_1], codice fiscale [CF_1], IBAN [IBAN_1], email [EMAIL_1]."
# table -> {"[CF_1]": "RSSMRA85M01H501Z", ...} # stays local; use it to rebuild the LLM reply
💡 Production tip: always pair the model with a regex + checksum safety net for structured fields (EMAIL / TELEPHONE / IBAN / CF / PIVA / credit-card / amount / plate). IBAN, CF, PIVA and card numbers are mathematically verifiable — let the checksum override the model when they disagree. This is exactly what the rizzo-pii desktop app does.
🏷️ The 22 PII categories
| Group | Tags |
|---|---|
| People | FULLNAME, GENDER, AGE |
| Contact | EMAIL, TELEPHONENUM |
| Location | STREET, BUILDINGNUM, CITY, ZIPCODE, PROVINCE |
| Financial | IBAN, CREDITCARDNUMBER, AMOUNT |
| IT-legal identifiers 🇮🇹 | CF (codice fiscale), PIVA (partita IVA), CATASTO (dati catastali), DOCID, ID_DOC |
| Other | ORG, DATE, TIME, TARGA (plate) |
Labels use the BIO scheme → 44 label ids (B-/I- per tag + O).
Full taxonomy and merge rules in the project docs.
📊 Evaluation
Entity-level metrics on a held-out Italian validation set (7,000 real sentences; the 5 IT-legal tags injected into held-out real text — real context, no leakage):
| Metric | Train (eval subset) | Validation (IT) |
|---|---|---|
| Precision | 0.9981 | 0.9876 |
| Recall | 0.9986 | 0.9900 |
| micro-F1 | 0.9984 | 0.9888 |
| Token accuracy | 0.9997 | 0.9985 |
Validation is Italian-only by design (the real use case is the IT legal domain). The training is multilingual, but the other 7 languages are not validated here.
🧠 Training
- Base model:
jhu-clsp/mmBERT-base(multilingual encoder, ModernBERT architecture, native 8192 context). Chosen over vanilla ModernBERT because the latter is almost English-only. - Data: ≈745k rows fused from 4 sources (multilingual; Italian reinforced to ~45%, ~38% synthetic). See the dataset: 🤗 rizzoaiacademy/rizzo-pii-it-dataset.
- Recipe: 1 epoch,
max_len=768, effective batch 32, dynamic padding,group_by_length. - Hardware: single RTX 5060 Ti (Blackwell, 16 GB).
Key idea: "LLM as author, code as labeler"
Synthetic data is generated by letting an LLM write only the prose with placeholders, while code injects the values. This gives exact BIO labels, mathematically valid checksums (CF/PIVA/IBAN), and guarantees no real PII is ever produced by the LLM.
⚠️ Limitations & honest expectations
- Structural overfit risk on tags that come only from templates (
CATASTO,PROVINCE) — mitigated with 72 templates, real-text augmentation, and DeepMount real context. - Italian-only validation — the 7 non-IT languages are not measured.
- Class imbalance —
FULLNAME≫CREDITCARDNUMBER(~66×), so rare tags are noisier. - Always add a regex+checksum net in production. The model is the recall engine; the checksum is the precision guarantee for structured identifiers.
🔗 Links
- 💻 App + code (GitHub): https://github.com/Rizzo-AI-Academy/rizzo-pii — Windows installer, Flask/Tauri UI
- 📚 Training dataset: https://huggingface.co/datasets/rizzoaiacademy/rizzo-pii-it-dataset
- 📄 Full technical report (PDF) in the GitHub repo
📄 License
MIT © 2026 Simone Rizzo — Rizzo AI Academy
📌 Citation
@software{rizzo_pii_2026,
author = {Simone Rizzo},
title = {rizzo-pii: local reversible PII anonymization for Italian legal text},
year = {2026},
url = {https://huggingface.co/rizzoaiacademy/rizzo-pii-0.3B},
note = {mmBERT/ModernBERT token classification, 22 PII categories}
}
Similar Projects
Discover other similar projects and AI models.
FlagEmbedding Model List | FAQ | Usage | Evaluation | Train | Contact | Citation | License More details please refer to our Github: FlagEmbedding(https://github.com/FlagOpen/FlagEmbedding). If you are looking for a model that supports more languages,...
all-MiniLM-L6-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic search. Usage (Sentence-Transformers) Using t...
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2 This is a sentence-transformers(https://www.SBERT.net) model: It maps sentences & paragraphs to a 384 dimensional dense vector space and can be used for tasks like clustering or semantic se...
GLiNER2-PII: Multilingual PII Detection & Masking GLiNER2-PII is a fine-tune of the GLiNER2(https://github.com/fastino-ai/GLiNER2) model (205M parameters) for detecting and masking personally identifiable information across 42 entity types and 7 lan...
GPT-2 Test the whole generation capabilities here: https://transformer.huggingface.co/doc/gpt2-large Pretrained model on English language using a causal language modeling (CLM) objective. It was introduced in this paper(https://d4mucfpksywv.cloudfro...
Cross-Encoder for MS Marco This model was trained on the MS Marco Passage Ranking(https://github.com/microsoft/MSMARCO-Passage-Ranking) task. The model can be used for Information Retrieval: Given a query, encode the query will all possible passages...
BERT base model (uncased) Pretrained model on English language using a masked language modeling (MLM) objective. It was introduced in this paper(https://arxiv.org/abs/1810.04805) and first released in this repository(https://github.com/google-resear...
OpenAI Privacy Filter OpenAI Privacy Filter is a bidirectional token-classification model for personally identifiable information (PII) detection and masking in text. It is intended for high-throughput data sanitization workflows where teams need a...
bert-base-NER If my open source models have been useful to you, please consider supporting me in building small, useful AI models for everyone (and help me afford med school / help out my parents financially). Thanks! Model description bert-base-NER...