Token Classification
Transformers
Safetensors
English
roberta
pii
pii-detection
invoices
ner
de-identification
redaction
Synthetic
Instructions to use aitrainingdatabroker/invoice-pii-detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use aitrainingdatabroker/invoice-pii-detector with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="aitrainingdatabroker/invoice-pii-detector")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("aitrainingdatabroker/invoice-pii-detector") model = AutoModelForTokenClassification.from_pretrained("aitrainingdatabroker/invoice-pii-detector", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Add README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
library_name: transformers
|
| 6 |
+
pipeline_tag: token-classification
|
| 7 |
+
base_model: distilroberta-base
|
| 8 |
+
datasets:
|
| 9 |
+
- aitrainingdatabroker/synthetic-invoice-pii-spans
|
| 10 |
+
tags:
|
| 11 |
+
- pii
|
| 12 |
+
- pii-detection
|
| 13 |
+
- invoices
|
| 14 |
+
- ner
|
| 15 |
+
- de-identification
|
| 16 |
+
- redaction
|
| 17 |
+
- synthetic
|
| 18 |
+
---
|
| 19 |
+
|
| 20 |
+
# Invoice PII Detector
|
| 21 |
+
|
| 22 |
+
Finds personal and account details in invoice and payment text: PERSON, ORG, EMAIL, PHONE, ADDRESS, DATE, MONEY, INVOICE_ID, BANK_ACCOUNT and TAX_ID.
|
| 23 |
+
|
| 24 |
+
Every name, number and sentence it was trained on is made up. Nothing comes from a real person, customer or business.
|
| 25 |
+
|
| 26 |
+
Related tool: [pii-pattern-scanner](https://huggingface.co/spaces/aitrainingdatabroker/pii-pattern-scanner) (a Space that runs in your browser).
|
| 27 |
+
|
| 28 |
+
## Why it exists
|
| 29 |
+
|
| 30 |
+
Accounting and ERP records hold names, addresses and account numbers next to the figures an AI lab might value. This model flags the candidates so a person can review them before the records are shared.
|
| 31 |
+
|
| 32 |
+
## Use it
|
| 33 |
+
|
| 34 |
+
```python
|
| 35 |
+
from transformers import pipeline
|
| 36 |
+
|
| 37 |
+
tagger = pipeline("token-classification", model="aitrainingdatabroker/invoice-pii-detector", aggregation_strategy="simple")
|
| 38 |
+
for hit in tagger("Please remit $4,310.00 to account 0048215937 by March 4, 2026 quoting INV-204517."):
|
| 39 |
+
print(hit["entity_group"], hit["word"], round(hit["score"], 3))
|
| 40 |
+
```
|
| 41 |
+
|
| 42 |
+
## How it was trained
|
| 43 |
+
|
| 44 |
+
Fine-tuned from `distilroberta-base` for 8 epochs on one RTX 3070. Training data: 280 rows from [synthetic-invoice-pii-spans](https://huggingface.co/datasets/aitrainingdatabroker/synthetic-invoice-pii-spans), all invented, with test rows built from templates the model never saw in training. The scripts that built the data and trained the model are in `source/`; the full scores are in `scores.json`.
|
| 45 |
+
|
| 46 |
+
## Test scores
|
| 47 |
+
|
| 48 |
+
Exact entity match on 120 held-out rows: precision 0.943, recall 0.962, F1 0.953.
|
| 49 |
+
|
| 50 |
+
| Type | Precision | Recall | F1 | Count |
|
| 51 |
+
|---|---|---|---|---|
|
| 52 |
+
| `ADDRESS` | 1.0 | 1.0 | 1.0 | 30 |
|
| 53 |
+
| `BANK_ACCOUNT` | 0.591 | 0.433 | 0.5 | 30 |
|
| 54 |
+
| `DATE` | 1.0 | 1.0 | 1.0 | 60 |
|
| 55 |
+
| `EMAIL` | 1.0 | 1.0 | 1.0 | 30 |
|
| 56 |
+
| `INVOICE_ID` | 1.0 | 1.0 | 1.0 | 60 |
|
| 57 |
+
| `MONEY` | 1.0 | 1.0 | 1.0 | 60 |
|
| 58 |
+
| `ORG` | 1.0 | 1.0 | 1.0 | 60 |
|
| 59 |
+
| `PERSON` | 1.0 | 1.0 | 1.0 | 60 |
|
| 60 |
+
| `PHONE` | 1.0 | 1.0 | 1.0 | 30 |
|
| 61 |
+
| `TAX_ID` | 0.638 | 1.0 | 0.779 | 30 |
|
| 62 |
+
|
| 63 |
+
## Limits
|
| 64 |
+
|
| 65 |
+
- Trained only on invented text from templates, with test sentences built from templates it never saw. Real text varies far more.
|
| 66 |
+
- Single lines, not tables or scanned PDFs. Account and tax numbers in the training data are not real numbers, and real formats vary by country.
|
| 67 |
+
- This model is not legal advice and not a certification. A person should review its output before anything is shared or decided, and your counsel decides what a rule requires.
|
| 68 |
+
|
| 69 |
+
## Read more
|
| 70 |
+
|
| 71 |
+
- [Can you license accounting and ERP records?](https://aitrainingdatabroker.com/data/accounting-and-erp-records/?utm_source=huggingface&utm_medium=model&utm_campaign=invoice-pii-detector)
|
| 72 |
+
- [QuickBooks data export for AI licensing](https://aitrainingdatabroker.com/data/quickbooks-data-export/?utm_source=huggingface&utm_medium=model&utm_campaign=invoice-pii-detector)
|
| 73 |
+
- [Can an accounting firm license data to AI?](https://aitrainingdatabroker.com/sell/accounting-firms/?utm_source=huggingface&utm_medium=model&utm_campaign=invoice-pii-detector)
|
| 74 |
+
|
| 75 |
+
## License and credit
|
| 76 |
+
|
| 77 |
+
Apache 2.0. Please credit **AI Training Data Broker** and link to https://aitrainingdatabroker.com/ when you share or build on it.
|
| 78 |
+
|
| 79 |
+
## About
|
| 80 |
+
|
| 81 |
+
AI Training Data Broker is a broker and technical advisor for companies that sell or license their data to AI labs. It guides the technical side, including export, format, de-identification and compliance, and publishes free guides, checklists and tools.
|