pplx-pii-masking
PII masking model for conversational data. A ~600M-parameter bidirectional
Qwen3 encoder
(perplexity-ai/pplx-embed-v1-0.6b
backbone, use_bidirectional_attention=true) with two heads:
- Token classification head (1024 -> 37): BIOES tags over 9 PII categories
(
private_person,account_number,private_url,private_date,private_address,private_email,private_phone,other_pii,secret), decoded with a constrained Viterbi decoder. - Sensitivity head (1024 -> 1): conversation-level sensitivity classifier on mean-pooled hidden states.
Usage
example_usage.py in this repo is a self-contained
reference pipeline (pip install torch safetensors transformers). It loads
the encoder implementation from the
backbone repo via
trust_remote_code, swaps in this repo's fine-tuned weights, applies the two
heads, and decodes spans with the constrained BIOES Viterbi included in the
script:
import sys
from huggingface_hub import snapshot_download
repo = snapshot_download("perplexity-ai/pplx-pii-masking")
sys.path.insert(0, repo)
from example_usage import PiiMasker
masker = PiiMasker(repo)
text = ("Hi, I'm Daniel Whitfield, you can reach me at "
"daniels@meridiancap.com or 415-555-0123.")
spans, sensitivity = masker(text)
for s in spans:
print(s.label, (s.start, s.end), text[s.start:s.end])
# private_person (8, 24) Daniel Whitfield
# private_email (46, 69) daniels@meridiancap.com
# private_phone (73, 85) 415-555-0123
print(masker.mask(text))
# Hi, I'm [PRIVATE_PERSON], you can reach me at [PRIVATE_EMAIL] or [PRIVATE_PHONE].
Checkpoint layout
model.safetensors holds the fine-tuned backbone (bf16, backbone.*), both
heads (fp32, token_cls_head.* / sensitivity_head.*), and the Viterbi bias
scalars (viterbi.*). max_seq_len is 4096 tokens.
Inference outline: tokenize (no BOS/EOS added), run the bidirectional encoder,
then per token logits = h @ W_cls.T + b_cls decoded with a constrained BIOES
Viterbi, and sensitivity = sigmoid(mean(h) @ W_sen.T + b_sen). The
PPLXQwen3Model encoder implementation (configuration.py / modeling.py
referenced by config.json's auto_map) ships with the
backbone repo.
- Downloads last month
- -