Token Classification
Transformers
Safetensors
PyTorch
Arabic
distilbert
ner
pii
pii-detection
de-identification
privacy
healthcare
medical
clinical
phi
arabic
openmed
Eval Results (legacy)
Instructions to use OpenMed/OpenMed-PII-Turkish-mLiteClinical-Base-135M-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenMed/OpenMed-PII-Turkish-mLiteClinical-Base-135M-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="OpenMed/OpenMed-PII-Turkish-mLiteClinical-Base-135M-v1")# Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("OpenMed/OpenMed-PII-Turkish-mLiteClinical-Base-135M-v1") model = AutoModelForTokenClassification.from_pretrained("OpenMed/OpenMed-PII-Turkish-mLiteClinical-Base-135M-v1", device_map="auto") - Notebooks
- Google Colab
- Kaggle
| language: | |
| - ar | |
| license: apache-2.0 | |
| base_model: distilbert/distilbert-base-multilingual-cased | |
| tags: | |
| - token-classification | |
| - ner | |
| - pii | |
| - pii-detection | |
| - de-identification | |
| - privacy | |
| - healthcare | |
| - medical | |
| - clinical | |
| - phi | |
| - arabic | |
| - pytorch | |
| - transformers | |
| - openmed | |
| pipeline_tag: token-classification | |
| library_name: transformers | |
| metrics: | |
| - f1 | |
| - precision | |
| - recall | |
| model-index: | |
| - name: OpenMed-PII-Arabic-mLiteClinical-Base-135M-v1 | |
| results: | |
| - task: | |
| type: token-classification | |
| name: Named Entity Recognition | |
| dataset: | |
| name: AI4Privacy + Synthetic Arabic PII | |
| type: ai4privacy/pii-masking-200k | |
| split: test | |
| metrics: | |
| - type: f1 | |
| value: 0.8911 | |
| name: F1 (micro) | |
| - type: precision | |
| value: 0.8846 | |
| name: Precision | |
| - type: recall | |
| value: 0.8976 | |
| name: Recall | |
| widget: | |
| - text: "د. أحمد محمد (رقم الهوية: 1234567890) يمكن التواصل معه عبر ahmed.mohammed@hospital.sa أو +966 50 123 4567. العنوان: شارع الملك فهد 25، الرياض 11564." | |
| example_title: Clinical Note with PII (Arabic) | |
| # OpenMed-PII-Arabic-mLiteClinical-Base-135M-v1 | |
| **Arabic PII Detection Model** | 135M Parameters | Open Source | |
| []() []() []() | |
| ## Model Description | |
| **OpenMed-PII-Arabic-mLiteClinical-Base-135M-v1** is a transformer-based token classification model fine-tuned for **Personally Identifiable Information (PII) detection in Arabic text**. This model identifies and classifies **54 types of sensitive information** including names, addresses, social security numbers, medical record numbers, and more. | |
| ### Key Features | |
| - **Arabic-Optimized**: Specifically trained on Arabic text for optimal performance | |
| - **High Accuracy**: Achieves strong F1 scores across diverse PII categories | |
| - **Comprehensive Coverage**: Detects 55+ entity types spanning personal, financial, medical, and contact information | |
| - **Privacy-Focused**: Designed for de-identification and compliance with GDPR and other privacy regulations | |
| - **Production-Ready**: Optimized for real-world text processing pipelines | |
| ## Performance | |
| Evaluated on the Arabic test split (AI4Privacy + synthetic data): | |
| | Metric | Score | | |
| |:---|:---:| | |
| | **Micro F1** | **0.8911** | | |
| | Precision | 0.8846 | | |
| | Recall | 0.8976 | | |
| | Macro F1 | 0.6671 | | |
| | Weighted F1 | 0.8866 | | |
| | Accuracy | 0.9224 | | |
| ### Top 10 Arabic PII Models | |
| | Rank | Model | F1 | Precision | Recall | | |
| |:---:|:---|:---:|:---:|:---:| | |
| | 1 | [OpenMed-PII-Arabic-SnowflakeMed-Large-568M-v1](https://huggingface.co/OpenMed/OpenMed-PII-Arabic-SnowflakeMed-Large-568M-v1) | 0.8976 | 0.8909 | 0.9045 | | |
| | 2 | [OpenMed-PII-Arabic-BigMed-Large-560M-v1](https://huggingface.co/OpenMed/OpenMed-PII-Arabic-BigMed-Large-560M-v1) | 0.8965 | 0.8898 | 0.9034 | | |
| | 3 | [OpenMed-PII-Arabic-ClinicalBGE-Large-568M-v1](https://huggingface.co/OpenMed/OpenMed-PII-Arabic-ClinicalBGE-Large-568M-v1) | 0.8962 | 0.8881 | 0.9043 | | |
| | 4 | [OpenMed-PII-Arabic-NomicMed-Large-395M-v1](https://huggingface.co/OpenMed/OpenMed-PII-Arabic-NomicMed-Large-395M-v1) | 0.8945 | 0.8920 | 0.8970 | | |
| | 5 | [OpenMed-PII-Arabic-BigMed-Large-278M-v1](https://huggingface.co/OpenMed/OpenMed-PII-Arabic-BigMed-Large-278M-v1) | 0.8942 | 0.8873 | 0.9013 | | |
| | 6 | [OpenMed-PII-Arabic-SuperClinical-Large-434M-v1](https://huggingface.co/OpenMed/OpenMed-PII-Arabic-SuperClinical-Large-434M-v1) | 0.8940 | 0.8858 | 0.9024 | | |
| | 7 | [OpenMed-PII-Arabic-BioClinicalModern-Large-395M-v1](https://huggingface.co/OpenMed/OpenMed-PII-Arabic-BioClinicalModern-Large-395M-v1) | 0.8932 | 0.8899 | 0.8966 | | |
| | 8 | [OpenMed-PII-Arabic-ModernMed-Large-395M-v1](https://huggingface.co/OpenMed/OpenMed-PII-Arabic-ModernMed-Large-395M-v1) | 0.8928 | 0.8894 | 0.8962 | | |
| | 9 | [OpenMed-PII-Arabic-mSuperClinical-Large-279M-v1](https://huggingface.co/OpenMed/OpenMed-PII-Arabic-mSuperClinical-Large-279M-v1) | 0.8926 | 0.8813 | 0.9042 | | |
| | 10 | [OpenMed-PII-Arabic-SuperMedical-Large-355M-v1](https://huggingface.co/OpenMed/OpenMed-PII-Arabic-SuperMedical-Large-355M-v1) | 0.8918 | 0.8854 | 0.8983 | | |
| ## Supported Entity Types | |
| This model detects **54 PII entity types** organized into categories: | |
| <details> | |
| <summary><strong>Identifiers</strong> (22 types)</summary> | |
| | Entity | Description | | |
| |:---|:---| | |
| | `ACCOUNTNAME` | Accountname | | |
| | `BANKACCOUNT` | Bankaccount | | |
| | `BIC` | Bic | | |
| | `BITCOINADDRESS` | Bitcoinaddress | | |
| | `CREDITCARD` | Creditcard | | |
| | `CREDITCARDISSUER` | Creditcardissuer | | |
| | `CVV` | Cvv | | |
| | `ETHEREUMADDRESS` | Ethereumaddress | | |
| | `IBAN` | Iban | | |
| | `IMEI` | Imei | | |
| | ... | *and 12 more* | | |
| </details> | |
| <details> | |
| <summary><strong>Personal Info</strong> (11 types)</summary> | |
| | Entity | Description | | |
| |:---|:---| | |
| | `AGE` | Age | | |
| | `DATEOFBIRTH` | Dateofbirth | | |
| | `EYECOLOR` | Eyecolor | | |
| | `FIRSTNAME` | Firstname | | |
| | `GENDER` | Gender | | |
| | `HEIGHT` | Height | | |
| | `LASTNAME` | Lastname | | |
| | `MIDDLENAME` | Middlename | | |
| | `OCCUPATION` | Occupation | | |
| | `PREFIX` | Prefix | | |
| | ... | *and 1 more* | | |
| </details> | |
| <details> | |
| <summary><strong>Contact Info</strong> (2 types)</summary> | |
| | Entity | Description | | |
| |:---|:---| | |
| | `EMAIL` | Email | | |
| | `PHONE` | Phone | | |
| </details> | |
| <details> | |
| <summary><strong>Location</strong> (9 types)</summary> | |
| | Entity | Description | | |
| |:---|:---| | |
| | `BUILDINGNUMBER` | Buildingnumber | | |
| | `CITY` | City | | |
| | `COUNTY` | County | | |
| | `GPSCOORDINATES` | Gpscoordinates | | |
| | `ORDINALDIRECTION` | Ordinaldirection | | |
| | `SECONDARYADDRESS` | Secondaryaddress | | |
| | `STATE` | State | | |
| | `STREET` | Street | | |
| | `ZIPCODE` | Zipcode | | |
| </details> | |
| <details> | |
| <summary><strong>Organization</strong> (3 types)</summary> | |
| | Entity | Description | | |
| |:---|:---| | |
| | `JOBDEPARTMENT` | Jobdepartment | | |
| | `JOBTITLE` | Jobtitle | | |
| | `ORGANIZATION` | Organization | | |
| </details> | |
| <details> | |
| <summary><strong>Financial</strong> (5 types)</summary> | |
| | Entity | Description | | |
| |:---|:---| | |
| | `AMOUNT` | Amount | | |
| | `CURRENCY` | Currency | | |
| | `CURRENCYCODE` | Currencycode | | |
| | `CURRENCYNAME` | Currencyname | | |
| | `CURRENCYSYMBOL` | Currencysymbol | | |
| </details> | |
| <details> | |
| <summary><strong>Temporal</strong> (2 types)</summary> | |
| | Entity | Description | | |
| |:---|:---| | |
| | `DATE` | Date | | |
| | `TIME` | Time | | |
| </details> | |
| ## Usage | |
| ### Quick Start | |
| ```python | |
| from transformers import pipeline | |
| # Load the PII detection pipeline | |
| ner = pipeline("ner", model="OpenMed/OpenMed-PII-Arabic-mLiteClinical-Base-135M-v1", aggregation_strategy="simple") | |
| text = """ | |
| المريض خالد العتيبي (تاريخ الميلاد: 15/03/1985، رقم الهوية: 9876543210) تم فحصه اليوم. | |
| التواصل: khaled.otaibi@email.sa، الهاتف: +966 50 123 4567. | |
| العنوان: شارع العليا 42، الرياض 11432. | |
| """ | |
| entities = ner(text) | |
| for entity in entities: | |
| print(f"{entity['entity_group']}: {entity['word']} (score: {entity['score']:.3f})") | |
| ``` | |
| ### De-identification Example | |
| ```python | |
| def redact_pii(text, entities, placeholder='[REDACTED]'): | |
| """Replace detected PII with placeholders.""" | |
| # Sort entities by start position (descending) to preserve offsets | |
| sorted_entities = sorted(entities, key=lambda x: x['start'], reverse=True) | |
| redacted = text | |
| for ent in sorted_entities: | |
| redacted = redacted[:ent['start']] + f"[{ent['entity_group']}]" + redacted[ent['end']:] | |
| return redacted | |
| # Apply de-identification | |
| redacted_text = redact_pii(text, entities) | |
| print(redacted_text) | |
| ``` | |
| ### Batch Processing | |
| ```python | |
| from transformers import AutoModelForTokenClassification, AutoTokenizer | |
| import torch | |
| model_name = "OpenMed/OpenMed-PII-Arabic-mLiteClinical-Base-135M-v1" | |
| model = AutoModelForTokenClassification.from_pretrained(model_name) | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| texts = [ | |
| "المريض خالد العتيبي (تاريخ الميلاد: 15/03/1985، رقم الهوية: 9876543210) تم فحصه اليوم.", | |
| "التواصل: khaled.otaibi@email.sa، الهاتف: +966 50 123 4567.", | |
| ] | |
| inputs = tokenizer(texts, return_tensors='pt', padding=True, truncation=True) | |
| with torch.no_grad(): | |
| outputs = model(**inputs) | |
| predictions = torch.argmax(outputs.logits, dim=-1) | |
| ``` | |
| ## Training Details | |
| ### Dataset | |
| This model was trained on a combination of: | |
| - **[AI4Privacy PII Masking 200K](https://huggingface.co/datasets/ai4privacy/pii-masking-200k)**: Multilingual base dataset (200K records across 8 languages) | |
| - **[NVIDIA Nemotron-PII](https://huggingface.co/datasets/nvidia/Nemotron-PII)**: Seed dataset for synthetic data generation | |
| - **Synthetic Arabic Data**: ~25K high-quality samples generated with locale-specific formatting (National ID format, +966 phones, Arabic names, SAR/ر.س currency) | |
| - **Format**: BIO-tagged token classification | |
| - **Labels**: 76 BIO tags (54 entity types) | |
| ### Training Configuration | |
| - **Max Sequence Length**: 512 tokens | |
| - **Framework**: Hugging Face Transformers + Trainer API | |
| ## Intended Use & Limitations | |
| ### Intended Use | |
| - **De-identification**: Automated redaction of PII in Arabic clinical notes, medical records, and documents | |
| - **Compliance**: Supporting GDPR, and other privacy regulation compliance | |
| - **Data Preprocessing**: Preparing datasets for research by removing sensitive information | |
| - **Audit Support**: Identifying PII in document collections | |
| ### Limitations | |
| **Important**: This model is intended as an **assistive tool**, not a replacement for human review. | |
| - **False Negatives**: Some PII may not be detected; always verify critical applications | |
| - **Context Sensitivity**: Performance may vary with domain-specific terminology | |
| - **Language**: Optimized for Arabic text; may not perform well on other languages | |
| ## Citation | |
| ```bibtex | |
| @misc{openmed-pii-2026, | |
| title = {OpenMed-PII-Arabic-mLiteClinical-Base-135M-v1: Arabic PII Detection Model}, | |
| author = {OpenMed Science}, | |
| year = {2026}, | |
| publisher = {Hugging Face}, | |
| url = {https://huggingface.co/OpenMed/OpenMed-PII-Arabic-mLiteClinical-Base-135M-v1} | |
| } | |
| ``` | |
| ## Links | |
| - **Organization**: [OpenMed](https://huggingface.co/OpenMed) | |