elifsudayi/crf-ner

Linear-chain Conditional Random Field (CRF) baseline trained with L-BFGS ($c_1=0.25, c_2=0.1$) to detect Personally Identifiable Information (PII) in financial texts (contracts, SWIFT messages, invoices) using window-based hand-crafted features ($\pm 2$ window, prefixes/suffixes, shapes) and learned state transitions.

  • Project Repository: https://github.com/ata-sesli/nlp-project-2
  • Course & Split: Trained for the COE025 NLP course project (Istinye University) on the cleaned English split of gretelai/synthetic_pii_finance_multilingual (30,545 training chunks, 17 BIO tags across 8 PII categories).

Test results (strict IOB2, seqeval)

chunks entity micro-F1 token macro-F1 entity precision entity recall missed PII rate
3,903 0.8221 0.7551 0.8586 0.7887 21.1%

Per-entity test F1

EMAIL PHONE ADDRESS DATE NAME ID COMPANY ACCOUNT
0.9412 0.8814 0.8638 0.8464 0.8314 0.7844 0.7395 0.7138

Environment & Compatibility

Trained with sklearn-crfsuite, scikit-learn==1.9.1, and joblib. Because .joblib model artifacts depend on specific internal module structures and C-extensions, match the environment versions to prevent load errors:

pip install sklearn-crfsuite scikit-learn==1.9.1 joblib seqeval

## Use

```python
import joblib
from huggingface_hub import hf_hub_download
from features import sentence_features

# Download and load model artifact
model_path = hf_hub_download(repo_id="elifsudayi/crf-ner", filename="crf.joblib")
model = joblib.load(model_path)

# Example inference on financial text
tokens = ["Please", "transfer", "$500", "to", "John", "Doe", "IBAN", "DE89370400440532013000"]
features = sentence_features(tokens)
predictions = model.predict_single(features)

print(list(zip(tokens, predictions)))
# [('Please', 'O'), ('transfer', 'O'), ('$500', 'O'), ('to', 'O'), ('John', 'B-NAME'), ('Doe', 'I-NAME'), ('IBAN', 'O'), ('DE89370400440532013000', 'B-ACCOUNT')]
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Dataset used to train elifsudayi/crf-ner