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 files119 unmodified lines120121122123124125126119 unmodified linesif k in seen: continueif len(text[sp["start"]:sp["end"]].strip()) < 3: continue # drop fragmentsseen.add(k); uniq.append(sp)return uniqdef model_spans(text: str, tok, model):import torch119 unmodified lines120121122123124125126127128129130131132133134135136137138139140141142143144145146147148119 unmodified linesif 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.try:from context_cued import context_cued_spans, CONTEXT_TYPESexcept Exception:return uniqcued = context_cued_spans(text)if not cued:return uniqauth_claim = [False] * len(text)for sp in uniq:if sp["type"] in _AUTH_TYPES:for i in range(sp["start"], sp["end"]): auth_claim[i] = Truekept = [c for c in cued if not any(auth_claim[c["start"]:c["end"]])]rng = [(c["start"], c["end"]) for c in kept]def _ov(sp): return any(min(e, sp["end"]) > max(s, sp["start"]) for s, e in rng)merged = [sp for sp in uniq if not (sp["type"] in CONTEXT_TYPES and _ov(sp))] + keptseen, final = set(), []for sp in sorted(merged, key=lambda s: (s["start"], s["end"])):k = (sp["start"], sp["end"], sp["type"])if k in seen: continueseen.add(k); final.append(sp)return finaldef model_spans(text: str, tok, model):import torch
pii_hybrid_decode.py+23-1