gorkem371/pii-intent-detection-multilingual
Viewer • Updated • 41.4k • 121 • 2
How to use gorkem371/pii-intent-classifier-xlmr-large with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-classification", model="gorkem371/pii-intent-classifier-xlmr-large") # Load model directly
from transformers import AutoTokenizer, AutoModelForSequenceClassification
tokenizer = AutoTokenizer.from_pretrained("gorkem371/pii-intent-classifier-xlmr-large")
model = AutoModelForSequenceClassification.from_pretrained("gorkem371/pii-intent-classifier-xlmr-large")A multilingual binary classifier that detects PII (Personally Identifiable Information) sharing intent in text messages. Built for content moderation on creator-brand collaboration platforms.
V11 is the 15th iteration of this model, trained on 41,427 samples (up from 24,012 in V7c). Key improvements:
| Version | Stress Test | Conversation | Training Data | Key Change |
|---|---|---|---|---|
| V7c | 173/177 (98%) | - | 24,012 | First production model |
| V8 | 174/177 (98%) | - | 24,012 | +name_intro, greeting_slang |
| V9 | - | - | 39,303 | +"real contact = always PII" policy |
| V10 | 172/177 (97%) | 821/864 (95%) | 39,789 | +entity×label balance fix |
| V11 | 168/177 (95%) | 838/864 (97%) | 41,427 | +targeted error fixes |
This model classifies whether a message contains an intent to share personal contact information (phone numbers, emails, social media handles, IBANs, etc.) or not. Unlike simple regex-based PII detection, this model understands context and intent:
xlm-roberta-large (550M parameters)| Metric | Score |
|---|---|
| F1 | 99.33% |
| Accuracy | 99.24% |
| Precision | 99.20% |
| Recall | 99.46% |
| Test Suite | Score | Description |
|---|---|---|
| Standard (72) | 97% | Basic PII sharing and non-PII scenarios |
| Hardcore (72) | 92% | Evasion, coded sharing, sarcasm, context tricks |
| Edge Cases (33) | 97% | Business numbers, sarcasm+real numbers, hypotheticals |
| Total (177) | 95% | Combined across all suites |
| Metric | Score |
|---|---|
| Total Accuracy | 838/864 (97.0%) |
| Errors | 26 |
| False Positives | 2 |
| False Negatives | 24 |
| Design Limit (entity=NONE) | 19 of 24 FN |
| Actual Model Errors | 5 |
| Language | Score | Notes |
|---|---|---|
| Turkish | 96% | Weak: masked numbers, order numbers |
| Arabic | 96% | Weak: scam warnings, math expressions |
| English | 100% | All standard+hardcore+edge passed |
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
import torch.nn.functional as F
model_name = "gorkem371/pii-intent-classifier-xlmr-large"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
model.eval()
def classify_pii(context: str, entity: str, entity_type: str) -> dict:
"""
Classify whether a message contains PII sharing intent.
Args:
context: The full message text
entity: The specific entity to classify (e.g., phone number, "NONE" if implicit)
entity_type: Type of entity (PHONE, EMAIL, SOCIAL_MEDIA, IBAN, ADDRESS, URL, etc.)
Returns:
dict with 'is_pii' (bool) and 'confidence' (float)
"""
text = f"{context} </s> {entity} | {entity_type}"
inputs = tokenizer(text, max_length=256, padding="max_length", truncation=True, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
probs = F.softmax(outputs.logits, dim=-1)
pred = torch.argmax(probs, dim=-1).item()
confidence = probs[0][pred].item()
return {
"is_pii": pred == 1,
"label": "PII" if pred == 1 else "NOT_PII",
"confidence": round(confidence, 4)
}
# Examples
print(classify_pii("my number is 05321234567 call me", "05321234567", "PHONE"))
# {'is_pii': True, 'label': 'PII', 'confidence': 0.9987}
print(classify_pii("order number is ORD-784321", "ORD-784321", "PHONE"))
# {'is_pii': False, 'label': 'NOT_PII', 'confidence': 0.9954}
print(classify_pii("i will send you my whatsapp tomorrow", "NONE", "PHONE"))
# {'is_pii': True, 'label': 'PII', 'confidence': 0.9821}
print(classify_pii("oda numaram 532 otelde buluşalım", "NONE", "PHONE"))
# {'is_pii': False, 'label': 'NOT_PII', 'confidence': 0.9876}
The model expects input in the following format:
{context} </s> {entity} | {entity_type}
"NONE" for implicit PII intentPHONE, EMAIL, SOCIAL_MEDIA, IBAN, CREDIT_CARD, ADDRESS, URL, CRYPTO_ADDRESS, OFF_PLATFORM_ATTEMPT| Type | Description | Example |
|---|---|---|
| PHONE | Phone numbers | 05321234567, +966501234567 |
| Email addresses | user@gmail.com | |
| SOCIAL_MEDIA | Social media handles | @username, Instagram/TikTok/Telegram |
| IBAN | Bank account numbers | TR33000610... |
| ADDRESS | Physical addresses | 123 Oxford Street London |
| URL | Websites | my-site.com |
| CREDIT_CARD | Credit card numbers | 4532... |
| CRYPTO_ADDRESS | Cryptocurrency addresses | 0x... |
| OFF_PLATFORM_ATTEMPT | Attempts to move off-platform | "let's talk on WhatsApp" |
Author: Gorkem Yildiz
If you use this model, please cite:
@misc{pii-intent-classifier-2026,
title={PII Intent Classifier: Multilingual Context-Aware PII Detection},
author={Gorkem Yildiz},
year={2026},
url={https://huggingface.co/gorkem371/pii-intent-classifier-xlmr-large},
howpublished={\url{https://gorkemyildiz.com}}
}
Base model
FacebookAI/xlm-roberta-large