finance-pii-bert-base-cased
bert-base-cased fine-tuned to find personal data (PII) in financial documents, as token
classification with BIO tags. 8 entity types (17 tags): NAME, COMPANY, ADDRESS, DATE, EMAIL,
PHONE, ACCOUNT, ID.
Built for the COE025 Natural Language Processing course project (İstinye University). Code and data preparation: https://github.com/ata-sesli/nlp-project-2
Use
from transformers import pipeline
ner = pipeline("token-classification", model="akifkulll/finance-pii-bert-base-cased",
aggregation_strategy="first", stride=128)
ner("John Smith paid 500 EUR to XYZ Corp on 12 March 2024.")
aggregation_strategy="first" joins the subword pieces back into words and takes each word's tag
from its first piece, the same rule used in training. Each result is one entity:
entity_group (NAME, COMPANY, ...), word, score and the character offsets start, end.
stride=128 lets texts longer than BERT's 512-token limit be read in overlapping windows, so
nothing is cut off. The model was trained on English synthetic financial documents.
Training
- Data: English part of
gretelai/synthetic_pii_finance_multilingual, cleaned and converted to word-level BIO by the project'sdataset/prepare_dataset.py; 30,545 training chunks of up to 200 words. - 3 epochs, learning rate 3e-05, 10% linear warm-up, batch size 16, fp16, seed 42; best epoch chosen by validation entity F1.
- Labels go on the first subword of each word; chunks longer than 512 subwords are split.
- Hardware: NVIDIA A100-SXM4-40GB, 7.6 minutes.
Results (entity level, seqeval strict IOB2)
| Split | Precision | Recall | F1 | Missed PII |
|---|---|---|---|---|
| Validation | 0.8535 | 0.8690 | 0.8612 | 13.1% |
| Test | 0.8595 | 0.8772 | 0.8683 | 12.3% |
Test results per type:
| Type | Precision | Recall | F1 | Entities |
|---|---|---|---|---|
| NAME | 0.9040 | 0.8520 | 0.8772 | 3447 |
| COMPANY | 0.8053 | 0.8462 | 0.8252 | 2932 |
| ADDRESS | 0.8753 | 0.9041 | 0.8895 | 1856 |
| DATE | 0.8473 | 0.8925 | 0.8693 | 5712 |
| 0.9116 | 0.9419 | 0.9265 | 241 | |
| PHONE | 0.8785 | 0.9228 | 0.9001 | 337 |
| ACCOUNT | 0.9113 | 0.8403 | 0.8744 | 526 |
| ID | 0.9016 | 0.9347 | 0.9178 | 490 |
Limitations
The data is synthetic and English only, the labels were generated by the dataset authors, and the model was trained once (one seed). Do not rely on it alone to protect real personal data.