Token Classification
Transformers
Safetensors
lfm2
liquid
lfm2.5
bidirectional
masked-lm
encoder
pii
ner
privacy
multilingual
custom_code
Run this model with HF Jobs
Run LiquidAI/LFM2.5-Encoder-350M-PII-Detector on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/LiquidAI/LFM2.5-Encoder-350M-PII-Detector. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/LiquidAI/LFM2.5-Encoder-350M-PII-Detector on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
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)# pip install -U transformers accelerate # 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 files4 unmodified lines5678910111213141516171819202122232425262710 unmodified lines383940414243444546474849505152535455565758596061626364656667686970715 unmodified lines77787980814 unmodified linestags: [pii, ner, privacy, multilingual, token-classification]---# LiquidAI/pii-detect (v14)Multilingual PII detection — a full fine-tune of the bidirectional **LFM2.5-350M** MLMencoder with a token-classification head, covering **40 PII types** across **16 languages**(en, de, fr, es, pt, it, pl, ru, zh, ja, ko, ar, hi, id, vi, th). Ships with aninference-time **hybrid regex decode** (`pii_hybrid_decode.py`) that adds validator-gatedformats (email/IBAN/credit-card/IP/JWT/…) and cue-gated IDs on top of the model, fixingbyte-BPE boundary fragmentation.**v14** is trained on a persona-driven, gemma-generated synthetic corpus (coherentlocale-personas × scenarios × cue/inline/structured embedding, LLM-judge-filtered,contamination-cleaned against all eval sets).## Entity types (40 PII types across 11 domains)The model emits canonical `type` labels (BIOES token classification + an inference-time hybrid regex decode for format-bound types). Full label set:| Domain | Types ||---|---|| **Identity** | `identity.person_name`, `identity.ssn`, `identity.national_id`, `identity.passport`, `identity.drivers_license`, `identity.date_of_birth`, `identity.tax_id` |10 unmodified lines## Benchmarks (18-locale-filtered, partial-F1, hybrid decode)Comparison vs the prior release (v8) and external models (SauerkrautLM-LFM2.5-GLiNER, theLFM ShieldFlow demo q4). All on identical, contamination-cleaned, 16-language splits.| Benchmark | **v14** | v8 (prev) | GLiNER | LFM-demo-q4 ||---|---|---|---|---|| SPY | **0.388** | 0.351 | 0.280 | 0.192 || Gretel | **0.765** | 0.758 | 0.663 | 0.804 || TAB | **0.789** | 0.749 | 0.685 | 0.490 || ai4privacy | **0.557** | 0.643 | 0.488 | 0.500 || Nemotron | **0.782** | 0.773 | 0.639 | 0.656 || MAPA | **0.157** | 0.486 | 0.416 | 0.250 || Internal (40-type) | **0.628** | 0.616 | 0.479 | 0.466 || ShieldFlow proxy | **0.838** | 0.847 | 0.646 | 0.839 || ShieldFlow proxy-xl | **0.841** | 0.797 | 0.658 | 0.842 |### Honest notes- **v14 beats both external models** (GLiNER, LFM-demo) on the general/multilingualbenchmarks (TAB, Nemotron, Internal, SPY, Gretel) and **matches the LFM-demo on its ownShieldFlow distribution**, where it is the in-distribution incumbent.- **Two regressions vs v8** to be transparent about: **MAPA** (v14 0.157 vs v8 0.486) — abenchmark-convention conflict (MAPA labels citation dates as `date_of_birth`, whichconflicts with TAB where dates are not PII; v14 follows the standard convention) — and**ai4privacy** (v14 0.557 vs v8 0.643; note ai4privacy is in the backbone's pretraining).- **Detection-tier** (does it find the PII span, ignoring fine type — the metric thatmatters for redaction) is markedly higher than exact-type across the board (≈0.77–0.85internal/general), i.e. the strict per-type F1 understates real detection.## Usage```python5 unmodified linestok = AutoTokenizer.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True)m = AutoModelForTokenClassification.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True).eval()spans = hd.predict("Email Dr. Laura Schmidt at laura@charite.de about Marco Bianchi.", tok, m)# -> [{'type':'identity.person_name','text':'Laura Schmidt',...}, {'type':'contact.email',...}, ...]```4 unmodified lines5678910111213141516171819202122232410 unmodified lines353637383940414243444546474849505152535455565758595 unmodified lines656667684 unmodified linestags: [pii, ner, privacy, multilingual, token-classification]---# LiquidAI/pii-detectMultilingual PII detection — a full fine-tune of a **bidirectional LFM2.5 phase-2 MLM encoder**with a token-classification head, covering **40 PII types** across **16 languages**(en, de, fr, es, pt, it, pl, ru, zh, ja, ko, ar, hi, id, vi, th). Ships with an inference-time**hybrid regex decode** (`pii_hybrid_decode.py`) that adds validator-gated formats(email/IBAN/credit-card/IP/JWT/…) and cue-gated IDs on top of the model.Trained on a persona-driven, gemma-generated synthetic corpus (coherent locale-personas ×scenarios × cue/inline/structured embedding × ID-contrastive disambiguation), LLM-judge-filteredand contamination-cleaned against all evaluation sets.## Entity types (40 PII types across 11 domains)| Domain | Types ||---|---|| **Identity** | `identity.person_name`, `identity.ssn`, `identity.national_id`, `identity.passport`, `identity.drivers_license`, `identity.date_of_birth`, `identity.tax_id` |10 unmodified lines## Benchmarks (18-locale-filtered, partial-F1, hybrid decode)| Benchmark | **this model** | detection-tier | prev (v8) | GLiNER | LFM-demo-q4 ||---|---|---|---|---|---|| SPY | **0.428** | 0.509 | 0.351 | 0.280 | 0.192 || Gretel | **0.880** | 0.885 | 0.758 | 0.663 | 0.804 || TAB | **0.867** | 0.888 | 0.749 | 0.685 | 0.490 || ai4privacy | **0.715** | 0.774 | 0.643 | 0.488 | 0.500 || Nemotron | **0.855** | 0.863 | 0.773 | 0.639 | 0.656 || MAPA | **0.236** | 0.267 | 0.486 | 0.416 | 0.250 || Internal (40-type) | **0.720** | 0.829 | 0.616 | 0.479 | 0.466 || ShieldFlow | **0.901** | 0.911 | 0.847 | 0.646 | 0.839 || ShieldFlow-xl | **0.859** | 0.871 | 0.797 | 0.658 | 0.842 |- **Best overall** across general/multilingual benchmarks and the ShieldFlow product gate; beatsSauerkrautLM-GLiNER and the LFM demo on every benchmark except MAPA's idiosyncraticdate-as-`date_of_birth` labeling convention.- **Detection-tier** (did it find the PII span, ignoring fine type — the metric that matters forredaction) is markedly higher than exact-type, e.g. Internal 0.83 / ShieldFlow 0.91.## Usage```python5 unmodified linestok = AutoTokenizer.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True)m = AutoModelForTokenClassification.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True).eval()spans = hd.predict("Email Dr. Laura Schmidt at laura@charite.de about Marco Bianchi.", tok, m)```
README.md+25-38