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
v7: 40-type multilingual PII + hybrid decode
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187---license: otherlanguage: [en, es, fr, de, it, pt, nl, ru, ar, hi, ja, ko, zh, th, id, vi, tr, pl]pipeline_tag: token-classificationtags: [pii, ner, token-classification, lfm2, multilingual, privacy]---# LiquidAI/pii-detectMultilingual PII detection β a **full fine-tune of the bidirectional LFM2.5-350M MLMencoder** (`v13_encoder_mlm`) with a BIOES token-classification head. Detects ~27canonical PII types across 7 domains and 18 languages.> **Status:** pilot / interim checkpoint (trained on 10M synthetic multilingual docs).> Private β LiquidAI internal.## Usage```pythonfrom transformers import AutoTokenizer, AutoModelForTokenClassificationimport torchtok = AutoTokenizer.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True)model = AutoModelForTokenClassification.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True).eval()text = "Email Jane Doe at jane@acme.com or call +1-202-555-0142."enc = tok(text, return_offsets_mapping=True, return_tensors="pt")off = enc.pop("offset_mapping")[0]with torch.no_grad():pred = model(**enc).logits[0].argmax(-1)labels = [model.config.id2label[i] for i in pred.tolist()]# merge adjacent same-type tokens into spans using `off` + BIOES `labels````- **Labels:** 109 BIOES classes (27 types Γ B/I/E/S + O). See `id2label` in `config.json`.- **Backbone:** bidirectional LFM2.5-350M (MLM-pretrained), full fine-tune (no LoRA).- **Training data:** 10M synthetic multilingual PII documents (entity-first generation).## Public benchmark leaderboard_Black = this model. Gold tick = best score any previous checkpoint reached on thatbenchmark. Ξ (vs the previous run) is annotated under our bars once a second versionis tracked. Hatched benchmarks are train-contaminated for some models._Type-level **micro** scores, **partial-match**. P=precision, R=recall (PII caught),F1, F2 (recall-weighted Ξ²=2 β the metric that matters most for PII). Ours is an**interim checkpoint (βΒΌ of epoch 1)** vs **fully-trained** released baselines.### SPY (969 samples)_clean Β· synthetic Β· tests PII-vs-NER discrimination_| Model | P | R | F1 | F2 ||---|---|---|---|---|| trained:pii-detect-v4 | 0.284 | 0.706 | 0.405 | 0.544 || regex baseline | 0.259 | 0.579 | 0.358 | 0.464 || VAGOsolutions/SauerkrautLM-GLiNER | 0.171 | 0.785 | 0.280 | 0.456 || openai/privacy-filter | 0.169 | 0.595 | 0.264 | 0.396 || iiiorg/piiranha-v1 | 0.159 | 0.422 | 0.230 | 0.317 || OpenMed/privacy-filter-nemotron | 0.143 | 0.545 | 0.226 | 0.348 || LiquidAI demo (LFM2.5-PII-Demo) | 0.132 | 0.350 | 0.192 | 0.263 |### GRETEL (500 samples)_clean Β· synthetic English_| Model | P | R | F1 | F2 ||---|---|---|---|---|| trained:pii-detect-v4 | 0.770 | 0.852 | 0.809 | 0.834 || LiquidAI demo (LFM2.5-PII-Demo) | 0.887 | 0.735 | 0.804 | 0.761 || OpenMed/privacy-filter-nemotron | 0.762 | 0.773 | 0.767 | 0.770 || VAGOsolutions/SauerkrautLM-GLiNER | 0.605 | 0.734 | 0.663 | 0.704 || iiiorg/piiranha-v1 | 0.633 | 0.490 | 0.552 | 0.513 || openai/privacy-filter | 0.455 | 0.462 | 0.459 | 0.461 || regex baseline | 0.500 | 0.254 | 0.337 | 0.281 |### TAB (127 samples)_clean Β· human gold Β· English legal (ECHR)_| Model | P | R | F1 | F2 ||---|---|---|---|---|| trained:pii-detect-v4 | 0.860 | 0.782 | 0.819 | 0.797 || VAGOsolutions/SauerkrautLM-GLiNER | 0.843 | 0.576 | 0.685 | 0.615 || OpenMed/privacy-filter-nemotron | 0.728 | 0.625 | 0.673 | 0.643 || openai/privacy-filter | 0.933 | 0.383 | 0.543 | 0.434 || LiquidAI demo (LFM2.5-PII-Demo) | 0.995 | 0.325 | 0.490 | 0.375 || iiiorg/piiranha-v1 | 0.721 | 0.160 | 0.262 | 0.189 || regex baseline | 0.000 | 0.000 | 0.000 | 0.000 |### MAPA (370 samples)_clean Β· human gold Β· multilingual EU legal_| Model | P | R | F1 | F2 ||---|---|---|---|---|| trained:pii-detect-v4 | 0.445 | 0.541 | 0.488 | 0.518 || VAGOsolutions/SauerkrautLM-GLiNER | 0.487 | 0.258 | 0.337 | 0.285 || iiiorg/piiranha-v1 | 0.465 | 0.181 | 0.261 | 0.206 || openai/privacy-filter | 0.372 | 0.186 | 0.248 | 0.207 || LiquidAI demo (LFM2.5-PII-Demo) | 0.274 | 0.140 | 0.185 | 0.155 || OpenMed/privacy-filter-nemotron | 0.081 | 0.180 | 0.111 | 0.144 || regex baseline | 0.000 | 0.000 | 0.000 | 0.000 |### Contaminated benchmarks (reference only)### NEMOTRON (1000 samples)_β in-distribution for OpenMed-nemotron & nvidia GLiNER (read as ceilings)_| Model | P | R | F1 | F2 ||---|---|---|---|---|| OpenMed/privacy-filter-nemotron | 0.970 | 0.872 | 0.918 | 0.890 || LiquidAI demo (LFM2.5-PII-Demo) | 0.894 | 0.518 | 0.656 | 0.566 || iiiorg/piiranha-v1 | 0.841 | 0.538 | 0.656 | 0.580 || VAGOsolutions/SauerkrautLM-GLiNER | 0.707 | 0.583 | 0.639 | 0.604 || trained:pii-detect-v4 | 0.712 | 0.538 | 0.613 | 0.566 || openai/privacy-filter | 0.699 | 0.484 | 0.572 | 0.516 || regex baseline | 0.645 | 0.227 | 0.335 | 0.260 |### AI4PRIVACY (660 samples)_β in OUR backbone's pretraining β contaminated for us; reference only_| Model | P | R | F1 | F2 ||---|---|---|---|---|| iiiorg/piiranha-v1 | 0.969 | 0.924 | 0.946 | 0.932 || LiquidAI demo (LFM2.5-PII-Demo) | 0.533 | 0.464 | 0.496 | 0.476 || VAGOsolutions/SauerkrautLM-GLiNER | 0.403 | 0.610 | 0.485 | 0.553 || OpenMed/privacy-filter-nemotron | 0.341 | 0.541 | 0.418 | 0.484 || trained:pii-detect-v4 | 0.330 | 0.488 | 0.394 | 0.445 || openai/privacy-filter | 0.316 | 0.492 | 0.385 | 0.443 || regex baseline | 0.269 | 0.147 | 0.190 | 0.162 |## Notes- **Strength:** best-in-class on **SPY** (PII-vs-NER discrimination) with the highest recall of any model tested.- **Gap:** legal-domain benchmarks (TAB/MAPA) β high precision but low recall; targeted for the next data iteration.- Benchmarks use differing entity taxonomies; our fine-grained types are mapped to each via an identity/crosswalk, so type-level F1 understates raw detection (binary detection is higher).## ShieldFlow proxy-traffic product gate (native ShieldFlow taxonomy, partial)Held-out 10% of the v7 proxy corpus; we train on the same 90% the incumbent did andevaluate on the identical untouched holdout (seed-42 split). q4 baseline reproducedexactly in this harness (validates the scoring path).| dataset | **ours (v4)** P / R / F1 | q4 incumbent (reproduced) ||---|---|---|| proxy_traffic_holdout | 0.872 / 0.715 / **0.786** | 0.794 / 0.982 / 0.878 || proxy_traffic_holdout_xlong | 0.793 / 0.767 / **0.780** | 0.834 / 0.940 / 0.884 |v4 has **higher precision** than the incumbent; the F1 gap is **recall** (q4 is tuned fornear-total recall on this workload). Scored in native ShieldFlow space with these newtypes: `developer.login_credentials` (combo span), `developer.device_id`,`healthcare.health_plan_id`.## Internal evaluation (v1) β 40-type, 33-language held-out setA purpose-built held-out benchmark that is our primary feedback signal for modelimprovement: **1,010 documents, all 40 target PII types, 33 languages, 11 domains,72 document types**, with edge cases (PDF-to-text breakage, long context, truncation,structured/tabular layouts) and precision-trap documents. Exact character spans byconstruction (0 offset errors over ~6,500 spans), audited by adversarial review agents.Scored both partial- and exact-match; third-party and unlabelled real-format PII isplaced in `ignore` so a correct detector is never penalised.| model | partial F1 | precision | recall | exact F1 ||---|---|---|---|---|| regex baseline | 0.346 | 0.530 | 0.257 | 0.250 || **v4 (this model)** | 0.471 | 0.588 | 0.394 | 0.163 || v5 (candidate) | 0.497 | 0.770 | 0.367 | 0.152 |This eval is deliberately harder and broader than the public benchmarks; it exposes thegaps that drive the next data iteration:- **Boundary fragmentation** β exact F1 βͺ partial F1: entities are located but mis-bounded.- **Missing-type recall** β ~10 types at near-zero recall: 8 target types not yet emitted(`financial.amount`, `crypto_wallet`, `jwt`, `private_key`, `connection_string`,`device.imei`, `special.orientation`, `special.health_status`) plus `developer.device_id`and `location.gps_coordinates` (regex-offload artifacts).- **Regex-offload recall collapse** on common format types (`contact.email`, `financial.iban`,`identity.tax_id`, `financial.bank_account`, `credential.api_key`).- **Multilingual gaps** β weakest in hi/th/el/ja/ko and several EU languages.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677---license: otherlanguage: [en, de, fr, es, it, nl, pt, pl, ru, zh, ja, ko, ar, hi, id, vi, th, sv, fi, da, el, ro, hu, cs, sk, bg, lt, lv, et, ga, mt]pipeline_tag: token-classificationtags: [pii, ner, privacy, multilingual, token-classification]---# LiquidAI/pii-detect (v7)Multilingual PII detection β a full fine-tune of the bidirectional **LFM2.5-350M** MLMencoder with a token-classification head. **40 PII types** across identity, contact,financial, credential, online, device, location, healthcare, org, legal andspecial-category, over **33 languages**. Ships with an inference-time **hybrid regexdecode** (`pii_hybrid_decode.py`) that fixes byte-BPE boundary fragmentation onformat-bound types.## How to use```pythonimport torchfrom transformers import AutoTokenizer, AutoModelForTokenClassificationfrom huggingface_hub import hf_hub_downloadimport importlib.utilspec = importlib.util.spec_from_file_location("hd", hf_hub_download("LiquidAI/pii-detect","pii_hybrid_decode.py"))hd = importlib.util.module_from_spec(spec); spec.loader.exec_module(hd)tok = AutoTokenizer.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True)model = AutoModelForTokenClassification.from_pretrained("LiquidAI/pii-detect", trust_remote_code=True).eval()print(hd.predict("Email laura@charite.de or call +49 30 4505 1234.", tok, model)) # hybrid decode (recommended)```## EvaluationAll scored through one harness; **type-level micro-F1, partial match** unless noted.Two decodes reported: **base** (token classifier) and **+hybrid** (regex post-processing).v4 is the previous release. NOTE: nemotron & ai4privacy are *contaminated* benchmarks whosepublic leaders were trained in-distribution on those exact corpora (specialist ceilingsβ0.918 / 0.946) β we report them for completeness.### Public benchmarks (type-F1, partial)| benchmark | v4 (prev) | v7 base | v7 +hybrid | notes ||---|---|---|---|---|| SPY (clean, legal/medical) | 0.405 | 0.349 | 0.378 | slightly below v4 β SPY national_id format artifact || TAB (clean, legal/ECHR) | 0.819 | **0.786** | 0.784 | recovered (v6 had 0.677) || Gretel (clean) | 0.809 | **0.822** | 0.809 | β₯ v4 || MAPA (clean, EU legal) | 0.488 | 0.421 | 0.420 | below v4 (rebalance trade-off) || Nemotron (contaminated) | 0.613 | **0.775** | **0.790** | +0.18 vs v4 || AI4Privacy (contaminated) | 0.394 | **0.624** | 0.604 | +0.23 vs v4 |### Internal eval (held-out, 40-type / 33-lang / 6,094 docs; realistic subset, partial / exact)| model | base | +hybrid ||---|---|---|| v6 | (0.4538, 0.0965) | (0.5839, 0.33) || **v7** | (0.4792, 0.1435) | (0.5961, 0.3528) || v4 | (0.4826, 0.1683) | (0.5896, 0.3666) |The hybrid decode roughly **doubles exact-match F1** (e.g. v7 0.143 β 0.353) by fixingsub-token boundary fragmentation on emails, IBANs, phones, dates, SSNs, MACs, etc.### ShieldFlow proxy gate (native taxonomy, partial F1; base / xlong)| | v4 | v7 base | q4 incumbent ||---|---|---|---|| proxy_traffic_holdout | 0.786 | **0.810** (P0.83/R0.80) | 0.878 || proxy_traffic_holdout_xlong | 0.780 | 0.751 | 0.884 |## Honest summaryv7 is a large net improvement over v4: big gains on the contaminated sets (+0.18 / +0.23),the internal eval, and the ShieldFlow gate, plus recovered TAB. It is slightly behind theprevious checkpoint on **SPY** and **MAPA** (a data-rebalance trade-off; SPY's national_idformat is a recall artifact we chose not to overfit to). No single checkpoint dominatesevery benchmark; v7 wins the product-critical signals (internal, ShieldFlow) and mostpublic sets. Contaminated-benchmark specialists trained in-distribution remain ahead ontheir own corpora.## Schema & training40 canonical `domain.type` labels, BIOES (161 classes). Trained on multilingual syntheticdata (gemma-generated, exact char-span labels, PII-vs-NER decoy regime) + the publicbenchmarks' own test-disjoint train splits. Saturates <1 epoch.
README.md+60-170