Instructions to use Maryam033/bert-privacy-detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Maryam033/bert-privacy-detector with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Maryam033/bert-privacy-detector")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Maryam033/bert-privacy-detector") model = AutoModelForSequenceClassification.from_pretrained("Maryam033/bert-privacy-detector", device_map="auto") - Notebooks
- Google Colab
- Kaggle
🔒 Multilingual Privacy-Sensitive Text Detection (BERT)
A BERT-based classifier that detects whether a short message (Urdu or English) contains sensitive personal information such as phone numbers, CNIC/ID numbers, addresses, etc.
| Label | Meaning |
|---|---|
| 0 | Non-Sensitive |
| 1 | Sensitive |
Use case: privacy protection in messaging applications (warn the user before they send personal data).
Examples
| Text | Prediction |
|---|---|
| My phone number is 03XXXXXXXXX. | Sensitive |
| I study computer science. | Non-Sensitive |
| میرا شناختی کارڈ نمبر یہ ہے۔ | Sensitive |
Model
- Base model:
bert-base-multilingual-cased(encoder-only) - Task: binary sequence classification
- Framework: Hugging Face Transformers + PyTorch
- Max length: 128 tokens, 3 epochs, learning rate 2e-5, batch size 16
- Split: 80% train / 10% validation / 10% test (stratified)
Fine-tuned model on Hugging Face: https://huggingface.co/Maryam033/bert-privacy-detector
Results
Replace with your own numbers from the notebook's test set evaluation.
| Accuracy | Precision | Recall | F1 |
|---|---|---|---|
| XX.XX | XX.XX | XX.XX | XX.XX |
Project structure
├── BERT_Privacy_Sensitive_Detection.ipynb # training + evaluation notebook
├── dataset/privacy_dataset.csv # generated dataset
├── app.py # Streamlit web app
├── requirements.txt
└── README.md
Run the notebook
- Open
BERT_Privacy_Sensitive_Detection.ipynbin Google Colab and select a T4 GPU runtime. - Upload the data files to
/content/:train-00000-of-00001.parquet,test-00000-of-00001.parquet,urdu_ner.txt. - Run all cells from top to bottom. Check the printout of the data-loading cell (columns, label counts) before training.
- The last cells push the trained model to the Hugging Face Hub.
Run the app locally
pip install -r requirements.txt
streamlit run app.py
Before running, set MODEL_ID in app.py to your Hugging Face model repo.
Live demo
Streamlit app: https://Privacy_Sensitive_Detection.app
Dataset
The model is trained on our own datasets plus a synthetic bilingual set:
train-00000-of-00001.parquet– training data (90% train / 10% validation, stratified)test-00000-of-00001.parquet– held-out test data (never used for training)urdu_ner.txt– Urdu NER corpus (CoNLL format: onetoken tagper line, blank line between sentences). A sentence is labelled Sensitive if it contains a person/location tag (configurable viaSENSITIVE_TAGS), otherwise Non-Sensitive.- Synthetic Urdu / English / Roman Urdu messages (
dataset/privacy_dataset.csv) covering phone numbers, CNIC, email, address, bank account/IBAN, password, OTP, card, passport and date of birth, plus everyday sentences. Templates are split between train / validation / test.
Results are reported separately for the real test data and the synthetic test data.
Limitations
- Labels derived from NER tags are a weak proxy for sensitivity.
- The synthetic part is template-based, so its test score is optimistic; the real test set is the more honest number.
- Trained on a limited dataset; may miss unusual formats of personal data.
- Short messages work best; very long text is truncated at 128 tokens.
- Not a replacement for a full data-loss-prevention system.
Author
Maryam Zubair Ahmed – University of Gwadar/ Large Language Model
- Downloads last month
- 127
Model tree for Maryam033/bert-privacy-detector
Base model
google-bert/bert-base-multilingual-cased