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 pii_hybrid_decode.py with huggingface_hub
Browse files113 unmodified lines114115116117118119120121122123124113 unmodified linesss, ee = _snap_word(text, m["start"], m["end"]) # complete partial Latin wordsout.append({"start": ss, "end": ee, "type": t, "text": text[ss:ee]})out.extend(auth)seen, uniq = set(), []for sp in sorted(out, key=lambda s: (s["start"], s["end"])):k = (sp["start"], sp["end"], sp["type"])if k in seen: continueif len(text[sp["start"]:sp["end"]].strip()) < 3: continue # drop fragmentsseen.add(k); uniq.append(sp)# CONTEXT tier: cue-gated alphanumeric IDs (Passport No:/Policy #/MRN: ...) — recovers# the structure-less IDs the model can't learn. Authoritative for their types; AUTH wins.113 unmodified lines114115116117118119120121122123124125126127128129130113 unmodified linesss, ee = _snap_word(text, m["start"], m["end"]) # complete partial Latin wordsout.append({"start": ss, "end": ee, "type": t, "text": text[ss:ee]})out.extend(auth)# non-Latin scripts (CJK/Hangul/Hiragana/Katakana/Thai/Arabic/Cyrillic/Devanagari/Hebrew):# a 2-char span is a full token (e.g. the name 张敏), not Latin sub-token junk -> keep a >=2# floor for non-Latin, >=3 for Latin (otherwise short CJK/Hangul names are wrongly dropped).import re as _re_NONLATIN = _re.compile(r"[Ѐ-ӿ-ۿऀ-ॿ--ヿ㐀-鿿가-豈-]")seen, uniq = set(), []for sp in sorted(out, key=lambda s: (s["start"], s["end"])):k = (sp["start"], sp["end"], sp["type"])if k in seen: continuefrag = text[sp["start"]:sp["end"]].strip()if len(frag) < (2 if _NONLATIN.search(frag) else 3): continue # drop fragmentsseen.add(k); uniq.append(sp)# CONTEXT tier: cue-gated alphanumeric IDs (Passport No:/Policy #/MRN: ...) — recovers# the structure-less IDs the model can't learn. Authoritative for their types; AUTH wins.
pii_hybrid_decode.py+7-1