Italian NER for Browser-Only PII Anonymization (DistilBERT, Quantized ONNX)
A lightweight Italian Named Entity Recognition model optimized for browser-only inference, based on:
osiria/distilbert-italian-cased-ner
License: Apache-2.0
Original authors: Osiria
This repository provides a quantized ONNX version (~65 MB) suitable for running entirely in the browser via Transformers.js.
What this model is for
This model is designed as a privacy-friendly pre-filter layer to detect and help anonymize:
- Person names (PER)
- Organizations (ORG)
- Locations (LOC)
- Miscellaneous named entities (MISC)
Typical use case:
Run NER locally in the user's browser before sending text to an LLM, masking personal identifiers first.
All inference can run client-side.
Why this version
Compared to the original PyTorch model:
- Converted to ONNX
- Dynamically quantized
- Reduced payload to ~65 MB
- Optimized for ONNX Runtime Web
- Suitable for fully local browser execution
A ~65 MB download is roughly comparable to streaming 1–2 minutes of HD video (4–5 Mbps).
Model Details
Base model: osiria/distilbert-italian-cased-ner
Architecture: DistilBERT
Task: Token Classification (NER)
Language: Italian
This repository does not retrain the model.
It provides:
- ONNX export
- Quantized weights
- Transformers.js-compatible structure
Test it directly
You can test the model directly using the Hugging Face widget on this page.
Example text:
Il paziente Mario Rossi, nato il 12/04/1987, vive a Milano e lavora per l'Agenzia Spaziale Italiana.
Expected entities include:
- Mario Rossi → PER
- Milano → LOC
- Agenzia Spaziale Italiana → ORG
Use in the Browser (Transformers.js)
1import { pipeline, env } from "@huggingface/transformers";
2
3env.allowRemoteModels = true;
4env.backends.onnx.wasm.simd = true;
5env.backends.onnx.wasm.numThreads = 2;
6
7const ner = await pipeline(
8 "token-classification",
9 "laibniz/italian-ner-pii-browser-distilbert",
10 {
11 quantized: true,
12 aggregation_strategy: "simple"
13 }
14);
15
16const text = "Il paziente Mario Rossi vive a Milano.";
17const entities = await ner(text);
18console.log(entities);
All inference runs locally in the browser.
Privacy & Deployment
This model is intended for:
- Browser-based anonymization layers
- On-premise deployments
- Environments where raw text must not leave the device
It should be combined with:
- Regex-based detectors (email, IBAN, VAT, tax ID, phone numbers)
- Post-processing logic
- Manual validation for high-stakes use cases
This is not a full anonymization system by itself.
Limitations
- Quantization may slightly reduce precision/recall
- Domain-specific texts (medical, legal, dialectal Italian) may require fine-tuning
- Token-level predictions require aggregation logic
Attribution
This work builds upon:
All credit for original model training and dataset preparation belongs to the original authors.
This repository provides ONNX export and quantized packaging for browser use.
Custom Privacy-Friendly Setups
If you need:
- Domain-specific anonymization
- Clinical or legal tuning
- On-premise secure deployment
- Integration with LLM pipelines
Feel free to reach out.