Token Classification
Transformers
Safetensors
lfm2
liquid
lfm2.5
bidirectional
masked-lm
encoder
pii
ner
privacy
multilingual
custom_code
Instructions to use LiquidAI/LFM2.5-Encoder-350M-PII-Detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use LiquidAI/LFM2.5-Encoder-350M-PII-Detector with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="LiquidAI/LFM2.5-Encoder-350M-PII-Detector", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("LiquidAI/LFM2.5-Encoder-350M-PII-Detector", trust_remote_code=True) model = AutoModelForTokenClassification.from_pretrained("LiquidAI/LFM2.5-Encoder-350M-PII-Detector", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -5,23 +5,20 @@ pipeline_tag: token-classification
|
|
| 5 |
tags: [pii, ner, privacy, multilingual, token-classification]
|
| 6 |
---
|
| 7 |
|
| 8 |
-
# LiquidAI/pii-detect
|
| 9 |
|
| 10 |
-
Multilingual PII detection — a full fine-tune of
|
| 11 |
-
|
| 12 |
-
(en, de, fr, es, pt, it, pl, ru, zh, ja, ko, ar, hi, id, vi, th). Ships with an
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
byte-BPE boundary fragmentation.
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
contamination-cleaned against all
|
| 20 |
|
| 21 |
## Entity types (40 PII types across 11 domains)
|
| 22 |
|
| 23 |
-
The model emits canonical `type` labels (BIOES token classification + an inference-time hybrid regex decode for format-bound types). Full label set:
|
| 24 |
-
|
| 25 |
| Domain | Types |
|
| 26 |
|---|---|
|
| 27 |
| **Identity** | `identity.person_name`, `identity.ssn`, `identity.national_id`, `identity.passport`, `identity.drivers_license`, `identity.date_of_birth`, `identity.tax_id` |
|
|
@@ -38,34 +35,25 @@ The model emits canonical `type` labels (BIOES token classification + an inferen
|
|
| 38 |
|
| 39 |
## Benchmarks (18-locale-filtered, partial-F1, hybrid decode)
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
| 45 |
-
|
|
| 46 |
-
|
|
| 47 |
-
|
|
| 48 |
-
|
|
| 49 |
-
|
|
| 50 |
-
|
|
| 51 |
-
|
|
| 52 |
-
| Internal (40-type) | **0.628** | 0.616 | 0.479 | 0.466 |
|
| 53 |
-
| ShieldFlow proxy | **0.838** | 0.847 | 0.646 | 0.839 |
|
| 54 |
-
| ShieldFlow proxy-xl | **0.841** | 0.797 | 0.658 | 0.842 |
|
| 55 |
|
| 56 |

|
| 57 |
|
| 58 |
-
|
| 59 |
-
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
benchmark-convention conflict (MAPA labels citation dates as `date_of_birth`, which
|
| 64 |
-
conflicts with TAB where dates are not PII; v14 follows the standard convention) — and
|
| 65 |
-
**ai4privacy** (v14 0.557 vs v8 0.643; note ai4privacy is in the backbone's pretraining).
|
| 66 |
-
- **Detection-tier** (does it find the PII span, ignoring fine type — the metric that
|
| 67 |
-
matters for redaction) is markedly higher than exact-type across the board (≈0.77–0.85
|
| 68 |
-
internal/general), i.e. the strict per-type F1 understates real detection.
|
| 69 |
|
| 70 |
## Usage
|
| 71 |
```python
|
|
@@ -77,5 +65,4 @@ hd = importlib.util.module_from_spec(spec); spec.loader.exec_module(hd)
|
|
| 77 |
tok = AutoTokenizer.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True)
|
| 78 |
m = AutoModelForTokenClassification.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True).eval()
|
| 79 |
spans = hd.predict("Email Dr. Laura Schmidt at [email protected] about Marco Bianchi.", tok, m)
|
| 80 |
-
# -> [{'type':'identity.person_name','text':'Laura Schmidt',...}, {'type':'contact.email',...}, ...]
|
| 81 |
```
|
|
|
|
| 5 |
tags: [pii, ner, privacy, multilingual, token-classification]
|
| 6 |
---
|
| 7 |
|
| 8 |
+
# LiquidAI/pii-detect
|
| 9 |
|
| 10 |
+
Multilingual PII detection — a full fine-tune of a **bidirectional LFM2.5 phase-2 MLM encoder**
|
| 11 |
+
with a token-classification head, covering **40 PII types** across **16 languages**
|
| 12 |
+
(en, de, fr, es, pt, it, pl, ru, zh, ja, ko, ar, hi, id, vi, th). Ships with an inference-time
|
| 13 |
+
**hybrid regex decode** (`pii_hybrid_decode.py`) that adds validator-gated formats
|
| 14 |
+
(email/IBAN/credit-card/IP/JWT/…) and cue-gated IDs on top of the model.
|
|
|
|
| 15 |
|
| 16 |
+
Trained on a persona-driven, gemma-generated synthetic corpus (coherent locale-personas ×
|
| 17 |
+
scenarios × cue/inline/structured embedding × ID-contrastive disambiguation), LLM-judge-filtered
|
| 18 |
+
and contamination-cleaned against all evaluation sets.
|
| 19 |
|
| 20 |
## Entity types (40 PII types across 11 domains)
|
| 21 |
|
|
|
|
|
|
|
| 22 |
| Domain | Types |
|
| 23 |
|---|---|
|
| 24 |
| **Identity** | `identity.person_name`, `identity.ssn`, `identity.national_id`, `identity.passport`, `identity.drivers_license`, `identity.date_of_birth`, `identity.tax_id` |
|
|
|
|
| 35 |
|
| 36 |
## Benchmarks (18-locale-filtered, partial-F1, hybrid decode)
|
| 37 |
|
| 38 |
+
| Benchmark | **this model** | detection-tier | prev (v8) | GLiNER | LFM-demo-q4 |
|
| 39 |
+
|---|---|---|---|---|---|
|
| 40 |
+
| SPY | **0.428** | 0.509 | 0.351 | 0.280 | 0.192 |
|
| 41 |
+
| Gretel | **0.880** | 0.885 | 0.758 | 0.663 | 0.804 |
|
| 42 |
+
| TAB | **0.867** | 0.888 | 0.749 | 0.685 | 0.490 |
|
| 43 |
+
| ai4privacy | **0.715** | 0.774 | 0.643 | 0.488 | 0.500 |
|
| 44 |
+
| Nemotron | **0.855** | 0.863 | 0.773 | 0.639 | 0.656 |
|
| 45 |
+
| MAPA | **0.236** | 0.267 | 0.486 | 0.416 | 0.250 |
|
| 46 |
+
| Internal (40-type) | **0.720** | 0.829 | 0.616 | 0.479 | 0.466 |
|
| 47 |
+
| ShieldFlow | **0.901** | 0.911 | 0.847 | 0.646 | 0.839 |
|
| 48 |
+
| ShieldFlow-xl | **0.859** | 0.871 | 0.797 | 0.658 | 0.842 |
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |

|
| 51 |
|
| 52 |
+
- **Best overall** across general/multilingual benchmarks and the ShieldFlow product gate; beats
|
| 53 |
+
SauerkrautLM-GLiNER and the LFM demo on every benchmark except MAPA's idiosyncratic
|
| 54 |
+
date-as-`date_of_birth` labeling convention.
|
| 55 |
+
- **Detection-tier** (did it find the PII span, ignoring fine type — the metric that matters for
|
| 56 |
+
redaction) is markedly higher than exact-type, e.g. Internal 0.83 / ShieldFlow 0.91.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
## Usage
|
| 59 |
```python
|
|
|
|
| 65 |
tok = AutoTokenizer.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True)
|
| 66 |
m = AutoModelForTokenClassification.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True).eval()
|
| 67 |
spans = hd.predict("Email Dr. Laura Schmidt at [email protected] about Marco Bianchi.", tok, m)
|
|
|
|
| 68 |
```
|