Instructions to use SlayerLab/NERGAL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use SlayerLab/NERGAL with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="SlayerLab/NERGAL")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("SlayerLab/NERGAL") model = AutoModelForTokenClassification.from_pretrained("SlayerLab/NERGAL", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Add hybrid PII scripts: nergal.py and frozen scrub_pii.py
Browse files
README.md
CHANGED
|
@@ -77,12 +77,21 @@ Union with unchanged rules. Character scores are on gold vs masked characters.
|
|
| 77 |
|
| 78 |
## Load
|
| 79 |
|
|
|
|
|
|
|
| 80 |
```python
|
| 81 |
-
from
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
```
|
| 85 |
|
| 86 |
-
|
| 87 |
|
| 88 |
Base weights: [`FacebookAI/xlm-roberta-large`](https://huggingface.co/FacebookAI/xlm-roberta-large) revision `c23d21b0620b635a76227c604d44e43a9f0ee389` (MIT).
|
|
|
|
| 77 |
|
| 78 |
## Load
|
| 79 |
|
| 80 |
+
This repo is the PII island: frozen `scrub_pii.py` plus `nergal.py`. `pipeline("token-classification")` will not match. Regex runs on the original text, the model adds spans at 0.95, then the two are unioned and replaced with `[Telefon]` / `[PII]`.
|
| 81 |
+
|
| 82 |
```python
|
| 83 |
+
from pathlib import Path
|
| 84 |
+
from huggingface_hub import snapshot_download
|
| 85 |
+
|
| 86 |
+
root = Path(snapshot_download("SlayerLab/NERGAL"))
|
| 87 |
+
import sys
|
| 88 |
+
sys.path.insert(0, str(root))
|
| 89 |
+
from nergal import Nergal
|
| 90 |
+
|
| 91 |
+
nergal = Nergal.from_pretrained(root, local_files_only=True)
|
| 92 |
+
masked, counts = nergal.scrub(text)
|
| 93 |
```
|
| 94 |
|
| 95 |
+
`hybrid.json` records threshold 0.95 and gap ids `250002` / `250003`.
|
| 96 |
|
| 97 |
Base weights: [`FacebookAI/xlm-roberta-large`](https://huggingface.co/FacebookAI/xlm-roberta-large) revision `c23d21b0620b635a76227c604d44e43a9f0ee389` (MIT).
|