Modeltoken-classification
rizzoaiacademy

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...

25likes
4.1kdownloads
0views

Featured achievements

The project's latest awards

1
TINIX TRENDING·Topic: base_model:jhu-clsp/mmBERT-base

#1 Repository of the month

1
TINIX TRENDING·Topic: base_model:quantized:jhu-clsp/mmBERT-base

#1 Repository of the month

1
TINIX TRENDING·Topic: mmbert

#1 Repository of the month

rizzo-pii mascot — a purple hedgehog guarding a document with a shield

rizzo-pii · 0.3B

Use frontier models without giving up your data.

100% local GDPR by design EU AI Act aligned

0.3B parameters 0.5 GB RAM CPU 22 PII categories 0.989 micro-F1 offline, no API key

GitHub Dataset Download for Windows


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-firsttrained multilingually (8 languages from Ai4Privacy)
🧾 5 IT-legal tagsCF, PIVA, CATASTO, DOCID, PROVINCE — missing from every other PII model
💻 Runs on CPU~0.5 GB RAM, no GPU, no API key
🔁 Reversibledesigned for anonymize → call LLM → de-anonymize
📦 8192-token contextnative (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

GroupTags
PeopleFULLNAME, GENDER, AGE
ContactEMAIL, TELEPHONENUM
LocationSTREET, BUILDINGNUM, CITY, ZIPCODE, PROVINCE
FinancialIBAN, CREDITCARDNUMBER, AMOUNT
IT-legal identifiers 🇮🇹CF (codice fiscale), PIVA (partita IVA), CATASTO (dati catastali), DOCID, ID_DOC
OtherORG, 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):

MetricTrain (eval subset)Validation (IT)
Precision0.99810.9876
Recall0.99860.9900
micro-F10.99840.9888
Token accuracy0.99970.9985
training loss curve

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.

📄 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}
}
Made with 🦔 by Rizzo AI Academy

Similar Projects

Discover other similar projects and AI models.

Modelfeature-extraction
BAAI/bge-small-en-v1.5

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,...

♥0
41.9M
Feb 22, 2024
Modelsentence-similarity
sentence-transformers/all-MiniLM-L6-v2

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...

♥0
157.6M
Jun 1, 2026
Modelsentence-similarity
sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2

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...

♥0
24.4M
Jan 28, 2026
Modeltoken-classification
fastino/gliner2-privacy-filter-PII-multi

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...

♥0
113.9k
Sep 28, 2026
Modeltext-generation
openai-community/gpt2

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...

♥0
30.6M
Feb 19, 2024
Modeltext-ranking
cross-encoder/ms-marco-MiniLM-L6-v2

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...

♥0
52.2M
Aug 9, 2026
Modelfill-mask
google-bert/bert-base-uncased

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...

♥0
32.4M
Feb 19, 2024
Modeltoken-classification
openai/privacy-filter

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...

♥0
146.2k
Apr 22, 2026
Modeltoken-classification
dslim/bert-base-NER

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...

♥0
1.0M
Oct 8, 2024