Token Classification
Transformers
ONNX
Safetensors
English
modernbert
pii
redaction
person-names
ner
ettin
distillation
Instructions to use HMC83/name-detector-68m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use HMC83/name-detector-68m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="HMC83/name-detector-68m")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("HMC83/name-detector-68m") model = AutoModelForTokenClassification.from_pretrained("HMC83/name-detector-68m", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 855 Bytes
77daf58 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | """Find people's names in a text.
pip install onnxruntime tokenizers numpy
python example.py
python example.py letter.txt
"""
import sys
from pathlib import Path
HERE = Path(__file__).resolve().parent
sys.path.insert(0, str(HERE / 'code'))
import runtime
SAMPLE = """Dear Ms Okonjo,
Sam Hill has checked the figures with the Planning team. AR to circulate the draft before the committee meets.
Yours sincerely
Priya Raman
Information Governance Officer
"""
detector = runtime.Detector(HERE)
text = Path(sys.argv[1]).read_text() if len(sys.argv) > 1 else SAMPLE
found = detector.findings(text)
for f in found:
print(f"{f['start']:>6}-{f['end']:<6} {f['score']:.2f} {text[f['start']:f['end']]}")
masked, last = [], 0
for f in found:
masked += [text[last:f['start']], '[NAME]']
last = f['end']
print()
print(''.join(masked) + text[last:])
|