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
Download example.py from HMC83/name-detector-68m: direct link, hf CLI and curl.
- Browser
- Download file 855 Bytes
-
https://huggingface.co/HMC83/name-detector-68m/resolve/main/example.py
- Command line
-
hf download hf://HMC83/name-detector-68m/example.py
-
curl -L -o example.py https://huggingface.co/HMC83/name-detector-68m/resolve/main/example.py
855 Bytes
| """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:]) | |