- Yalen Structured-PII Validator β IBAN Β· Card Β· Phone Β· Email Β· Date (XLM-RoBERTa)
Yalen Structured-PII Validator β IBAN Β· Card Β· Phone Β· Email Β· Date (XLM-RoBERTa)
Fine-tuned version of xlm-roberta-base for PII (Personally Identifiable Information) detection with focus on financial and contact data.
Developed by Yalen Labs as part of the Yalen Sentinel Pulse privacy protection platform.
Model Description
This model performs Named Entity Recognition (NER) to detect sensitive personal and financial information in text. It uses BIO tagging (Begin / Inside / Outside) and supports multilingual input, with strong performance on French, English, and Tunisian Arabic-Latin mixed text.
Detected Entities
| Label | Description | Examples |
|---|---|---|
IBAN |
International Bank Account Number | TN59 1000 6035 1835 9848 3270, FR76 3000 6000 0112... |
CARD |
Credit / Debit card number | 4532 1234 5678 9012, 5412 7534 2589 6315 |
PHONE |
Phone number (international formats) | +216 23 456 789, 0023 4567890 |
EMAIL |
Email address | support@yalen.tn, ahmed.ben@gmail.com |
DATE |
Date (any format) | 15/03/2025, 14 janvier 1990, 12/2028 |
Quick Start
from transformers import pipeline
ner = pipeline(
"ner",
model="YalenLabs/yalen-pii-structured-validator",
aggregation_strategy="simple"
)
text = "Contact: support@yalen.tn | Tel: +216 23 456 789 | IBAN: TN59 1000 6035 1835 9848 3270"
results = ner(text)
for entity in results:
print(f"[{entity['entity_group']}] '{entity['word']}' (score: {entity['score']:.3f})")
Output:
[EMAIL] 'support@yalen.tn' (score: 1.000)
[PHONE] '+216 23 456 789' (score: 1.000)
[IBAN] 'TN59 1000 6035 1835 9848 3270' (score: 1.000)
Installation
pip install transformers torch
Usage Examples
Detect all PII in a document
from transformers import pipeline
ner = pipeline("ner", model="YalenLabs/yalen-pii-structured-validator", aggregation_strategy="simple")
examples = [
"Rendez-vous le 15/03/2025, contactez ahmed.ben@gmail.com",
"Carte bancaire: 4532 1234 5678 9012, expire 12/2028",
"Virement IBAN FR76 3000 6000 0112 3456 7890 189",
"Appelez le +216 98 765 432 ou +33 1 23 45 67 89",
]
for text in examples:
print(f"\nTexte: {text}")
for e in ner(text):
print(f" [{e['entity_group']}] {e['word'].strip('.,;')} ({e['score']:.3f})")
Post-processing tip
The tokenizer may include trailing punctuation in detected spans. Clean it up:
def clean_entity(word: str) -> str:
return word.strip(".,;:!? ")
results = ner("Email: contact@yalen.tn, Tel: +216 23 000 000")
cleaned = [{**e, "word": clean_entity(e["word"])} for e in results]
With explicit label mapping
from transformers import AutoTokenizer, AutoModelForTokenClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("YalenLabs/yalen-pii-structured-validator")
model = AutoModelForTokenClassification.from_pretrained("YalenLabs/yalen-pii-structured-validator")
text = "IBAN: TN59 1000 6035 1835 9848 3270"
inputs = tokenizer(text, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.argmax(outputs.logits, dim=2)
tokens = tokenizer.convert_ids_to_tokens(inputs["input_ids"][0])
labels = [model.config.id2label[p.item()] for p in predictions[0]]
for token, label in zip(tokens, labels):
if label != "O":
print(f"{token:20} β {label}")
Model Architecture
| Parameter | Value |
|---|---|
| Base model | xlm-roberta-base |
| Architecture | XLMRobertaForTokenClassification |
| Hidden size | 768 |
| Attention heads | 12 |
| Hidden layers | 12 |
| Max tokens | 512 |
| Vocab size | 250,002 |
| Labels | 11 (O + 5ΓBIO) |
| Model size | ~1.06 GB |
Label Map
{
"0": "O",
"1": "B-IBAN", "2": "I-IBAN",
"3": "B-CARD", "4": "I-CARD",
"5": "B-PHONE", "6": "I-PHONE",
"7": "B-EMAIL", "8": "I-EMAIL",
"9": "B-DATE", "10": "I-DATE"
}
Intended Use
- Privacy compliance (GDPR, Tunisian Data Protection Law)
- Document redaction β anonymize sensitive documents before sharing
- Data loss prevention (DLP) β detect accidental PII leaks in logs or messages
- Financial document processing β extract IBAN/card numbers for validation
- Healthcare & insurance β detect dates and contact information
Limitations
- Maximum input length: 512 tokens (long documents should be split by sentence or paragraph)
- Trained primarily on French and English data β performance may vary on other languages
- Card number detection works best with standard spacing formats (
XXXX XXXX XXXX XXXX) - Trailing punctuation may be included in token spans β apply post-processing (
.strip(".,;"))
Training Data
The model was fine-tuned on a dataset composed of:
| Source | Type | Volume | Languages |
|---|---|---|---|
| Synthetically generated PII | IBAN, CARD, PHONE, EMAIL, DATE | ~50,000 examples | FR, EN, AR-latin |
| Filtered CommonCrawl corpus | Neutral text contexts | ~20,000 examples | Multilingual |
| Anonymized internal Yalen data | Tunisian/French formats | ~5,000 examples | FR, AR-latin |
No real patient data was used in training.
All personally identifiable information in training data is either synthetic or fully anonymized prior to use.
Intended Use
Primary Use Case
Validation of PII detections in the Yalen Artemesia Desktop Guardian compliance audit tool. The model acts as a second-pass validator after regex-based detection, providing confidence scores to reduce false positives.
Inference Pipeline
Raw text (file content)
β
Regex patterns (email, IBAN, CARD, PHONE, DATE) β raw findings
β
XLM-RoBERTa (this model)
- context window: Β±100 chars around each detected value
- BIO token classification
- confidence score per entity
β
Threshold: 0.55
β₯ 0.55 β slm_confirmed=True β included in audit report
< 0.55 β slm_confirmed=False β flagged as uncertain (not silently dropped)
Out-of-Scope Uses
- Real-time surveillance or profiling of individuals
- Automated decisions affecting individuals' rights
- Use outside of compliance audit contexts
Bias, Risks, and Limitations
Known Biases
| Bias | Risk | Mitigation |
|---|---|---|
| Linguistic bias | Lower performance on non-latin Arabic scripts | Documented limitation; AR-latin covered in training data |
| IBAN format bias | Stronger on FR/TN formats | Synthetic data covers 30+ country formats |
| Threshold sensitivity | Score 0.40β0.55 edge cases | Uncertain findings preserved in report with flag, not silently dropped |
| Training data distribution | Overrepresentation of FR/TN data | Stated limitation; multilingual XLM-R base partially compensates |
Risk Mitigation
- Graceful degradation: if the model is unavailable, the system falls back to regex-only detection with
slm_score=1.0β no silent failures - Human in the loop: the tool produces a consultative audit report; no automated decision affecting individuals is made
- Transparency: every finding in the generated PDF report includes the
slm_scoreandslm_confirmedfields
What the model does NOT do
- It does not detect names of persons (handled by spaCy NER on filenames)
- It does not make decisions β it produces scores for human review
- It does not process or store the scanned content beyond the inference session
Explainability
Each detected entity contributes a traceable output:
{
"type": "EMAIL",
"value": "j***.d*****@h******.fr", # masked in report
"slm_score": 0.923,
"slm_confirmed": True
}
The confidence score is derived from the model's softmax output on the token span overlapping the regex-detected value. Scores below 0.55 are surfaced in the report as uncertain rather than hidden.
GDPR / HDS Compliance Notes
- Local inference only: no data is sent to external APIs or servers
- No persistent storage of scanned content: only metadata (file paths, PII types, scores) are stored
- Purpose limitation: the model is used exclusively for compliance auditing
- Legal basis: legitimate interest + legal obligation (GDPR Art. 32 β security of processing)
Citation
If you use this model in research or compliance documentation, please cite:
@software{yalen_artemesia_2026,
author = {Yalen AI},
title = {Yalen Artemesia β PII Detection Platform},
year = {2026},
url = {https://huggingface.co/YalenLabs/yalen-pii-structured-validator}
}
Additional Resources
- Full audit documentation:
docs/MODEL_CARD_AUDIT.mdin the Yalen Sentinel Pulse repository - NER pipeline source:
Aiko/aiko/pii_detector.py - SLM validation source:
Aiko/aiko/slm_validator.py - spaCy NER model: fr_core_news_sm
About Yalen AI
Yalen Sentinel Pulse is an AI-powered platform for PII detection and data privacy protection, developed by the Yalen AI team. It combines regex patterns, ML models, and NER to provide comprehensive sensitive data identification.
- π Platform: Yalen Sentinel Pulse
- π§ Contact: hello@yalen.ai
License
MIT β free for commercial and research use.
- Downloads last month
- 37
Evaluation results
- F1 (test set)self-reported1.000