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:
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.
1from transformers import pipeline
2
3nlp = pipeline(
4 "token-classification",
5 model="rizzoaiacademy/rizzo-pii-0.3B",
6 aggregation_strategy="simple", # merges B-/I- subwords into whole entities
7)
8
9text = ("Mi chiamo Mario Rossi, codice fiscale RSSMRA85M01H501Z, "
10 "IBAN IT60X0542811101000000123456, email mario.rossi@gmail.com.")
11
12for ent in nlp(text):
13 print(f"{ent['entity_group']:<14} {ent['word']!r} ({ent['score']:.2f})")
14
15# FULLNAME 'Mario Rossi' (1.00)
16# CF 'RSSMRA85M01H501Z' (1.00)
17# IBAN 'IT60X0542811101000000123456' (1.00)
18# EMAIL 'mario.rossi@gmail.com' (1.00)
1def anonymize(text, ents):
2 """Replace each entity with a numbered placeholder; keep a reversible dictionary."""
3 mapping, out, counters = {}, text, {}
4 for e in sorted(ents, key=lambda x: x["start"], reverse=True):
5 g = e["entity_group"]
6 counters[g] = counters.get(g, 0) + 1
7 tag = f"[{g}_{counters[g]}]"
8 mapping[tag] = text[e["start"]:e["end"]]
9 out = out[:e["start"]] + tag + out[e["end"]:]
10 return out, mapping
11
12anon, table = anonymize(text, nlp(text))
13# anon -> "Mi chiamo [FULLNAME_1], codice fiscale [CF_1], IBAN [IBAN_1], email [EMAIL_1]."
14# table -> {"[CF_1]": "RSSMRA85M01H501Z", ...} # stays local; use it to rebuild the LLM reply
Labels use the
BIO scheme →
44 label ids (
B-/
I- per tag +
O).
Full taxonomy and merge rules in the
project docs.
1@software{rizzo_pii_2026,
2 author = {Simone Rizzo},
3 title = {rizzo-pii: local reversible PII anonymization for Italian legal text},
4 year = {2026},
5 url = {https://huggingface.co/rizzoaiacademy/rizzo-pii-0.3B},
6 note = {mmBERT/ModernBERT token classification, 22 PII categories}
7}