Downloads · 30 days
0
zachz/pii-ner-model
pii-ner-model is a token classification model from zachz. Use it when you need labels on individual words, such as names. It is set up for sklearn. The card lists the license as mit.
A lightweight sklearn-based Named Entity Recognition model for detecting Personally Identifiable Information in text.
Downloads · 30 days
0
Access
Public
Updated Apr 10, 2026
Repo size
—
Likes
0
Public
Click a slice to open those files.
.pkl9.1 KB · 85%
From the Hugging Face model README
A lightweight sklearn-based Named Entity Recognition model for detecting Personally Identifiable Information in text.
import pickle
with open("model.pkl", "rb") as f:
model = pickle.load(f)
def extract_features(tokens, idx):
token = tokens[idx]
features = {
'word.lower': token.lower(),
'word.length': len(token),
'word.has_at': '@' in token,
'word.is_digit': token.isdigit(),
}
if idx > 0: features['prev.lower'] = tokens[idx-1].lower()
if idx < len(tokens)-1: features['next.lower'] = tokens[idx+1].lower()
return features
text = "Contact [email protected] or call 555-123-4567"
tokens = text.split()
features = [extract_features(tokens, i) for i in range(len(tokens))]
predictions = model.predict(features)
entities = [(t, l) for t, l in zip(tokens, predictions) if l != "O"]
MIT