Token Classification
Transformers
ONNX
Safetensors
English
distilbert
pii
privacy
experimental
datafog
Instructions to use DataFog/pii-en-65m with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DataFog/pii-en-65m with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="DataFog/pii-en-65m")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("DataFog/pii-en-65m") model = AutoModelForTokenClassification.from_pretrained("DataFog/pii-en-65m", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download reproduction/scripts/evaluate.py from DataFog/pii-en-65m: direct link, hf CLI and curl.
- Browser
- Download file 893 Bytes
-
https://huggingface.co/DataFog/pii-en-65m/resolve/5683ef559df6618f563375b632fdab7352ac1628/reproduction/scripts/evaluate.py
- Command line
-
hf download hf://DataFog/pii-en-65m@5683ef559df6618f563375b632fdab7352ac1628/reproduction/scripts/evaluate.py
-
curl -L -o evaluate.py https://huggingface.co/DataFog/pii-en-65m/resolve/5683ef559df6618f563375b632fdab7352ac1628/reproduction/scripts/evaluate.py
893 Bytes
| #!/usr/bin/env python3 | |
| import argparse | |
| import json | |
| import sys | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parents[1])) | |
| from pii.evaluation import evaluate, read_jsonl, write_json | |
| if __name__ == '__main__': | |
| p = argparse.ArgumentParser(description='Evaluate complete saved span predictions against character-offset gold JSONL') | |
| for name in ('gold', 'predictions', 'output'): | |
| p.add_argument('--' + name, required=True) | |
| p.add_argument('--calibration') | |
| p.add_argument('--threshold', type=float) | |
| args = p.parse_args() | |
| calibration = json.loads(Path(args.calibration).read_text()) if args.calibration else None | |
| result = evaluate(read_jsonl(args.gold), read_jsonl(args.predictions), args.threshold, calibration) | |
| write_json(args.output, result) | |
| print(json.dumps({'overall': result['overall'], 'documents': result['documents']})) | |