rail-v2 is a DistilBERT model fine-tuned for token classification on personally identifiable information (PII). It is the NER backbone of GuardRailAI, where it runs alongside eleven checksum-validating Presidio recognisers (Luhn, US SSN, Singapore NRIC, China Resident ID, Hong Kong HKID/BR/CR, SWIFT BIC, US ABA routing, Singapore UEN, China USCC).
What's new vs rail-v1
Five new entity types covering Hong Kong business documents and Singapore GST registration:
HK_ID — Hong Kong Identity Card (with ISO 7064 Mod 11-2 checksum validator in the pipeline)
ADDRESS_HK — Hong Kong street addresses
HK_PHONE — Hong Kong phone numbers (+852 prefix)
BANK_ACCOUNT_HK — HK bank account numbers (HSBC, BOC HK, SCB, Hang Seng)
Evaluated on a held-out validation set (Kaggle PII val + Nemotron corporate val + 148 DataDesigner HK/SG/CN business docs):
Metric
Value
Overall F_β5 (β=5)
0.986
Overall recall
0.988
Overall precision
0.949
Per-entity recall and precision:
Entity
Recall
Precision
HK_ID
1.000
0.980
ADDRESS_HK
1.000
0.940
HK_PHONE
1.000
1.000
BANK_ACCOUNT_HK
1.000
1.000
GST_REG_NUM
1.000
1.000
URL_PERSONAL
1.000
0.980
ID_NUM
1.000
0.933
EMAIL
0.998
0.967
COMPANY_NAME
0.994
0.953
PHONE_NUM
0.980
0.915
USERNAME
0.976
0.976
PERSON_NAME
0.978
0.932
STREET_ADDRESS
0.951
0.938
F_β5 (β=5) weights recall 25× more than precision — the model is tuned for compliance use cases where missing PII is catastrophic and over-redacting is merely annoying. All gated entities clear the 0.95 recall threshold; the five new HK/SG entities all reach perfect recall on the validation set thanks to deterministic checksum generation in the synthetic data.
The DataDesigner corpora are generated with NVIDIA NeMo DataDesigner: identifiers (HKID, GST reg num, USCC, phone numbers, bank accounts) are pre-computed in Python so every synthetic example passes the pipeline's own checksum validators. The LLM only generates surrounding prose, never identifiers themselves. An LLM-as-judge column filters out incoherent rows (quality < 4/5 dropped).
Quick start
python
1from transformers import pipeline
23ner = pipeline(4"token-classification",5 model="lbsavf3t/rail-v2",6 aggregation_strategy="simple",7)89text =(10"Director Jason Wong (HKID A123456(3)) of Dragon Pearl Holdings Limited "11"can be reached at +852 9123 4567 or jason@dragonpearl.com.hk."12)13for span in ner(text):14print(f"{span['entity_group']:<15}{span['word']!r:<30} score={span['score']:.3f}")
For production use, combine this NER with the Presidio pattern recognisers in the parent repo. The full pipeline includes checksum-validated detection for credit cards, SSNs, NRICs, China Resident IDs, SWIFT BICs, ABA routing numbers, Singapore UENs, China USCCs, and Hong Kong HKID/BR/CR numbers.
Intended use
Batch redaction of logs and exported datasets for GDPR/CCPA/PDPO compliance
Real-time PII screening of chat / email / form data
Pre-training corpus filtering for LLM teams
Hong Kong corporate document workflows (BR registration, payroll, bank statements)
Singapore GST-registered entity onboarding
Limitations
English and Chinese only. Other languages will pass through largely unredacted.
Optimised for recall over precision at β=5; expect a low rate of false positives.
The 5 new HK/SG entities are still in "ramp" territory — gated at 0.85 recall rather than the default 0.95 — because they were introduced in this release. Real-world recall on out-of-distribution HK documents may be lower than the validation numbers suggest. Treat the DataDesigner-only entities as defence-in-depth alongside the deterministic Presidio pattern recognisers.
Architecture
Base model: distilbert/distilbert-base-uncased (66M params)
Training: 5 epochs, batch size 16, lr 2e-5, weighted cross-entropy loss (max class weight 50)
Hardware: NVIDIA RTX PRO 6000 Blackwell Workstation Edition (sm_120, cu128)
Hyperparameters: see training_args.bin in this repo
Citation
If you use this model, please cite the parent project:
GuardRailAI: Context-aware PII detection extending Microsoft Presidio.
https://github.com/lbsavf3t/guardrail-pii