You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

MAQSM PII Detection Model

Model Description

This model is a fine-tuned version of gemma3 specifically designed for Personally Identifiable Information (PII) detection and masking in Arabic and English text. The model identifies and replaces PII with [MASKED] tokens while preserving the original text structure and meaning.

Model Details

  • Base Model: google/gemma-3
  • Model Type: Causal Language Model
  • Fine-tuning Method: LoRA (Low-Rank Adaptation)
  • Languages: Arabic, English (Mixed-language support)
  • Task: PII Detection and Masking
  • License: Same as base model

Training Details

Training Data

  • Custom dataset for PII detection and masking
  • Mixed Arabic-English text samples
  • Various PII types including names, emails, phone numbers, addresses, IP addresses, national IDs, and financial information

Supported PII Types

The model is trained to detect and mask the following types of PII:

  • Personal Names: First, middle, and family names
  • Contact Information: Phone numbers, email addresses
  • Addresses: Physical addresses and locations
  • Identification Numbers: National IDs, SSNs, account numbers
  • Financial Information: Bank account details, credit card numbers
  • Technical Identifiers: IP addresses, MAC addresses
  • Dates: Birth dates and other personal dates
  • Cryptocurrency: Wallet addresses and transaction IDs

Usage

Quick Start

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline

# Load model and tokenizer
model_name = "imabedalghafer/maqsm_model_pii_removal_gemma34b"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    torch_dtype=torch.auto,
    device_map="auto",
    trust_remote_code=True
)

# Create pipeline
pipe = pipeline(
    "text-generation",
    model=model,
    tokenizer=tokenizer,
    device_map="auto"
)

# System message
system_msg = """
**Role Definition**
You are a specialized language model trained to identify and mask Personally Identifiable Information (PII) within textual data. 
"""

# Example usage
def mask_pii(text):
    prompt = [
        {"role": "system", "content": system_msg},
        {"role": "user", "content": f"{text}"}
    ]
    
    generation = pipe(prompt, do_sample=True, temperature=0.7, top_p=0.8, top_k=20)
    output = generation[0]['generated_text'][-1]['content'].strip()
    
    
    return output

# Test the model
test_text = "ุงุณู…ูŠ ุฃุญู…ุฏ ู…ุญู…ุฏ ูˆุฑู‚ู… ู‡ุงุชููŠ 123-456-7890"
masked_text = mask_pii(test_text)
print(f"Original: {test_text}")
print(f"Masked: {masked_text}")

Expected Output Format

Input:

"ุงุณู…ูŠ ุฃุญู…ุฏ ู…ุญู…ุฏ ูˆุฑู‚ู… ู‡ุงุชููŠ 123-456-7890"

Output:

"ุงุณู…ูŠ [MASKED] ูˆุฑู‚ู… ู‡ุงุชููŠ [MASKED]"

Limitations

  • The model is primarily trained on Arabic and English text
  • Performance may vary with domain-specific PII types not covered in training
  • May occasionally over-mask or under-mask certain edge cases
  • Requires careful prompt engineering for optimal results

Ethical Considerations

This model is designed to protect individual privacy by identifying and masking PII. However:

  • Users should verify masked output for completeness
  • The model should not be the sole method for PII protection in critical applications
  • Consider human review for sensitive documents
  • Be aware of potential false positives/negatives

Citation

If you use this model in your research, please cite:

@misc{maqsm_pii_model_2025,
  title={MAQSM PII Detection Model: Fine-tuned Gemma-3-4B for Arabic-English PII Masking},
  author={TheConsultants Team},
  year={2025},
  publisher={Hugging Face},
  url={https://huggingface.co/imabedalghafer/maqsm_model_pii_removal_gemma34b}
}

License

This model inherits the license from the base model (google/gemma-3-4b-it). Please refer to the base model's license for terms and conditions.

Contact

For questions, issues, or collaboration opportunities, please reach out through the Hugging Face model repository or create an issue in the discussions section.


Disclaimer: This model is provided as-is for research and development purposes. Users are responsible for ensuring compliance with applicable privacy laws and regulations when using this model in production environments.

Downloads last month
-
Safetensors
Model size
5B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support